3
0
corteza/api/sam/spec.json
2018-12-04 15:26:51 +01:00

719 lines
17 KiB
JSON

[
{
"title": "Channels",
"description": "A channel is a representation of a sequence of messages. It has meta data like channel subject. Channels may be public, private or group.",
"package": "sam",
"entrypoint": "channel",
"path": "/channels",
"authentication": [
"Client ID",
"Session ID"
],
"apis": [
{
"name": "list",
"method": "GET",
"title": "List channels",
"path": "/",
"parameters": {
"GET": [
{
"type": "string",
"name": "query",
"required": false,
"title": "Search query"
}
]
}
},
{
"name": "create",
"method": "POST",
"title": "Create new channel",
"path": "/",
"parameters": {
"post": [
{
"type": "string",
"name": "name",
"required": true,
"title": "Name of Channel"
},
{
"type": "string",
"name": "topic",
"required": false,
"title": "Subject of Channel"
},
{
"type": "string",
"name": "type",
"required": false,
"title": "Channel type"
},
{
"type": "[]string",
"name": "members",
"required": false,
"title": "Initial members of the channel"
}
]
}
},
{
"name": "update",
"method": "PUT",
"path": "/{channelID}",
"title": "Update channel details",
"parameters": {
"path": [
{
"type": "uint64",
"name": "channelID",
"required": true,
"title": "Channel ID"
}
],
"post": [
{
"type": "string",
"name": "name",
"required": false,
"title": "Name of Channel"
},
{
"type": "string",
"name": "topic",
"required": false,
"title": "Subject of Channel"
},
{
"type": "string",
"name": "type",
"required": false,
"title": "Channel type"
},
{
"type": "uint64",
"name": "organisationID",
"required": false,
"title": "Move channel to different organisation"
}
]
}
},
{
"name": "state",
"method": "PUT",
"path": "/{channelID}/state",
"title": "Update channel state",
"parameters": {
"path": [
{
"type": "uint64",
"name": "channelID",
"required": true,
"title": "Channel ID"
}
],
"post": [
{
"type": "string",
"name": "state",
"required": true,
"title": "Valid values: delete, undelete, archive, unarchive"
}
]
}
},
{
"name": "read",
"method": "GET",
"path": "/{channelID}",
"title": "Read channel details",
"parameters": {
"path": [
{
"type": "uint64",
"name": "channelID",
"required": true,
"title": "Channel ID"
}
]
}
},
{
"name": "members",
"method": "GET",
"path": "/{channelID}/members",
"title": "List channel members",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
}
]
}
},
{
"name": "join",
"method": "PUT",
"path": "/{channelID}/members/{userID}",
"title": "Join channel",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
},
{
"name": "userID",
"type": "uint64",
"required": false,
"title": "Member ID"
}
]
}
},
{
"name": "part",
"method": "DELETE",
"path": "/{channelID}/members/{userID}",
"title": "Remove member from channel",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
},
{
"name": "userID",
"type": "uint64",
"required": false,
"title": "Member ID"
}
]
}
},
{
"name": "invite",
"method": "POST",
"path": "/{channelID}/invite",
"title": "Join channel",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
}
],
"post": [
{
"name": "userID",
"type": "[]uint64",
"required": false,
"title": "User ID"
}
]
}
},
{
"name": "attach",
"path": "/{channelID}/attach",
"method": "POST",
"title": "Attach file to channel",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
}
],
"post": [
{
"name": "replyTo",
"type": "uint64",
"required": false,
"title": "Upload as a reply"
},
{
"name": "upload",
"type": "*multipart.FileHeader",
"required": true,
"title": "File to upload"
}
]
}
}
]
},
{
"title": "Messages",
"package": "sam",
"path": "/channels/{channelID}/messages",
"parameters": {
"path": [
{
"name": "channelID",
"type": "uint64",
"required": true,
"title": "Channel ID"
}
]
},
"entrypoint": "message",
"authentication": [
"Client ID",
"Session ID"
],
"apis": [
{
"name": "create",
"path": "/",
"method": "POST",
"title": "Post new message to the channel",
"parameters": {
"post": [
{
"type": "string",
"name": "message",
"required": true,
"title": "Message contents (markdown)"
}
]
}
},
{
"name": "history",
"path": "/",
"method": "GET",
"title": "All messages (channel history)",
"parameters": {
"get": [
{
"name": "lastMessageID",
"type": "uint64",
"required": false,
"title": ""
}
]
}
},
{
"name": "edit",
"path": "/{messageID}",
"method": "PUT",
"title": "Edit existing message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
],
"post": [
{
"type": "string",
"name": "message",
"required": true,
"title": "Message contents (markdown)"
}
]
}
},
{
"name": "delete",
"path": "/{messageID}",
"method": "DELETE",
"title": "Delete existing message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "replyGet",
"path": "/{messageID}/replies",
"method": "GET",
"title": "Returns all replies to a message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "replyCreate",
"path": "/{messageID}/replies",
"method": "POST",
"title": "Reply to a message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
],
"post": [
{
"type": "string",
"name": "message",
"required": true,
"title": "Message contents (markdown)"
}
]
}
},
{
"name": "markAsUnread",
"path": "/{messageID}/unread",
"method": "POST",
"title": "Mark message in channel (or thread) as unread",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "pinCreate",
"path": "/{messageID}/pin",
"method": "POST",
"title": "Pin message to channel (public bookmark)",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "pinRemove",
"path": "/{messageID}/pin",
"method": "DELETE",
"title": "Pin message to channel (public bookmark)",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "bookmarkCreate",
"path": "/{messageID}/bookmark",
"method": "POST",
"title": "Bookmark a message (private bookmark)",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "bookmarkRemove",
"path": "/{messageID}/bookmark",
"method": "DELETE",
"title": "Remove boomark from message (private bookmark)",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
}
]
}
},
{
"name": "reactionCreate",
"path": "/{messageID}/reaction/{reaction}",
"method": "POST",
"title": "React to a message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
},
{
"name": "reaction",
"type": "string",
"required": true,
"title": "Reaction"
}
]
}
},
{
"name": "reactionRemove",
"path": "/{messageID}/reaction/{reaction}",
"method": "DELETE",
"title": "Delete reaction from a message",
"parameters": {
"path": [
{
"name": "messageID",
"type": "uint64",
"required": true,
"title": "Message ID"
},
{
"name": "reaction",
"type": "string",
"required": true,
"title": "Reaction"
}
]
}
}
]
},
{
"title": "Attachments",
"package": "sam",
"path": "/attachment/{attachmentID}",
"parameters": {
"path": [
{
"name": "attachmentID",
"type": "uint64",
"required": true,
"title": "Attachment ID"
}
]
},
"entrypoint": "attachment",
"authentication": [
"Client ID",
"Session ID"
],
"apis": [
{
"name": "original",
"path": "/original/{name}",
"method": "GET",
"title": "Serves attached file",
"parameters": {
"path": [
{
"name": "name",
"type": "string",
"required": true,
"title": "File name"
}
],
"get": [
{
"type": "bool",
"name": "download",
"required": false,
"title": "Force file download"
}
]
}
},
{
"name": "preview",
"path": "/preview.{ext}",
"method": "GET",
"title": "Serves preview of an attached file",
"parameters": {
"path": [
{
"name": "ext",
"type": "string",
"required": true,
"title": "Preview extension/format"
}
]
}
}
]
},
{
"name": "search",
"entrypoint": "search",
"authentication": [
"Client ID",
"Session ID"
],
"path": "/search",
"method": "GET",
"title": "Search entry point",
"parameters": {
"get": [
{
"name": "query",
"type": "string",
"required": false,
"title": "Search query"
}
]
},
"apis": [
{
"method": "GET",
"name": "messages",
"path": "/messages",
"title": "Search for messages",
"parameters": {
"GET": [
{
"name": "inChannel",
"type": "uint64",
"required": false,
"title": "Search only in one channel"
},
{
"name": "fromUser",
"type": "uint64",
"required": false,
"title": "Search only from one user"
},
{
"name": "firstID",
"type": "uint64",
"required": false,
"title": "Paging; return newer messages only (higher id)"
},
{
"name": "lastID",
"type": "uint64",
"required": false,
"title": "Paging; return older messages only (lower id)"
}
]
}
}
]
},
{
"title": "Permissions",
"package": "sam",
"parameters": {},
"entrypoint": "permissions",
"authentication": [
"Client ID",
"Session ID"
],
"struct": [
{
"imports": [
"github.com/crusttech/crust/internal/rbac"
]
}
],
"apis": [
{
"name": "list",
"path": "/permissions",
"method": "GET",
"title": "List default permissions",
"parameters": {}
},
{
"name": "getTeam",
"path": "/permissions/{team}",
"method": "GET",
"title": "Retrieve current permission settings",
"parameters": {
"path": [
{
"name": "team",
"type": "string",
"required": true,
"title": "Team ID"
}
],
"get": [
{
"name": "scope",
"type": "string",
"required": true,
"title": "Permissions scope"
},
{
"name": "resource",
"type": "string",
"required": true,
"title": "Permissions resource"
}
]
}
},
{
"name": "setTeam",
"path": "/permissions/{team}",
"method": "POST",
"title": "Update permission settings",
"parameters": {
"path": [
{
"name": "team",
"type": "string",
"required": true,
"title": "Team ID"
}
],
"post": [
{
"name": "permissions",
"type": "[]rbac.Permission",
"required": true,
"title": "List of permissions to set"
}
]
}
}
]
}
]