upd(all): codegen update handlers/request pkgs

This commit is contained in:
Tit Petric
2019-04-03 14:45:38 +02:00
parent a1aadeaa2f
commit e27720dc93
41 changed files with 397 additions and 200 deletions
+6 -7
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -77,11 +78,9 @@ func NewAttachment(ah AttachmentAPI) *Attachment {
func (ah *Attachment) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/attachment/{kind}", func(r chi.Router) {
r.Get("/", ah.List)
r.Get("/{attachmentID}", ah.Details)
r.Get("/{attachmentID}/original/{name}", ah.Original)
r.Get("/{attachmentID}/preview.{ext}", ah.Preview)
})
r.Get("/attachment/{kind}/", ah.List)
r.Get("/attachment/{kind}/{attachmentID}", ah.Details)
r.Get("/attachment/{kind}/{attachmentID}/original/{name}", ah.Original)
r.Get("/attachment/{kind}/{attachmentID}/preview.{ext}", ah.Preview)
})
}
+7 -8
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -86,12 +87,10 @@ func NewChart(ch ChartAPI) *Chart {
func (ch *Chart) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/chart", func(r chi.Router) {
r.Get("/", ch.List)
r.Post("/", ch.Create)
r.Get("/{chartID}", ch.Read)
r.Post("/{chartID}", ch.Update)
r.Delete("/{chartID}", ch.Delete)
})
r.Get("/chart/", ch.List)
r.Post("/chart/", ch.Create)
r.Get("/chart/{chartID}", ch.Read)
r.Post("/chart/{chartID}", ch.Update)
r.Delete("/chart/{chartID}", ch.Delete)
})
}
+7 -8
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -86,12 +87,10 @@ func NewModule(mh ModuleAPI) *Module {
func (mh *Module) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/module", func(r chi.Router) {
r.Get("/", mh.List)
r.Post("/", mh.Create)
r.Get("/{moduleID}", mh.Read)
r.Post("/{moduleID}", mh.Update)
r.Delete("/{moduleID}", mh.Delete)
})
r.Get("/module/", mh.List)
r.Post("/module/", mh.Create)
r.Get("/module/{moduleID}", mh.Read)
r.Post("/module/{moduleID}", mh.Update)
r.Delete("/module/{moduleID}", mh.Delete)
})
}
+3 -4
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -50,8 +51,6 @@ func NewNotification(nh NotificationAPI) *Notification {
func (nh *Notification) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/notification", func(r chi.Router) {
r.Post("/email", nh.EmailSend)
})
r.Post("/notification/email", nh.EmailSend)
})
}
+10 -11
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -113,15 +114,13 @@ func NewPage(ph PageAPI) *Page {
func (ph *Page) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/page", func(r chi.Router) {
r.Get("/", ph.List)
r.Post("/", ph.Create)
r.Get("/{pageID}", ph.Read)
r.Get("/tree", ph.Tree)
r.Post("/{pageID}", ph.Update)
r.Post("/{selfID}/reorder", ph.Reorder)
r.Delete("/{pageID}", ph.Delete)
r.Post("/{pageID}/attachment", ph.Upload)
})
r.Get("/page/", ph.List)
r.Post("/page/", ph.Create)
r.Get("/page/{pageID}", ph.Read)
r.Get("/page/tree", ph.Tree)
r.Post("/page/{pageID}", ph.Update)
r.Post("/page/{selfID}/reorder", ph.Reorder)
r.Delete("/page/{pageID}", ph.Delete)
r.Post("/page/{pageID}/attachment", ph.Upload)
})
}
+3 -4
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -50,8 +51,6 @@ func NewPermissions(ph PermissionsAPI) *Permissions {
func (ph *Permissions) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/permissions", func(r chi.Router) {
r.Get("/effective", ph.Effective)
})
r.Get("/permissions/effective", ph.Effective)
})
}
+9 -10
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -104,14 +105,12 @@ func NewRecord(rh RecordAPI) *Record {
func (rh *Record) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/module/{moduleID}/record", func(r chi.Router) {
r.Get("/report", rh.Report)
r.Get("/", rh.List)
r.Post("/", rh.Create)
r.Get("/{recordID}", rh.Read)
r.Post("/{recordID}", rh.Update)
r.Delete("/{recordID}", rh.Delete)
r.Post("/{recordID}/{fieldName}/attachment", rh.Upload)
})
r.Get("/module/{moduleID}/record/report", rh.Report)
r.Get("/module/{moduleID}/record/", rh.List)
r.Post("/module/{moduleID}/record/", rh.Create)
r.Get("/module/{moduleID}/record/{recordID}", rh.Read)
r.Post("/module/{moduleID}/record/{recordID}", rh.Update)
r.Delete("/module/{moduleID}/record/{recordID}", rh.Delete)
r.Post("/module/{moduleID}/record/{recordID}/{fieldName}/attachment", rh.Upload)
})
}
+7 -8
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/crm/rest/request"
@@ -86,12 +87,10 @@ func NewTrigger(th TriggerAPI) *Trigger {
func (th *Trigger) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/trigger", func(r chi.Router) {
r.Get("/", th.List)
r.Post("/", th.Create)
r.Get("/{triggerID}", th.Read)
r.Post("/{triggerID}", th.Update)
r.Delete("/{triggerID}", th.Delete)
})
r.Get("/trigger/", th.List)
r.Post("/trigger/", th.Create)
r.Get("/trigger/{triggerID}", th.Read)
r.Post("/trigger/{triggerID}", th.Update)
r.Delete("/trigger/{triggerID}", th.Delete)
})
}
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+77 -1
View File
@@ -1,5 +1,12 @@
# Attachments
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/attachment/{kind}/` | List, filter all page attachments |
| `GET` | `/attachment/{kind}/{attachmentID}` | Attachment details |
| `GET` | `/attachment/{kind}/{attachmentID}/original/{name}` | Serves attached file |
| `GET` | `/attachment/{kind}/{attachmentID}/preview.{ext}` | Serves preview of an attached file |
## List, filter all page attachments
#### Method
@@ -68,11 +75,21 @@
| ext | string | PATH | Preview extension/format | N/A | YES |
| kind | string | PATH | Attachment kind | N/A | YES |
---
# Charts
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/chart/` | List/read charts from module section |
| `POST` | `/chart/` | List/read charts from module section |
| `GET` | `/chart/{chartID}` | Read charts by ID from module section |
| `POST` | `/chart/{chartID}` | Add/update charts in module section |
| `DELETE` | `/chart/{chartID}` | Delete chart |
## List/read charts from module section
#### Method
@@ -145,6 +162,8 @@
| --------- | ---- | ------ | ----------- | ------- | --------- |
| chartID | uint64 | PATH | Chart ID | N/A | YES |
---
@@ -152,6 +171,14 @@
CRM module definitions
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/module/` | List modules |
| `POST` | `/module/` | Create module |
| `GET` | `/module/{moduleID}` | Read module |
| `POST` | `/module/{moduleID}` | Update module |
| `DELETE` | `/module/{moduleID}` | Delete module |
## List modules
#### Method
@@ -227,6 +254,8 @@ CRM module definitions
| --------- | ---- | ------ | ----------- | ------- | --------- |
| moduleID | uint64 | PATH | Module ID | N/A | YES |
---
@@ -234,6 +263,10 @@ CRM module definitions
CRM Notifications
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `POST` | `/notification/email` | Send email from the CRM |
## Send email from the CRM
#### Method
@@ -252,6 +285,8 @@ CRM Notifications
| subject | string | POST | Email subject | N/A | NO |
| content | sqlxTypes.JSONText | POST | Message content | N/A | YES |
---
@@ -259,6 +294,17 @@ CRM Notifications
CRM module pages
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/page/` | List available pages |
| `POST` | `/page/` | Create page |
| `GET` | `/page/{pageID}` | Get page details |
| `GET` | `/page/tree` | Get page all (non-record) pages, hierarchically |
| `POST` | `/page/{pageID}` | Update page |
| `POST` | `/page/{selfID}/reorder` | Reorder pages |
| `Delete` | `/page/{pageID}` | Delete page |
| `POST` | `/page/{pageID}/attachment` | Uploads attachment to page |
## List available pages
#### Method
@@ -383,11 +429,17 @@ CRM module pages
| pageID | uint64 | PATH | Page ID | N/A | YES |
| upload | *multipart.FileHeader | POST | File to upload | N/A | YES |
---
# Permissions
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/permissions/effective` | Effective rules for current user |
## Effective rules for current user
#### Method
@@ -402,6 +454,8 @@ CRM module pages
| --------- | ---- | ------ | ----------- | ------- | --------- |
| resource | string | GET | Show only rules for a specific resource | N/A | NO |
---
@@ -409,6 +463,16 @@ CRM module pages
CRM records
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/module/{moduleID}/record/report` | Generates report from module records |
| `GET` | `/module/{moduleID}/record/` | List/read records from module section |
| `POST` | `/module/{moduleID}/record/` | Create record in module section |
| `GET` | `/module/{moduleID}/record/{recordID}` | Read records by ID from module section |
| `POST` | `/module/{moduleID}/record/{recordID}` | Update records in module section |
| `DELETE` | `/module/{moduleID}/record/{recordID}` | Delete record row from module section |
| `POST` | `/module/{moduleID}/record/{recordID}/{fieldName}/attachment` | Uploads attachment and validates it against record field requirements |
## Generates report from module records
#### Method
@@ -522,6 +586,8 @@ CRM records
| moduleID | uint64 | PATH | Module ID | N/A | YES |
| upload | *multipart.FileHeader | POST | File to upload | N/A | YES |
---
@@ -529,6 +595,14 @@ CRM records
CRM Triggers
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/trigger/` | List available triggers |
| `POST` | `/trigger/` | Create trigger |
| `GET` | `/trigger/{triggerID}` | Get trigger details |
| `POST` | `/trigger/{triggerID}` | Update trigger |
| `Delete` | `/trigger/{triggerID}` | Delete trigger |
## List available triggers
#### Method
@@ -606,4 +680,6 @@ CRM Triggers
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| triggerID | uint64 | PATH | Trigger ID | N/A | YES |
| triggerID | uint64 | PATH | Trigger ID | N/A | YES |
---
+55 -1
View File
@@ -1,5 +1,10 @@
# Attachments
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/attachment/{attachmentID}/original/{name}` | Serves attached file |
| `GET` | `/attachment/{attachmentID}/preview.{ext}` | Serves preview of an attached file |
## Serves attached file
#### Method
@@ -31,6 +36,8 @@
| ext | string | PATH | Preview extension/format | N/A | YES |
| attachmentID | uint64 | PATH | Attachment ID | N/A | YES |
---
@@ -38,6 +45,21 @@
A channel is a representation of a sequence of messages. It has meta data like channel subject. Channels may be public, private or group.
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/channels/` | List channels |
| `POST` | `/channels/` | Create new channel |
| `PUT` | `/channels/{channelID}` | Update channel details |
| `PUT` | `/channels/{channelID}/state` | Update channel state |
| `PUT` | `/channels/{channelID}/flag` | Update channel membership flag |
| `DELETE` | `/channels/{channelID}/flag` | Remove channel membership flag |
| `GET` | `/channels/{channelID}` | Read channel details |
| `GET` | `/channels/{channelID}/members` | List channel members |
| `PUT` | `/channels/{channelID}/members/{userID}` | Join channel |
| `DELETE` | `/channels/{channelID}/members/{userID}` | Remove member from channel |
| `POST` | `/channels/{channelID}/invite` | Join channel |
| `POST` | `/channels/{channelID}/attach` | Attach file to channel |
## List channels
#### Method
@@ -220,6 +242,8 @@ A channel is a representation of a sequence of messages. It has meta data like c
| replyTo | uint64 | POST | Upload as a reply | N/A | NO |
| upload | *multipart.FileHeader | POST | File to upload | N/A | YES |
---
@@ -245,6 +269,22 @@ The following event types may be sent with a message event:
| EDITED | A message has been edited by the sender |
| REMOVED | A message has been removed by the sender |
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `POST` | `/channels/{channelID}/messages/` | Post new message to the channel |
| `GET` | `/channels/{channelID}/messages/` | All messages (channel history) |
| `GET` | `/channels/{channelID}/messages/mark-as-read` | Manages read/unread messages in a channel or a thread |
| `PUT` | `/channels/{channelID}/messages/{messageID}` | Edit existing message |
| `DELETE` | `/channels/{channelID}/messages/{messageID}` | Delete existing message |
| `GET` | `/channels/{channelID}/messages/{messageID}/replies` | Returns all replies to a message |
| `POST` | `/channels/{channelID}/messages/{messageID}/replies` | Reply to a message |
| `POST` | `/channels/{channelID}/messages/{messageID}/pin` | Pin message to channel (public bookmark) |
| `DELETE` | `/channels/{channelID}/messages/{messageID}/pin` | Pin message to channel (public bookmark) |
| `POST` | `/channels/{channelID}/messages/{messageID}/bookmark` | Bookmark a message (private bookmark) |
| `DELETE` | `/channels/{channelID}/messages/{messageID}/bookmark` | Remove boomark from message (private bookmark) |
| `POST` | `/channels/{channelID}/messages/{messageID}/reaction/{reaction}` | React to a message |
| `DELETE` | `/channels/{channelID}/messages/{messageID}/reaction/{reaction}` | Delete reaction from a message |
## Post new message to the channel
#### Method
@@ -445,11 +485,17 @@ The following event types may be sent with a message event:
| reaction | string | PATH | Reaction | N/A | YES |
| channelID | uint64 | PATH | Channel ID | N/A | YES |
---
# Permissions
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/permissions/effective` | Effective rules for current user |
## Effective rules for current user
#### Method
@@ -464,11 +510,17 @@ The following event types may be sent with a message event:
| --------- | ---- | ------ | ----------- | ------- | --------- |
| resource | string | GET | Show only rules for a specific resource | N/A | NO |
---
# Search entry point
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/search/messages` | Search for messages |
## Search for messages
#### Method
@@ -485,4 +537,6 @@ The following event types may be sent with a message event:
| fromUser | uint64 | GET | Search only from one user | N/A | NO |
| firstID | uint64 | GET | Paging; return newer messages only (higher id) | N/A | NO |
| lastID | uint64 | GET | Paging; return older messages only (lower id) | N/A | NO |
| query | string | GET | Search query | N/A | NO |
| query | string | GET | Search query | N/A | NO |
---
+68 -1
View File
@@ -1,5 +1,13 @@
# Applications
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/application/` | List applications |
| `POST` | `/application/` | Create application |
| `PUT` | `/application/{applicationID}` | Update user details |
| `GET` | `/application/{applicationID}` | Read application details |
| `DELETE` | `/application/{applicationID}` | Remove application |
## List applications
#### Method
@@ -76,11 +84,19 @@
| --------- | ---- | ------ | ----------- | ------- | --------- |
| applicationID | uint64 | PATH | Application ID | N/A | YES |
---
# Authentication
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/auth/check` | Check JWT token |
| `POST` | `/auth/login` | Login user |
| `GET` | `/auth/logout` | Delete JWT token (Sign Out) |
## Check JWT token
#### Method
@@ -122,6 +138,8 @@
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
---
@@ -129,6 +147,15 @@
Organisations represent a top-level grouping entity. There may be many organisations defined in a single deployment.
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/organisations/` | List organisations |
| `POST` | `/organisations/` | Create organisation |
| `PUT` | `/organisations/{id}` | Update organisation details |
| `DELETE` | `/organisations/{id}` | Remove organisation |
| `GET` | `/organisations/{id}` | Read organisation details |
| `POST` | `/organisations/{id}/archive` | Archive organisation |
## List organisations
#### Method
@@ -214,11 +241,21 @@ Organisations represent a top-level grouping entity. There may be many organisat
| --------- | ---- | ------ | ----------- | ------- | --------- |
| id | uint64 | PATH | Organisation ID | N/A | YES |
---
# Permissions
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/permissions/` | Retrieve defined permissions |
| `GET` | `/permissions/effective` | Effective rules for current user |
| `GET` | `/permissions/{roleID}/rules` | Retrieve role permissions |
| `DELETE` | `/permissions/{roleID}/rules` | Remove all defined role permissions |
| `PATCH` | `/permissions/{roleID}/rules` | Update permission settings |
## Retrieve defined permissions
#### Method
@@ -289,6 +326,8 @@ Organisations represent a top-level grouping entity. There may be many organisat
| roleID | uint64 | PATH | Role ID | N/A | YES |
| permissions | []rules.Rule | POST | List of permissions to set | N/A | YES |
---
@@ -296,6 +335,20 @@ Organisations represent a top-level grouping entity. There may be many organisat
An organisation may have many roles. Roles may have many channels available. Access to channels may be shared between roles.
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/roles/` | List roles |
| `POST` | `/roles/` | Update role details |
| `PUT` | `/roles/{roleID}` | Update role details |
| `GET` | `/roles/{roleID}` | Read role details and memberships |
| `DELETE` | `/roles/{roleID}` | Remove role |
| `POST` | `/roles/{roleID}/archive` | Archive role |
| `POST` | `/roles/{roleID}/move` | Move role to different organisation |
| `POST` | `/roles/{roleID}/merge` | Merge one role into another |
| `GET` | `/roles/{roleID}/members` | Returns all role members |
| `POST` | `/roles/{roleID}/member/{userID}` | Add member to a role |
| `DELETE` | `/roles/{roleID}/member/{userID}` | Remove member from a role |
## List roles
#### Method
@@ -457,11 +510,23 @@ An organisation may have many roles. Roles may have many channels available. Acc
| roleID | uint64 | PATH | Source Role ID | N/A | YES |
| userID | uint64 | PATH | User ID | N/A | YES |
---
# Users
| Method | Endpoint | Purpose |
| ------ | -------- | ------- |
| `GET` | `/users/` | Search users (Directory) |
| `POST` | `/users/` | Create user |
| `PUT` | `/users/{userID}` | Update user details |
| `GET` | `/users/{userID}` | Read user details and memberships |
| `DELETE` | `/users/{userID}` | Remove user |
| `POST` | `/users/{userID}/suspend` | Suspend user |
| `POST` | `/users/{userID}/unsuspend` | Unsuspend user |
## Search users (Directory)
#### Method
@@ -567,4 +632,6 @@ An organisation may have many roles. Roles may have many channels available. Acc
| Parameter | Type | Method | Description | Default | Required? |
| --------- | ---- | ------ | ----------- | ------- | --------- |
| userID | uint64 | PATH | User ID | N/A | YES |
| userID | uint64 | PATH | User ID | N/A | YES |
---
+4 -5
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/messaging/rest/request"
@@ -59,9 +60,7 @@ func NewAttachment(ah AttachmentAPI) *Attachment {
func (ah *Attachment) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/attachment/{attachmentID}", func(r chi.Router) {
r.Get("/original/{name}", ah.Original)
r.Get("/preview.{ext}", ah.Preview)
})
r.Get("/attachment/{attachmentID}/original/{name}", ah.Original)
r.Get("/attachment/{attachmentID}/preview.{ext}", ah.Preview)
})
}
+14 -15
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/messaging/rest/request"
@@ -149,19 +150,17 @@ func NewChannel(ch ChannelAPI) *Channel {
func (ch *Channel) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/channels", func(r chi.Router) {
r.Get("/", ch.List)
r.Post("/", ch.Create)
r.Put("/{channelID}", ch.Update)
r.Put("/{channelID}/state", ch.State)
r.Put("/{channelID}/flag", ch.SetFlag)
r.Delete("/{channelID}/flag", ch.RemoveFlag)
r.Get("/{channelID}", ch.Read)
r.Get("/{channelID}/members", ch.Members)
r.Put("/{channelID}/members/{userID}", ch.Join)
r.Delete("/{channelID}/members/{userID}", ch.Part)
r.Post("/{channelID}/invite", ch.Invite)
r.Post("/{channelID}/attach", ch.Attach)
})
r.Get("/channels/", ch.List)
r.Post("/channels/", ch.Create)
r.Put("/channels/{channelID}", ch.Update)
r.Put("/channels/{channelID}/state", ch.State)
r.Put("/channels/{channelID}/flag", ch.SetFlag)
r.Delete("/channels/{channelID}/flag", ch.RemoveFlag)
r.Get("/channels/{channelID}", ch.Read)
r.Get("/channels/{channelID}/members", ch.Members)
r.Put("/channels/{channelID}/members/{userID}", ch.Join)
r.Delete("/channels/{channelID}/members/{userID}", ch.Part)
r.Post("/channels/{channelID}/invite", ch.Invite)
r.Post("/channels/{channelID}/attach", ch.Attach)
})
}
+15 -16
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/messaging/rest/request"
@@ -158,20 +159,18 @@ func NewMessage(mh MessageAPI) *Message {
func (mh *Message) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/channels/{channelID}/messages", func(r chi.Router) {
r.Post("/", mh.Create)
r.Get("/", mh.History)
r.Get("/mark-as-read", mh.MarkAsRead)
r.Put("/{messageID}", mh.Edit)
r.Delete("/{messageID}", mh.Delete)
r.Get("/{messageID}/replies", mh.ReplyGet)
r.Post("/{messageID}/replies", mh.ReplyCreate)
r.Post("/{messageID}/pin", mh.PinCreate)
r.Delete("/{messageID}/pin", mh.PinRemove)
r.Post("/{messageID}/bookmark", mh.BookmarkCreate)
r.Delete("/{messageID}/bookmark", mh.BookmarkRemove)
r.Post("/{messageID}/reaction/{reaction}", mh.ReactionCreate)
r.Delete("/{messageID}/reaction/{reaction}", mh.ReactionRemove)
})
r.Post("/channels/{channelID}/messages/", mh.Create)
r.Get("/channels/{channelID}/messages/", mh.History)
r.Get("/channels/{channelID}/messages/mark-as-read", mh.MarkAsRead)
r.Put("/channels/{channelID}/messages/{messageID}", mh.Edit)
r.Delete("/channels/{channelID}/messages/{messageID}", mh.Delete)
r.Get("/channels/{channelID}/messages/{messageID}/replies", mh.ReplyGet)
r.Post("/channels/{channelID}/messages/{messageID}/replies", mh.ReplyCreate)
r.Post("/channels/{channelID}/messages/{messageID}/pin", mh.PinCreate)
r.Delete("/channels/{channelID}/messages/{messageID}/pin", mh.PinRemove)
r.Post("/channels/{channelID}/messages/{messageID}/bookmark", mh.BookmarkCreate)
r.Delete("/channels/{channelID}/messages/{messageID}/bookmark", mh.BookmarkRemove)
r.Post("/channels/{channelID}/messages/{messageID}/reaction/{reaction}", mh.ReactionCreate)
r.Delete("/channels/{channelID}/messages/{messageID}/reaction/{reaction}", mh.ReactionRemove)
})
}
+3 -4
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/messaging/rest/request"
@@ -50,8 +51,6 @@ func NewPermissions(ph PermissionsAPI) *Permissions {
func (ph *Permissions) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/permissions", func(r chi.Router) {
r.Get("/effective", ph.Effective)
})
r.Get("/permissions/effective", ph.Effective)
})
}
+3 -4
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/messaging/rest/request"
@@ -50,8 +51,6 @@ func NewSearch(sh SearchAPI) *Search {
func (sh *Search) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/search", func(r chi.Router) {
r.Get("/messages", sh.Messages)
})
r.Get("/search/messages", sh.Messages)
})
}
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+7 -8
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -86,12 +87,10 @@ func NewApplication(ah ApplicationAPI) *Application {
func (ah *Application) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/application", func(r chi.Router) {
r.Get("/", ah.List)
r.Post("/", ah.Create)
r.Put("/{applicationID}", ah.Update)
r.Get("/{applicationID}", ah.Read)
r.Delete("/{applicationID}", ah.Delete)
})
r.Get("/application/", ah.List)
r.Post("/application/", ah.Create)
r.Put("/application/{applicationID}", ah.Update)
r.Get("/application/{applicationID}", ah.Read)
r.Delete("/application/{applicationID}", ah.Delete)
})
}
+5 -6
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -68,10 +69,8 @@ func NewAuth(ah AuthAPI) *Auth {
func (ah *Auth) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/auth", func(r chi.Router) {
r.Get("/check", ah.Check)
r.Post("/login", ah.Login)
r.Get("/logout", ah.Logout)
})
r.Get("/auth/check", ah.Check)
r.Post("/auth/login", ah.Login)
r.Get("/auth/logout", ah.Logout)
})
}
+8 -9
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -95,13 +96,11 @@ func NewOrganisation(oh OrganisationAPI) *Organisation {
func (oh *Organisation) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/organisations", func(r chi.Router) {
r.Get("/", oh.List)
r.Post("/", oh.Create)
r.Put("/{id}", oh.Update)
r.Delete("/{id}", oh.Delete)
r.Get("/{id}", oh.Read)
r.Post("/{id}/archive", oh.Archive)
})
r.Get("/organisations/", oh.List)
r.Post("/organisations/", oh.Create)
r.Put("/organisations/{id}", oh.Update)
r.Delete("/organisations/{id}", oh.Delete)
r.Get("/organisations/{id}", oh.Read)
r.Post("/organisations/{id}/archive", oh.Archive)
})
}
+7 -8
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -86,12 +87,10 @@ func NewPermissions(ph PermissionsAPI) *Permissions {
func (ph *Permissions) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/permissions", func(r chi.Router) {
r.Get("/", ph.List)
r.Get("/effective", ph.Effective)
r.Get("/{roleID}/rules", ph.Read)
r.Delete("/{roleID}/rules", ph.Delete)
r.Patch("/{roleID}/rules", ph.Update)
})
r.Get("/permissions/", ph.List)
r.Get("/permissions/effective", ph.Effective)
r.Get("/permissions/{roleID}/rules", ph.Read)
r.Delete("/permissions/{roleID}/rules", ph.Delete)
r.Patch("/permissions/{roleID}/rules", ph.Update)
})
}
+13 -14
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -140,18 +141,16 @@ func NewRole(rh RoleAPI) *Role {
func (rh *Role) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/roles", func(r chi.Router) {
r.Get("/", rh.List)
r.Post("/", rh.Create)
r.Put("/{roleID}", rh.Update)
r.Get("/{roleID}", rh.Read)
r.Delete("/{roleID}", rh.Delete)
r.Post("/{roleID}/archive", rh.Archive)
r.Post("/{roleID}/move", rh.Move)
r.Post("/{roleID}/merge", rh.Merge)
r.Get("/{roleID}/members", rh.MemberList)
r.Post("/{roleID}/member/{userID}", rh.MemberAdd)
r.Delete("/{roleID}/member/{userID}", rh.MemberRemove)
})
r.Get("/roles/", rh.List)
r.Post("/roles/", rh.Create)
r.Put("/roles/{roleID}", rh.Update)
r.Get("/roles/{roleID}", rh.Read)
r.Delete("/roles/{roleID}", rh.Delete)
r.Post("/roles/{roleID}/archive", rh.Archive)
r.Post("/roles/{roleID}/move", rh.Move)
r.Post("/roles/{roleID}/merge", rh.Merge)
r.Get("/roles/{roleID}/members", rh.MemberList)
r.Post("/roles/{roleID}/member/{userID}", rh.MemberAdd)
r.Delete("/roles/{roleID}/member/{userID}", rh.MemberRemove)
})
}
+9 -10
View File
@@ -17,9 +17,10 @@ package handlers
import (
"context"
"github.com/go-chi/chi"
"net/http"
"github.com/go-chi/chi"
"github.com/titpetric/factory/resputil"
"github.com/crusttech/crust/system/rest/request"
@@ -104,14 +105,12 @@ func NewUser(uh UserAPI) *User {
func (uh *User) MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) {
r.Group(func(r chi.Router) {
r.Use(middlewares...)
r.Route("/users", func(r chi.Router) {
r.Get("/", uh.List)
r.Post("/", uh.Create)
r.Put("/{userID}", uh.Update)
r.Get("/{userID}", uh.Read)
r.Delete("/{userID}", uh.Delete)
r.Post("/{userID}/suspend", uh.Suspend)
r.Post("/{userID}/unsuspend", uh.Unsuspend)
})
r.Get("/users/", uh.List)
r.Post("/users/", uh.Create)
r.Put("/users/{userID}", uh.Update)
r.Get("/users/{userID}", uh.Read)
r.Delete("/users/{userID}", uh.Delete)
r.Post("/users/{userID}/suspend", uh.Suspend)
r.Post("/users/{userID}/unsuspend", uh.Unsuspend)
})
}
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"
+3 -2
View File
@@ -16,11 +16,12 @@ package request
*/
import (
"encoding/json"
"io"
"strings"
"encoding/json"
"mime/multipart"
"net/http"
"strings"
"github.com/go-chi/chi"
"github.com/pkg/errors"