diff --git a/api/crm/spec.json b/api/crm/spec.json index e8907b908..a0ebcad1c 100644 --- a/api/crm/spec.json +++ b/api/crm/spec.json @@ -1,1013 +1,1038 @@ [ - { - "title": "Permissions", - "parameters": {}, - "entrypoint": "permissions", - "path": "/permissions", - "authentication": [], - "apis": [ - { - "name": "effective", - "path": "/effective", - "method": "GET", - "title": "Effective rules for current user", - "parameters": { - "get": [ + { + "title": "Permissions", + "parameters": {}, + "entrypoint": "permissions", + "path": "/permissions", + "authentication": [], + "apis": [ { - "name": "resource", - "type": "string", - "required": false, - "title": "Show only rules for a specific resource" + "name": "effective", + "path": "/effective", + "method": "GET", + "title": "Effective rules for current user", + "parameters": { + "get": [ + { + "name": "resource", + "type": "string", + "required": false, + "title": "Show only rules for a specific resource" + } + ] + } } - ] - } - } - ] - }, - { - "title": "Permissions", - "description": "Permissions", - "entrypoint": "page", - "path": "/permissions", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types" ] - } - ], - "apis": [ - { - "name": "list", - "method": "GET", - "path": "/", - "title": "List available pages", - "parameters": { - "get": [ - { - "type": "uint64", - "name": "selfID", - "required": false, - "title": "Parent page ID" - } - ] - } - } - ] - }, - { - "title": "Pages", - "description": "CRM module pages", - "entrypoint": "page", - "path": "/page", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types" - ] - } - ], - "apis": [ - { - "name": "list", - "method": "GET", - "path": "/", - "title": "List available pages", - "parameters": { - "get": [ - { - "type": "uint64", - "name": "selfID", - "required": false, - "title": "Parent page ID" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create page", - "path": "/", - "parameters": { - "post": [ - { - "type": "uint64", - "name": "selfID", - "required": false, - "title": "Parent Page ID" - }, - { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Module ID" - }, - { - "type": "string", - "name": "title", - "required": true, - "title": "Title" - }, - { - "type": "string", - "name": "description", - "required": false, - "title": "Description" - }, - { - "type": "bool", - "name": "visible", - "required": false, - "title": "Visible in navigation" - }, - { - "type": "sqlxTypes.JSONText", - "name": "blocks", - "required": true, - "title": "Blocks JSON" - } - ] - } - }, - { - "name": "read", - "path": "/{pageID}", - "method": "GET", - "title": "Get page details", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "pageID", - "required": true, - "title": "Page ID" - } - ] - } - }, - { - "name": "tree", - "path": "/tree", - "method": "GET", - "title": "Get page all (non-record) pages, hierarchically", - "parameters": {} - }, - { - "name": "update", - "method": "POST", - "title": "Update page", - "path": "/{pageID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "pageID", - "required": true, - "title": "Page ID" - } - ], - "post": [ - { - "type": "uint64", - "name": "selfID", - "required": false, - "title": "Parent Page ID" - }, - { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Module ID (optional)" - }, - { - "type": "string", - "name": "title", - "required": true, - "title": "Title" - }, - { - "type": "string", - "name": "description", - "required": false, - "title": "Description" - }, - { - "type": "bool", - "name": "visible", - "required": false, - "title": "Visible in navigation" - }, - { - "type": "sqlxTypes.JSONText", - "name": "blocks", - "required": true, - "title": "Blocks JSON" - } - ] - } - }, - { - "name": "reorder", - "method": "POST", - "title": "Reorder pages", - "path": "/{selfID}/reorder", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "selfID", - "required": true, - "title": "Parent page ID" - } - ], - "post": [ - { - "type": "[]string", - "name": "pageIDs", - "required": true, - "title": "Page ID order" - } - ] - } - }, - { - "name": "delete", - "path": "/{pageID}", - "method": "Delete", - "title": "Delete page", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "pageID", - "required": true, - "title": "Page ID" - } - ] - } - }, - { - "name": "upload", - "path": "/{pageID}/attachment", - "method": "POST", - "title": "Uploads attachment to page", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "pageID", - "required": true, - "title": "Page ID" - } - ], - "post": [ - { - "name": "upload", - "type": "*multipart.FileHeader", - "required": true, - "title": "File to upload" - } - ] - } - } - ] - }, - { - "title": "Modules", - "description": "CRM module definitions", - "entrypoint": "module", - "path": "/module", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types", - "github.com/crusttech/crust/crm/types" - ] - } - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "List modules", - "path": "/", - "parameters": { - "get": [ - { - "type": "string", - "name": "query", - "required": false, - "title": "Search query" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create module", - "path": "/", - "parameters": { - "post": [ - { - "type": "string", - "name": "name", - "required": true, - "title": "Module Name" - }, - { - "type": "types.ModuleFieldSet", - "name": "fields", - "required": true, - "title": "Fields JSON" - }, - { - "type": "sqlxTypes.JSONText", - "name": "meta", - "required": true, - "title": "Module meta data" - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read module", - "path": "/{moduleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "moduleID", - "required": true, - "title": "Module ID" - } - ] - } - }, - { - "name": "update", - "method": "POST", - "title": "Update module", - "path": "/{moduleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "moduleID", - "required": true, - "title": "Module ID" - } - ], - "post": [ - { - "type": "string", - "name": "name", - "required": true, - "title": "Module Name" - }, - { - "type": "types.ModuleFieldSet", - "name": "fields", - "required": true, - "title": "Fields JSON" - }, - { - "type": "sqlxTypes.JSONText", - "name": "meta", - "required": true, - "title": "Module meta data" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Delete module", - "path": "/{moduleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "moduleID", - "required": true, - "title": "Module ID" - } - ] - } - } - ] - }, - { - "title": "Records", - "description": "CRM records ", - "entrypoint": "record", - "path": "/module/{moduleID}/record", - "authentication": [], - "struct": [ - { - "imports": [ - "github.com/crusttech/crust/crm/types" - ] - } - ], - "parameters": { - "path": [ - { - "type": "uint64", - "name": "moduleID", - "required": true, - "title": "Module ID" - } - ] }, - "apis": [ - { - "name": "report", - "method": "GET", - "title": "Generates report from module records", - "path": "/report", - "parameters": { - "get": [ + { + "title": "Permissions", + "description": "Permissions", + "entrypoint": "page", + "path": "/permissions", + "authentication": [], + "struct": [ { - "type": "string", - "name": "metrics", - "required": false, - "title": "Metrics (eg: 'SUM(money), MAX(calls)')" - }, - { - "type": "string", - "name": "dimensions", - "required": true, - "title": "Dimensions (eg: 'DATE(foo), status')" - }, - { - "type": "string", - "name": "filter", - "required": false, - "title": "Filter (eg: 'DATE(foo) > 2010')" + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types" + ] } - ] - } - }, - { - "name": "list", - "method": "GET", - "title": "List/read records from module section", - "path": "/", - "parameters": { - "get": [ + ], + "apis": [ { - "name": "filter", - "type": "string", - "required": false, - "title": "Filtering condition" - }, - { - "name": "page", - "type": "int", - "required": false, - "title": "Page number (0 based)" - }, - { - "name": "perPage", - "type": "int", - "required": false, - "title": "Returned items per page (default 50)" - }, - { - "name": "sort", - "type": "string", - "required": false, - "title": "Sort field (default id desc)" + "name": "list", + "method": "GET", + "path": "/", + "title": "List available pages", + "parameters": { + "get": [ + { + "type": "uint64", + "name": "selfID", + "required": false, + "title": "Parent page ID" + } + ] + } } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create record in module section", - "path": "/", - "parameters": { - "post": [ - { - "type": "types.RecordValueSet", - "name": "values", - "required": true, - "title": "Record values" - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read records by ID from module section", - "path": "/{recordID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "recordID", - "required": true, - "title": "Record ID" - } - ] - } - }, - { - "name": "update", - "method": "POST", - "title": "Update records in module section", - "path": "/{recordID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "recordID", - "required": true, - "title": "Record ID" - } - ], - "post": [ - { - "type": "types.RecordValueSet", - "name": "values", - "required": true, - "title": "Record values" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Delete record row from module section", - "path": "/{recordID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "recordID", - "required": true, - "title": "Record ID" - } - ] - } - }, - { - "name": "upload", - "path": "/{recordID}/{fieldName}/attachment", - "method": "POST", - "title": "Uploads attachment and validates it against record field requirements", - "parameters": { - "path": [ - { - "name": "recordID", - "type": "uint64", - "required": true, - "title": "Record ID" - }, - { - "name": "fieldName", - "type": "string", - "required": true, - "title": "Field name" - } - ], - "post": [ - { - "name": "upload", - "type": "*multipart.FileHeader", - "required": true, - "title": "File to upload" - } - ] - } - } - ] - }, - { - "title": "Charts", - "path": "/chart", - "entrypoint": "chart", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types" ] - } - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "List/read charts from module section", - "path": "/" - }, - { - "name": "create", - "method": "POST", - "title": "List/read charts from module section", - "path": "/", - "parameters": { - "post": [ - { - "type": "sqlxTypes.JSONText", - "name": "config", - "required": true, - "title": "Chart JSON" - }, - { - "name": "name", - "title": "Chart name", - "type": "string", - "required": true - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read charts by ID from module section", - "path": "/{chartID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "chartID", - "required": true, - "title": "Chart ID" - } - ] - } - }, - { - "name": "update", - "method": "POST", - "title": "Add/update charts in module section", - "path": "/{chartID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "chartID", - "required": true, - "title": "Chart ID" - } - ], - "post": [ - { - "type": "sqlxTypes.JSONText", - "name": "config", - "required": true, - "title": "Chart JSON" - }, - { - "name": "name", - "title": "Chart name", - "type": "string", - "required": true - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Delete chart", - "path": "/{chartID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "chartID", - "required": true, - "title": "Chart ID" - } - ] - } - } - ] - }, - { - "title": "Triggers", - "description": "CRM Triggers", - "entrypoint": "trigger", - "path": "/trigger", - "authentication": [], - "apis": [ - { - "name": "list", - "method": "GET", - "path": "/", - "title": "List available triggers", - "parameters": { - "get": [ - { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Filter triggers by module" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create trigger", - "path": "/", - "parameters": { - "post": [ - { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Module ID" - }, - { - "type": "string", - "name": "name", - "required": true, - "title": "Name" - }, - { - "type": "[]string", - "name": "actions", - "required": false, - "title": "Actions that trigger this trigger" - }, - { - "type": "bool", - "name": "enabled", - "required": false, - "title": "Enabled" - }, - { - "type": "string", - "name": "source", - "required": false, - "title": "Trigger source code" - } - ] - } - }, - { - "name": "read", - "path": "/{triggerID}", - "method": "GET", - "title": "Get trigger details", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "triggerID", - "required": true, - "title": "Trigger ID" - } - ] - } - }, - { - "name": "update", - "method": "POST", - "title": "Update trigger", - "path": "/{triggerID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "triggerID", - "required": true, - "title": "Trigger ID" - } - ], - "post": [ - { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Module ID" - }, - { - "type": "string", - "name": "name", - "required": true, - "title": "Name" - }, - { - "type": "[]string", - "name": "actions", - "required": false, - "title": "Actions that trigger this trigger" - }, - { - "type": "bool", - "name": "enabled", - "required": false, - "title": "Enabled" - }, - { - "type": "string", - "name": "source", - "required": false, - "title": "Trigger source code" - } - ] - } - }, - { - "name": "delete", - "path": "/{triggerID}", - "method": "Delete", - "title": "Delete trigger", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "triggerID", - "required": true, - "title": "Trigger ID" - } - ] - } - } - ] - }, - { - "title": "Notifications", - "description": "CRM Notifications", - "entrypoint": "notification", - "path": "/notification", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types" - ] - } - ], - "apis": [ - { - "name": "email/send", - "method": "POST", - "title": "Send email from the CRM", - "path": "/email", - "parameters": { - "post": [ - { "name": "to", "type": "[]string", "required": true, "title": "Email addresses or Crust user IDs" }, - { "name": "cc", "type": "[]string", "required": false, "title": "Email addresses or Crust user IDs" }, - { "name": "replyTo", "type": "string", "required": false, "title": "Crust user ID or email address in reply-to field" }, - { "name": "subject ", "type": "string", "required": false, "title": "Email subject" }, - { "name": "content", "type": "sqlxTypes.JSONText", "required": true, "title": "Message content" } - ] - } - } - ] - }, - { - "title": "Attachments", - "path": "/attachment/{kind}", - "entrypoint": "attachment", - "authentication": [ - "Client ID", - "Session ID" - ], - "parameters": { - "path": [ - { - "name": "kind", - "type": "string", - "required": true, - "title": "Attachment kind" - } - ] }, - "apis": [ - { - "name": "list", - "path": "/", - "method": "GET", - "title": "List, filter all page attachments", + { + "title": "Pages", + "description": "CRM module pages", + "entrypoint": "page", + "path": "/page", + "authentication": [], + "struct": [ + { + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types" + ] + } + ], + "apis": [ + { + "name": "list", + "method": "GET", + "path": "/", + "title": "List available pages", + "parameters": { + "get": [ + { + "type": "uint64", + "name": "selfID", + "required": false, + "title": "Parent page ID" + } + ] + } + }, + { + "name": "create", + "method": "POST", + "title": "Create page", + "path": "/", + "parameters": { + "post": [ + { + "type": "uint64", + "name": "selfID", + "required": false, + "title": "Parent Page ID" + }, + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Module ID" + }, + { + "type": "string", + "name": "title", + "required": true, + "title": "Title" + }, + { + "type": "string", + "name": "description", + "required": false, + "title": "Description" + }, + { + "type": "bool", + "name": "visible", + "required": false, + "title": "Visible in navigation" + }, + { + "type": "sqlxTypes.JSONText", + "name": "blocks", + "required": true, + "title": "Blocks JSON" + } + ] + } + }, + { + "name": "read", + "path": "/{pageID}", + "method": "GET", + "title": "Get page details", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "pageID", + "required": true, + "title": "Page ID" + } + ] + } + }, + { + "name": "tree", + "path": "/tree", + "method": "GET", + "title": "Get page all (non-record) pages, hierarchically", + "parameters": {} + }, + { + "name": "update", + "method": "POST", + "title": "Update page", + "path": "/{pageID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "pageID", + "required": true, + "title": "Page ID" + } + ], + "post": [ + { + "type": "uint64", + "name": "selfID", + "required": false, + "title": "Parent Page ID" + }, + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Module ID (optional)" + }, + { + "type": "string", + "name": "title", + "required": true, + "title": "Title" + }, + { + "type": "string", + "name": "description", + "required": false, + "title": "Description" + }, + { + "type": "bool", + "name": "visible", + "required": false, + "title": "Visible in navigation" + }, + { + "type": "sqlxTypes.JSONText", + "name": "blocks", + "required": true, + "title": "Blocks JSON" + } + ] + } + }, + { + "name": "reorder", + "method": "POST", + "title": "Reorder pages", + "path": "/{selfID}/reorder", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "selfID", + "required": true, + "title": "Parent page ID" + } + ], + "post": [ + { + "type": "[]string", + "name": "pageIDs", + "required": true, + "title": "Page ID order" + } + ] + } + }, + { + "name": "delete", + "path": "/{pageID}", + "method": "Delete", + "title": "Delete page", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "pageID", + "required": true, + "title": "Page ID" + } + ] + } + }, + { + "name": "upload", + "path": "/{pageID}/attachment", + "method": "POST", + "title": "Uploads attachment to page", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "pageID", + "required": true, + "title": "Page ID" + } + ], + "post": [ + { + "name": "upload", + "type": "*multipart.FileHeader", + "required": true, + "title": "File to upload" + } + ] + } + } + ] + }, + { + "title": "Modules", + "description": "CRM module definitions", + "entrypoint": "module", + "path": "/module", + "authentication": [], + "struct": [ + { + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types", + "github.com/crusttech/crust/crm/types" + ] + } + ], + "apis": [ + { + "name": "list", + "method": "GET", + "title": "List modules", + "path": "/", + "parameters": { + "get": [ + { + "type": "string", + "name": "query", + "required": false, + "title": "Search query" + } + ] + } + }, + { + "name": "create", + "method": "POST", + "title": "Create module", + "path": "/", + "parameters": { + "post": [ + { + "type": "string", + "name": "name", + "required": true, + "title": "Module Name" + }, + { + "type": "types.ModuleFieldSet", + "name": "fields", + "required": true, + "title": "Fields JSON" + }, + { + "type": "sqlxTypes.JSONText", + "name": "meta", + "required": true, + "title": "Module meta data" + } + ] + } + }, + { + "name": "read", + "method": "GET", + "title": "Read module", + "path": "/{moduleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "moduleID", + "required": true, + "title": "Module ID" + } + ] + } + }, + { + "name": "update", + "method": "POST", + "title": "Update module", + "path": "/{moduleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "moduleID", + "required": true, + "title": "Module ID" + } + ], + "post": [ + { + "type": "string", + "name": "name", + "required": true, + "title": "Module Name" + }, + { + "type": "types.ModuleFieldSet", + "name": "fields", + "required": true, + "title": "Fields JSON" + }, + { + "type": "sqlxTypes.JSONText", + "name": "meta", + "required": true, + "title": "Module meta data" + } + ] + } + }, + { + "name": "delete", + "method": "DELETE", + "title": "Delete module", + "path": "/{moduleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "moduleID", + "required": true, + "title": "Module ID" + } + ] + } + } + ] + }, + { + "title": "Records", + "description": "CRM records ", + "entrypoint": "record", + "path": "/module/{moduleID}/record", + "authentication": [], + "struct": [ + { + "imports": [ + "github.com/crusttech/crust/crm/types" + ] + } + ], "parameters": { - "get": [ + "path": [ + { + "type": "uint64", + "name": "moduleID", + "required": true, + "title": "Module ID" + } + ] + }, + "apis": [ { - "name": "pageID", - "type": "uint64", - "required": false, - "title": "Filter attachments by page ID" + "name": "report", + "method": "GET", + "title": "Generates report from module records", + "path": "/report", + "parameters": { + "get": [ + { + "type": "string", + "name": "metrics", + "required": false, + "title": "Metrics (eg: 'SUM(money), MAX(calls)')" + }, + { + "type": "string", + "name": "dimensions", + "required": true, + "title": "Dimensions (eg: 'DATE(foo), status')" + }, + { + "type": "string", + "name": "filter", + "required": false, + "title": "Filter (eg: 'DATE(foo) > 2010')" + } + ] + } }, { - "type": "uint64", - "name": "moduleID", - "required": false, - "title": "Filter attachments by mnodule ID" + "name": "list", + "method": "GET", + "title": "List/read records from module section", + "path": "/", + "parameters": { + "get": [ + { + "name": "filter", + "type": "string", + "required": false, + "title": "Filtering condition" + }, + { + "name": "page", + "type": "int", + "required": false, + "title": "Page number (0 based)" + }, + { + "name": "perPage", + "type": "int", + "required": false, + "title": "Returned items per page (default 50)" + }, + { + "name": "sort", + "type": "string", + "required": false, + "title": "Sort field (default id desc)" + } + ] + } }, { - "name": "recordID", - "type": "uint64", - "required": false, - "title": "Filter attachments by record ID" + "name": "create", + "method": "POST", + "title": "Create record in module section", + "path": "/", + "parameters": { + "post": [ + { + "type": "types.RecordValueSet", + "name": "values", + "required": true, + "title": "Record values" + } + ] + } }, { - "name": "fieldName", - "type": "string", - "required": false, - "title": "Filter attachments by field name" + "name": "read", + "method": "GET", + "title": "Read records by ID from module section", + "path": "/{recordID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "recordID", + "required": true, + "title": "Record ID" + } + ] + } }, { - "name": "page", - "type": "uint", - "required": false, - "title": "Page number (0 based)" + "name": "update", + "method": "POST", + "title": "Update records in module section", + "path": "/{recordID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "recordID", + "required": true, + "title": "Record ID" + } + ], + "post": [ + { + "type": "types.RecordValueSet", + "name": "values", + "required": true, + "title": "Record values" + } + ] + } }, { - "name": "perPage", - "type": "uint", - "required": false, - "title": "Returned items per page (default 50)" + "name": "delete", + "method": "DELETE", + "title": "Delete record row from module section", + "path": "/{recordID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "recordID", + "required": true, + "title": "Record ID" + } + ] + } + }, + { + "name": "upload", + "path": "/{recordID}/{fieldName}/attachment", + "method": "POST", + "title": "Uploads attachment and validates it against record field requirements", + "parameters": { + "path": [ + { + "name": "recordID", + "type": "uint64", + "required": true, + "title": "Record ID" + }, + { + "name": "fieldName", + "type": "string", + "required": true, + "title": "Field name" + } + ], + "post": [ + { + "name": "upload", + "type": "*multipart.FileHeader", + "required": true, + "title": "File to upload" + } + ] + } } - ] - } - }, - { - "name": "details", - "path": "/{attachmentID}", - "method": "GET", - "title": "Attachment details", + ] + }, + { + "title": "Charts", + "path": "/chart", + "entrypoint": "chart", + "authentication": [], + "struct": [ + { + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types" + ] + } + ], + "apis": [ + { + "name": "list", + "method": "GET", + "title": "List/read charts from module section", + "path": "/" + }, + { + "name": "create", + "method": "POST", + "title": "List/read charts from module section", + "path": "/", + "parameters": { + "post": [ + { + "type": "sqlxTypes.JSONText", + "name": "config", + "required": true, + "title": "Chart JSON" + }, + { + "name": "name", + "title": "Chart name", + "type": "string", + "required": true + } + ] + } + }, + { + "name": "read", + "method": "GET", + "title": "Read charts by ID from module section", + "path": "/{chartID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "chartID", + "required": true, + "title": "Chart ID" + } + ] + } + }, + { + "name": "update", + "method": "POST", + "title": "Add/update charts in module section", + "path": "/{chartID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "chartID", + "required": true, + "title": "Chart ID" + } + ], + "post": [ + { + "type": "sqlxTypes.JSONText", + "name": "config", + "required": true, + "title": "Chart JSON" + }, + { + "name": "name", + "title": "Chart name", + "type": "string", + "required": true + } + ] + } + }, + { + "name": "delete", + "method": "DELETE", + "title": "Delete chart", + "path": "/{chartID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "chartID", + "required": true, + "title": "Chart ID" + } + ] + } + } + ] + }, + { + "title": "Triggers", + "description": "CRM Triggers", + "entrypoint": "trigger", + "path": "/trigger", + "authentication": [], + "apis": [ + { + "name": "list", + "method": "GET", + "path": "/", + "title": "List available triggers", + "parameters": { + "get": [ + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Filter triggers by module" + } + ] + } + }, + { + "name": "create", + "method": "POST", + "title": "Create trigger", + "path": "/", + "parameters": { + "post": [ + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Module ID" + }, + { + "type": "string", + "name": "name", + "required": true, + "title": "Name" + }, + { + "type": "[]string", + "name": "actions", + "required": false, + "title": "Actions that trigger this trigger" + }, + { + "type": "bool", + "name": "enabled", + "required": false, + "title": "Enabled" + }, + { + "type": "string", + "name": "source", + "required": false, + "title": "Trigger source code" + } + ] + } + }, + { + "name": "read", + "path": "/{triggerID}", + "method": "GET", + "title": "Get trigger details", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "triggerID", + "required": true, + "title": "Trigger ID" + } + ] + } + }, + { + "name": "update", + "method": "POST", + "title": "Update trigger", + "path": "/{triggerID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "triggerID", + "required": true, + "title": "Trigger ID" + } + ], + "post": [ + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Module ID" + }, + { + "type": "string", + "name": "name", + "required": true, + "title": "Name" + }, + { + "type": "[]string", + "name": "actions", + "required": false, + "title": "Actions that trigger this trigger" + }, + { + "type": "bool", + "name": "enabled", + "required": false, + "title": "Enabled" + }, + { + "type": "string", + "name": "source", + "required": false, + "title": "Trigger source code" + } + ] + } + }, + { + "name": "delete", + "path": "/{triggerID}", + "method": "Delete", + "title": "Delete trigger", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "triggerID", + "required": true, + "title": "Trigger ID" + } + ] + } + } + ] + }, + { + "title": "Notifications", + "description": "CRM Notifications", + "entrypoint": "notification", + "path": "/notification", + "authentication": [], + "struct": [ + { + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types" + ] + } + ], + "apis": [ + { + "name": "email/send", + "method": "POST", + "title": "Send email from the CRM", + "path": "/email", + "parameters": { + "post": [ + { + "name": "to", + "type": "[]string", + "required": true, + "title": "Email addresses or Crust user IDs" + }, + { + "name": "cc", + "type": "[]string", + "required": false, + "title": "Email addresses or Crust user IDs" + }, + { + "name": "replyTo", + "type": "string", + "required": false, + "title": "Crust user ID or email address in reply-to field" + }, + { + "name": "subject ", + "type": "string", + "required": false, + "title": "Email subject" + }, + { + "name": "content", + "type": "sqlxTypes.JSONText", + "required": true, + "title": "Message content" + } + ] + } + } + ] + }, + { + "title": "Attachments", + "path": "/attachment/{kind}", + "entrypoint": "attachment", + "authentication": [ + "Client ID", + "Session ID" + ], "parameters": { - "path": [ + "path": [ + { + "name": "kind", + "type": "string", + "required": true, + "title": "Attachment kind" + } + ] + }, + "apis": [ { - "name": "attachmentID", - "type": "uint64", - "required": true, - "title": "Attachment ID" - } - ] - } - }, - { - "name": "original", - "path": "/{attachmentID}/original/{name}", - "method": "GET", - "title": "Serves attached file", - "parameters": { - "path": [ - { - "name": "attachmentID", - "type": "uint64", - "required": true, - "title": "Attachment ID" + "name": "list", + "path": "/", + "method": "GET", + "title": "List, filter all page attachments", + "parameters": { + "get": [ + { + "name": "pageID", + "type": "uint64", + "required": false, + "title": "Filter attachments by page ID" + }, + { + "type": "uint64", + "name": "moduleID", + "required": false, + "title": "Filter attachments by mnodule ID" + }, + { + "name": "recordID", + "type": "uint64", + "required": false, + "title": "Filter attachments by record ID" + }, + { + "name": "fieldName", + "type": "string", + "required": false, + "title": "Filter attachments by field name" + }, + { + "name": "page", + "type": "uint", + "required": false, + "title": "Page number (0 based)" + }, + { + "name": "perPage", + "type": "uint", + "required": false, + "title": "Returned items per page (default 50)" + } + ] + } }, { - "name": "name", - "type": "string", - "required": true, - "title": "File name" - } - ], - "get": [ - { - "type": "bool", - "name": "download", - "required": false, - "title": "Force file download" - } - ] - } - }, - { - "name": "preview", - "path": "/{attachmentID}/preview.{ext}", - "method": "GET", - "title": "Serves preview of an attached file", - "parameters": { - "path": [ - { - "name": "attachmentID", - "type": "uint64", - "required": true, - "title": "Attachment ID" + "name": "details", + "path": "/{attachmentID}", + "method": "GET", + "title": "Attachment details", + "parameters": { + "path": [ + { + "name": "attachmentID", + "type": "uint64", + "required": true, + "title": "Attachment ID" + } + ] + } }, { - "name": "ext", - "type": "string", - "required": true, - "title": "Preview extension/format" + "name": "original", + "path": "/{attachmentID}/original/{name}", + "method": "GET", + "title": "Serves attached file", + "parameters": { + "path": [ + { + "name": "attachmentID", + "type": "uint64", + "required": true, + "title": "Attachment ID" + }, + { + "name": "name", + "type": "string", + "required": true, + "title": "File name" + } + ], + "get": [ + { + "type": "bool", + "name": "download", + "required": false, + "title": "Force file download" + } + ] + } + }, + { + "name": "preview", + "path": "/{attachmentID}/preview.{ext}", + "method": "GET", + "title": "Serves preview of an attached file", + "parameters": { + "path": [ + { + "name": "attachmentID", + "type": "uint64", + "required": true, + "title": "Attachment ID" + }, + { + "name": "ext", + "type": "string", + "required": true, + "title": "Preview extension/format" + } + ] + } } - ] - } - } - ] - } -] + ] + } +] \ No newline at end of file diff --git a/api/messaging/spec.json b/api/messaging/spec.json index ac1738445..aa48398df 100644 --- a/api/messaging/spec.json +++ b/api/messaging/spec.json @@ -1,708 +1,707 @@ [ - { - "title": "Permissions", - "parameters": {}, - "entrypoint": "permissions", - "path": "/permissions", - "authentication": [], - "apis": [ - { - "name": "effective", - "path": "/effective", - "method": "GET", - "title": "Effective rules for current user", - "parameters": { - "get": [ + { + "title": "Permissions", + "parameters": {}, + "entrypoint": "permissions", + "path": "/permissions", + "authentication": [], + "apis": [ { - "name": "resource", - "type": "string", - "required": false, - "title": "Show only rules for a specific resource" + "name": "effective", + "path": "/effective", + "method": "GET", + "title": "Effective rules for current user", + "parameters": { + "get": [ + { + "name": "resource", + "type": "string", + "required": false, + "title": "Show only rules for a specific resource" + } + ] + } } - ] - } - } - ] - }, - { - "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.", - "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": "setFlag", - "method": "PUT", - "path": "/{channelID}/flag", - "title": "Update channel membership flag", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "channelID", - "required": true, - "title": "Channel ID" - } - ], - "post": [ - { - "type": "string", - "name": "flag", - "required": true, - "title": "Valid values: pinned, hidden, ignored" - } - ] - } - }, - { - "name": "removeFlag", - "method": "DELETE", - "path": "/{channelID}/flag", - "title": "Remove channel membership flag", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "channelID", - "required": true, - "title": "Channel ID" - } - ] - } - }, - { - "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", - "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": [ + { + "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.", + "entrypoint": "channel", + "path": "/channels", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ { - "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": "markAsRead", - "path": "/mark-as-read", - "method": "GET", - "title": "Manages read/unread messages in a channel or a thread", - "parameters": { - "path": [ - ], - "post": [ - { - "type": "uint64", - "name": "threadID", - "required": false, - "title": "ID of thread (messageID) " + "name": "list", + "method": "GET", + "title": "List channels", + "path": "/", + "parameters": { + "GET": [ + { + "type": "string", + "name": "query", + "required": false, + "title": "Search query" + } + ] + } }, { - "type": "uint64", - "name": "lastReadMessageID", - "required": false, - "title": "ID of the last read message" - } - ] - } - }, - { - "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": "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": "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": "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": "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": "reaction", - "type": "string", - "required": true, - "title": "Reaction" + "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": "setFlag", + "method": "PUT", + "path": "/{channelID}/flag", + "title": "Update channel membership flag", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "channelID", + "required": true, + "title": "Channel ID" + } + ], + "post": [ + { + "type": "string", + "name": "flag", + "required": true, + "title": "Valid values: pinned, hidden, ignored" + } + ] + } + }, + { + "name": "removeFlag", + "method": "DELETE", + "path": "/{channelID}/flag", + "title": "Remove channel membership flag", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "channelID", + "required": true, + "title": "Channel ID" + } + ] + } + }, + { + "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": "Attachments", - "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", + { + "title": "Messages", + "path": "/channels/{channelID}/messages", "parameters": { - "path": [ + "path": [ + { + "name": "channelID", + "type": "uint64", + "required": true, + "title": "Channel ID" + } + ] + }, + "entrypoint": "message", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ { - "name": "name", - "type": "string", - "required": true, - "title": "File name" - } - ], - "get": [ + "name": "create", + "path": "/", + "method": "POST", + "title": "Post new message to the channel", + "parameters": { + "post": [ + { + "type": "string", + "name": "message", + "required": true, + "title": "Message contents (markdown)" + } + ] + } + }, { - "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": "history", + "path": "/", + "method": "GET", + "title": "All messages (channel history)", + "parameters": { + "get": [ + { + "name": "lastMessageID", + "type": "uint64", + "required": false, + "title": "" + } + ] + } + }, { - "name": "ext", - "type": "string", - "required": true, - "title": "Preview extension/format" + "name": "markAsRead", + "path": "/mark-as-read", + "method": "GET", + "title": "Manages read/unread messages in a channel or a thread", + "parameters": { + "path": [], + "post": [ + { + "type": "uint64", + "name": "threadID", + "required": false, + "title": "ID of thread (messageID) " + }, + { + "type": "uint64", + "name": "lastReadMessageID", + "required": false, + "title": "ID of the last read message" + } + ] + } + }, + { + "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": "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" + } + ] + } } - ] - } - } - ] - }, - { - "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", + { + "title": "Attachments", + "path": "/attachment/{attachmentID}", "parameters": { - "GET": [ + "path": [ + { + "name": "attachmentID", + "type": "uint64", + "required": true, + "title": "Attachment ID" + } + ] + }, + "entrypoint": "attachment", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ { - "name": "inChannel", - "type": "uint64", - "required": false, - "title": "Search only in one channel" + "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": "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)" + "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)" + } + ] + } + } + ] + } +] \ No newline at end of file diff --git a/api/system/spec.json b/api/system/spec.json index 5b541f09d..9a50e7635 100644 --- a/api/system/spec.json +++ b/api/system/spec.json @@ -1,764 +1,804 @@ [ - { - "title": "Authentication", - "path": "/auth", - "entrypoint": "auth", - "authentication": [], - "apis": [ - { - "name": "check", - "method": "GET", - "title": "Check JWT token", - "path": "/check", - "parameters": {} - }, - { - "name": "login", - "method": "POST", - "title": "Login user", - "path": "/login", - "parameters": { - "post": [ + { + "title": "Authentication", + "path": "/auth", + "entrypoint": "auth", + "authentication": [], + "apis": [ { - "name": "username", - "type": "string", - "required": true, - "title": "Username" + "name": "check", + "method": "GET", + "title": "Check JWT token", + "path": "/check", + "parameters": {} }, { - "name": "password", - "type": "string", - "required": true, - "title": "Password" - } - ] - } - }, - { - "name": "logout", - "method": "GET", - "title": "Delete JWT token (Sign Out)", - "path": "/logout", - "parameters": {} - } - ] - }, - { - "title": "Organisations", - "description": "Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.", - "path": "/organisations", - "entrypoint": "organisation", - "authentication": [ - "Client ID", - "Session ID" - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "List organisations", - "path": "/", - "parameters": { - "get": [ - { - "type": "string", - "name": "query", - "required": false, - "title": "Search query" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create organisation", - "path": "/", - "parameters": { - "post": [ - { - "type": "string", - "name": "name", - "required": true, - "title": "Organisation Name" - } - ] - } - }, - { - "name": "update", - "method": "PUT", - "title": "Update organisation details", - "path": "/{id}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "id", - "required": false, - "title": "Organisation ID" - } - ], - "post": [ - { - "type": "string", - "name": "name", - "required": true, - "title": "Organisation Name" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Remove organisation", - "path": "/{id}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "id", - "required": true, - "title": "Organisation ID" - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read organisation details", - "path": "/{id}", - "parameters": { - "get": [ - { - "type": "uint64", - "name": "id", - "required": true, - "title": "Organisation ID" - } - ] - } - }, - { - "name": "archive", - "method": "POST", - "title": "Archive organisation", - "path": "/{id}/archive", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "id", - "required": true, - "title": "Organisation ID" - } - ] - } - } - ] - }, - { - "title": "Roles", - "description": "An organisation may have many roles. Roles may have many channels available. Access to channels may be shared between roles.", - "path": "/roles", - "entrypoint": "role", - "authentication": [ - "Client ID", - "Session ID" - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "List roles", - "path": "/", - "parameters": { - "get": [ - { - "type": "string", - "name": "query", - "required": false, - "title": "Search query" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Update role details", - "path": "/", - "parameters": { - "post": [ - { - "type": "string", - "name": "name", - "required": true, - "title": "Name of Role" + "name": "login", + "method": "POST", + "title": "Login user", + "path": "/login", + "parameters": { + "post": [ + { + "name": "username", + "type": "string", + "required": true, + "title": "Username" + }, + { + "name": "password", + "type": "string", + "required": true, + "title": "Password" + } + ] + } }, { - "type": "[]string", - "name": "members", - "required": false, - "title": "Role member IDs" + "name": "logout", + "method": "GET", + "title": "Delete JWT token (Sign Out)", + "path": "/logout", + "parameters": {} } - ] - } - }, - { - "name": "update", - "method": "PUT", - "title": "Update role details", - "path": "/{roleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Role ID" - } - ], - "post": [ - { - "type": "string", - "name": "name", - "required": false, - "title": "Name of Role" - }, - { - "type": "[]string", - "name": "members", - "required": false, - "title": "Role member IDs" - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read role details and memberships", - "path": "/{roleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Remove role", - "path": "/{roleID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "archive", - "method": "POST", - "title": "Archive role", - "path": "/{roleID}/archive", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "move", - "method": "POST", - "title": "Move role to different organisation", - "path": "/{roleID}/move", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Role ID" - } - ], - "post": [ - { - "type": "uint64", - "name": "organisationID", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "merge", - "method": "POST", - "title": "Merge one role into another", - "path": "/{roleID}/merge", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Source Role ID" - } - ], - "post": [ - { - "type": "uint64", - "name": "destination", - "required": true, - "title": "Destination Role ID" - } - ] - } - }, - { - "name": "memberList", - "method": "GET", - "title": "Returns all role members", - "path": "/{roleID}/members", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Source Role ID" - } - ] - } - }, - { - "name": "memberAdd", - "method": "POST", - "title": "Add member to a role", - "path": "/{roleID}/member/{userID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Source Role ID" - }, - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - }, - { - "name": "memberRemove", - "method": "DELETE", - "title": "Remove member from a role", - "path": "/{roleID}/member/{userID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "roleID", - "required": true, - "title": "Source Role ID" - }, - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - } - ] - }, - { - "title": "Users", - "path": "/users", - "entrypoint": "user", - "authentication": [ - "Client ID", - "Session ID" - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "Search users (Directory)", - "path": "/", - "parameters": { - "get": [ - { - "type": "string", - "name": "query", - "required": false, - "title": "Search query to match against users" - }, - { - "type": "string", - "name": "username", - "required": false, - "title": "Search username to match against users" - }, - { - "type": "string", - "name": "email", - "required": false, - "title": "Search email to match against users" - } - ] - } - }, - { - "name": "create", - "method": "POST", - "title": "Create user", - "path": "/", - "parameters": { - "post": [ - { - "name": "email", - "type": "string", - "required": true, - "title": "Email" - }, - { - "name": "name", - "type": "string", - "required": false, - "title": "Name" - }, - { - "name": "handle", - "type": "string", - "required": false, - "title": "Handle" - }, - { - "name": "kind", - "type": "string", - "required": false, - "title": "Kind (normal, bot)" - } - ] - } - }, - { - "name": "update", - "method": "PUT", - "title": "Update user details", - "path": "/{userID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ], - "post": [ - { - "name": "email", - "type": "string", - "required": true, - "title": "Email" - }, - { - "name": "name", - "type": "string", - "required": true, - "title": "Name" - }, - { - "name": "handle", - "type": "string", - "required": false, - "title": "Handle" - }, - { - "name": "kind", - "type": "string", - "required": false, - "title": "Kind (normal, bot)" - } - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read user details and memberships", - "path": "/{userID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Remove user", - "path": "/{userID}", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - }, - { - "name": "suspend", - "method": "POST", - "title": "Suspend user", - "path": "/{userID}/suspend", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - }, - { - "name": "unsuspend", - "method": "POST", - "title": "Unsuspend user", - "path": "/{userID}/unsuspend", - "parameters": { - "path": [ - { - "type": "uint64", - "name": "userID", - "required": true, - "title": "User ID" - } - ] - } - } - ] - }, - { - "title": "Applications", - "path": "/application", - "entrypoint": "application", - "authentication": [], - "struct": [ - { - "imports": [ - "sqlxTypes github.com/jmoiron/sqlx/types" ] - } - ], - "apis": [ - { - "name": "list", - "method": "GET", - "title": "List applications", - "path": "/" - }, - { - "name": "create", - "method": "POST", - "title": "Create application", - "path": "/", - "parameters": { - "post": [ - { "name": "name", "type": "string", "required": true, "title": "Email"}, - { "name": "enabled", "type": "bool", "required": false, "title": "Enabled"}, - { "name": "unify", "type": "sqlxTypes.JSONText", "required": false, "title": "Unify properties"}, - { "name": "config", "type": "sqlxTypes.JSONText", "required": false, "title": "Arbitrary JSON holding application configuration"} - ] - } - }, - { - "name": "update", - "method": "PUT", - "title": "Update user details", - "path": "/{applicationID}", - "parameters": { - "path": [ + }, + { + "title": "Organisations", + "description": "Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.", + "path": "/organisations", + "entrypoint": "organisation", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ { - "type": "uint64", - "name": "applicationID", - "required": true, - "title": "Application ID" - } - ], - "post": [ - { "name": "name", "type": "string", "required": true, "title": "Email"}, - { "name": "enabled", "type": "bool", "required": false, "title": "Enabled"}, - { "name": "unify", "type": "sqlxTypes.JSONText", "required": false, "title": "Unify properties"}, - { "name": "config", "type": "sqlxTypes.JSONText", "required": false, "title": "Arbitrary JSON holding application configuration"} - ] - } - }, - { - "name": "read", - "method": "GET", - "title": "Read application details", - "path": "/{applicationID}", - "parameters": { - "path": [ + "name": "list", + "method": "GET", + "title": "List organisations", + "path": "/", + "parameters": { + "get": [ + { + "type": "string", + "name": "query", + "required": false, + "title": "Search query" + } + ] + } + }, { - "type": "uint64", - "name": "applicationID", - "required": true, - "title": "Application ID" - } - ] - } - }, - { - "name": "delete", - "method": "DELETE", - "title": "Remove application", - "path": "/{applicationID}", - "parameters": { - "path": [ + "name": "create", + "method": "POST", + "title": "Create organisation", + "path": "/", + "parameters": { + "post": [ + { + "type": "string", + "name": "name", + "required": true, + "title": "Organisation Name" + } + ] + } + }, { - "type": "uint64", - "name": "applicationID", - "required": true, - "title": "Application ID" + "name": "update", + "method": "PUT", + "title": "Update organisation details", + "path": "/{id}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "id", + "required": false, + "title": "Organisation ID" + } + ], + "post": [ + { + "type": "string", + "name": "name", + "required": true, + "title": "Organisation Name" + } + ] + } + }, + { + "name": "delete", + "method": "DELETE", + "title": "Remove organisation", + "path": "/{id}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "id", + "required": true, + "title": "Organisation ID" + } + ] + } + }, + { + "name": "read", + "method": "GET", + "title": "Read organisation details", + "path": "/{id}", + "parameters": { + "get": [ + { + "type": "uint64", + "name": "id", + "required": true, + "title": "Organisation ID" + } + ] + } + }, + { + "name": "archive", + "method": "POST", + "title": "Archive organisation", + "path": "/{id}/archive", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "id", + "required": true, + "title": "Organisation ID" + } + ] + } } - ] - } - } - ] - }, - { - "title": "Permissions", - "parameters": {}, - "entrypoint": "permissions", - "path": "/permissions", - "authentication": [ - "Client ID", - "Session ID" - ], - "struct": [ - { - "imports": [ - "github.com/crusttech/crust/internal/rules" ] - } - ], - "apis": [ - { - "name": "list", - "path": "/", - "method": "GET", - "title": "Retrieve defined permissions", - "parameters": {} - }, - { - "name": "effective", - "path": "/effective", - "method": "GET", - "title": "Effective rules for current user", - "parameters": { - "get": [ + }, + { + "title": "Roles", + "description": "An organisation may have many roles. Roles may have many channels available. Access to channels may be shared between roles.", + "path": "/roles", + "entrypoint": "role", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ { - "name": "resource", - "type": "string", - "required": false, - "title": "Show only rules for a specific resource" - } - ] - } - }, - { - "name": "read", - "path": "/{roleID}/rules", - "method": "GET", - "title": "Retrieve role permissions", - "parameters": { - "path": [ + "name": "list", + "method": "GET", + "title": "List roles", + "path": "/", + "parameters": { + "get": [ + { + "type": "string", + "name": "query", + "required": false, + "title": "Search query" + } + ] + } + }, { - "name": "roleID", - "type": "uint64", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "delete", - "path": "/{roleID}/rules", - "method": "DELETE", - "title": "Remove all defined role permissions", - "parameters": { - "path": [ + "name": "create", + "method": "POST", + "title": "Update role details", + "path": "/", + "parameters": { + "post": [ + { + "type": "string", + "name": "name", + "required": true, + "title": "Name of Role" + }, + { + "type": "[]string", + "name": "members", + "required": false, + "title": "Role member IDs" + } + ] + } + }, { - "name": "roleID", - "type": "uint64", - "required": true, - "title": "Role ID" - } - ] - } - }, - { - "name": "update", - "path": "/{roleID}/rules", - "method": "PATCH", - "title": "Update permission settings", - "parameters": { - "path": [ + "name": "update", + "method": "PUT", + "title": "Update role details", + "path": "/{roleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Role ID" + } + ], + "post": [ + { + "type": "string", + "name": "name", + "required": false, + "title": "Name of Role" + }, + { + "type": "[]string", + "name": "members", + "required": false, + "title": "Role member IDs" + } + ] + } + }, { - "name": "roleID", - "type": "uint64", - "required": true, - "title": "Role ID" - } - ], - "post": [ + "name": "read", + "method": "GET", + "title": "Read role details and memberships", + "path": "/{roleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Role ID" + } + ] + } + }, { - "name": "permissions", - "type": "[]rules.Rule", - "required": true, - "title": "List of permissions to set" + "name": "delete", + "method": "DELETE", + "title": "Remove role", + "path": "/{roleID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Role ID" + } + ] + } + }, + { + "name": "archive", + "method": "POST", + "title": "Archive role", + "path": "/{roleID}/archive", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Role ID" + } + ] + } + }, + { + "name": "move", + "method": "POST", + "title": "Move role to different organisation", + "path": "/{roleID}/move", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Role ID" + } + ], + "post": [ + { + "type": "uint64", + "name": "organisationID", + "required": true, + "title": "Role ID" + } + ] + } + }, + { + "name": "merge", + "method": "POST", + "title": "Merge one role into another", + "path": "/{roleID}/merge", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Source Role ID" + } + ], + "post": [ + { + "type": "uint64", + "name": "destination", + "required": true, + "title": "Destination Role ID" + } + ] + } + }, + { + "name": "memberList", + "method": "GET", + "title": "Returns all role members", + "path": "/{roleID}/members", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Source Role ID" + } + ] + } + }, + { + "name": "memberAdd", + "method": "POST", + "title": "Add member to a role", + "path": "/{roleID}/member/{userID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Source Role ID" + }, + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } + }, + { + "name": "memberRemove", + "method": "DELETE", + "title": "Remove member from a role", + "path": "/{roleID}/member/{userID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "roleID", + "required": true, + "title": "Source Role ID" + }, + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } } - ] - } - } - ] - } -] + ] + }, + { + "title": "Users", + "path": "/users", + "entrypoint": "user", + "authentication": [ + "Client ID", + "Session ID" + ], + "apis": [ + { + "name": "list", + "method": "GET", + "title": "Search users (Directory)", + "path": "/", + "parameters": { + "get": [ + { + "type": "string", + "name": "query", + "required": false, + "title": "Search query to match against users" + }, + { + "type": "string", + "name": "username", + "required": false, + "title": "Search username to match against users" + }, + { + "type": "string", + "name": "email", + "required": false, + "title": "Search email to match against users" + } + ] + } + }, + { + "name": "create", + "method": "POST", + "title": "Create user", + "path": "/", + "parameters": { + "post": [ + { + "name": "email", + "type": "string", + "required": true, + "title": "Email" + }, + { + "name": "name", + "type": "string", + "required": false, + "title": "Name" + }, + { + "name": "handle", + "type": "string", + "required": false, + "title": "Handle" + }, + { + "name": "kind", + "type": "string", + "required": false, + "title": "Kind (normal, bot)" + } + ] + } + }, + { + "name": "update", + "method": "PUT", + "title": "Update user details", + "path": "/{userID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ], + "post": [ + { + "name": "email", + "type": "string", + "required": true, + "title": "Email" + }, + { + "name": "name", + "type": "string", + "required": true, + "title": "Name" + }, + { + "name": "handle", + "type": "string", + "required": false, + "title": "Handle" + }, + { + "name": "kind", + "type": "string", + "required": false, + "title": "Kind (normal, bot)" + } + ] + } + }, + { + "name": "read", + "method": "GET", + "title": "Read user details and memberships", + "path": "/{userID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } + }, + { + "name": "delete", + "method": "DELETE", + "title": "Remove user", + "path": "/{userID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } + }, + { + "name": "suspend", + "method": "POST", + "title": "Suspend user", + "path": "/{userID}/suspend", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } + }, + { + "name": "unsuspend", + "method": "POST", + "title": "Unsuspend user", + "path": "/{userID}/unsuspend", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "userID", + "required": true, + "title": "User ID" + } + ] + } + } + ] + }, + { + "title": "Applications", + "path": "/application", + "entrypoint": "application", + "authentication": [], + "struct": [ + { + "imports": [ + "sqlxTypes github.com/jmoiron/sqlx/types" + ] + } + ], + "apis": [ + { + "name": "list", + "method": "GET", + "title": "List applications", + "path": "/" + }, + { + "name": "create", + "method": "POST", + "title": "Create application", + "path": "/", + "parameters": { + "post": [ + { + "name": "name", + "type": "string", + "required": true, + "title": "Email" + }, + { + "name": "enabled", + "type": "bool", + "required": false, + "title": "Enabled" + }, + { + "name": "unify", + "type": "sqlxTypes.JSONText", + "required": false, + "title": "Unify properties" + }, + { + "name": "config", + "type": "sqlxTypes.JSONText", + "required": false, + "title": "Arbitrary JSON holding application configuration" + } + ] + } + }, + { + "name": "update", + "method": "PUT", + "title": "Update user details", + "path": "/{applicationID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "applicationID", + "required": true, + "title": "Application ID" + } + ], + "post": [ + { + "name": "name", + "type": "string", + "required": true, + "title": "Email" + }, + { + "name": "enabled", + "type": "bool", + "required": false, + "title": "Enabled" + }, + { + "name": "unify", + "type": "sqlxTypes.JSONText", + "required": false, + "title": "Unify properties" + }, + { + "name": "config", + "type": "sqlxTypes.JSONText", + "required": false, + "title": "Arbitrary JSON holding application configuration" + } + ] + } + }, + { + "name": "read", + "method": "GET", + "title": "Read application details", + "path": "/{applicationID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "applicationID", + "required": true, + "title": "Application ID" + } + ] + } + }, + { + "name": "delete", + "method": "DELETE", + "title": "Remove application", + "path": "/{applicationID}", + "parameters": { + "path": [ + { + "type": "uint64", + "name": "applicationID", + "required": true, + "title": "Application ID" + } + ] + } + } + ] + }, + { + "title": "Permissions", + "parameters": {}, + "entrypoint": "permissions", + "path": "/permissions", + "authentication": [ + "Client ID", + "Session ID" + ], + "struct": [ + { + "imports": [ + "github.com/crusttech/crust/internal/rules" + ] + } + ], + "apis": [ + { + "name": "list", + "path": "/", + "method": "GET", + "title": "Retrieve defined permissions", + "parameters": {} + }, + { + "name": "effective", + "path": "/effective", + "method": "GET", + "title": "Effective rules for current user", + "parameters": { + "get": [ + { + "name": "resource", + "type": "string", + "required": false, + "title": "Show only rules for a specific resource" + } + ] + } + }, + { + "name": "read", + "path": "/{roleID}/rules", + "method": "GET", + "title": "Retrieve role permissions", + "parameters": { + "path": [ + { + "name": "roleID", + "type": "uint64", + "required": true, + "title": "Role ID" + } + ] + } + }, + { + "name": "delete", + "path": "/{roleID}/rules", + "method": "DELETE", + "title": "Remove all defined role permissions", + "parameters": { + "path": [ + { + "name": "roleID", + "type": "uint64", + "required": true, + "title": "Role ID" + } + ] + } + }, + { + "name": "update", + "path": "/{roleID}/rules", + "method": "PATCH", + "title": "Update permission settings", + "parameters": { + "path": [ + { + "name": "roleID", + "type": "uint64", + "required": true, + "title": "Role ID" + } + ], + "post": [ + { + "name": "permissions", + "type": "[]rules.Rule", + "required": true, + "title": "List of permissions to set" + } + ] + } + } + ] + } +] \ No newline at end of file