diff --git a/.env.dist b/.env.dist index cad0def..c80a85a 100644 --- a/.env.dist +++ b/.env.dist @@ -23,7 +23,6 @@ DEBUG=1 # ------------------------------ # MariaDB values --------------- MYSQL_ROOT_PASSWORD=popcube_dev -MYSQL_ROOT_PASSWORD=popcube_dev MYSQL_DATABASE=popcube_test MYSQL_USER=test_user MYSQL_PASSWORD=test diff --git a/api/api.go b/api/api.go index 619699a..ec7b6ed 100644 --- a/api/api.go +++ b/api/api.go @@ -47,36 +47,36 @@ func initMiddleware(router *chi.Mux) { // basicRoutes set basic routes for the API func basicRoutes(router *chi.Mux) { - // swagger:route GET / Test getter + // swagger:route GET / Test hello // // Hello World // // Responses: - // 200 + // 200: generalOk // default: genericError router.Get("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Welcome to PopCube api. Let's chat all together :O")) }) - // swagger:route GET /ping Test getter + // swagger:route GET /ping Test ping // // Pong // // Test api ping // // Responses: - // 200 + // 200: generalOk // default: genericError router.Get("/ping", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("pong")) }) - // swagger:route GET /panic Test getter + // swagger:route GET /panic Test panic // // Should result in 500 // // Test panic cautching // // Responses: - // 500 + // 500: genericError // default: genericError router.Get("/panic", func(w http.ResponseWriter, r *http.Request) { panic("C'est la panique, panique, panique. Sur le périphérique") diff --git a/api/api_parameters.go b/api/api_parameters.go index 0ae941c..5917c20 100644 --- a/api/api_parameters.go +++ b/api/api_parameters.go @@ -25,7 +25,7 @@ type avatarIDParam struct { AvatarID int `json:"avatarID"` } -// swagger:parameters newAvatar updateAvatar +// swagger:parameters newAvatar newAvatar1 updateAvatar type avatarObjectParam struct { //Link of the avatar in server. // in:body @@ -56,7 +56,7 @@ type channelIDParam struct { ChannelID int `json:"channelID"` } -// swagger:parameters newChannel updateChannel +// swagger:parameters newChannel newChannel1 updateChannel getMemberFromChannel getMessageFromChannel type channelObjectParam struct { //Link of the channel in server. // in:body @@ -94,7 +94,7 @@ type emojiIDParam struct { EmojiID int `json:"emojiID"` } -// swagger:parameters newEmoji updateEmoji +// swagger:parameters newEmoji newEmoji1 updateEmoji type emojiObjectParam struct { //Link of the emoji in server. // in:body @@ -102,3 +102,210 @@ type emojiObjectParam struct { } // <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> FOLDER PARAMETERS <><><><><> // + +// swagger:parameters getFolderFromLink +type folderLinkParam struct { + //Link of the folder in server. + // in:path + FolderLink string `json:"folderLink"` +} + +// swagger:parameters getFolderFromName +type folderNameParam struct { + //Link of the folder in server. + // in:path + FolderName string `json:"folderName"` +} + +// swagger:parameters getFolderFromType +type folderTypeParam struct { + //Link of the folder in server. + // in:path + FolderType string `json:"folderType"` +} + +// swagger:parameters updateFolder deleteFolder +type folderIDParam struct { + //Link of the folder in server. + // in:path + FolderID int `json:"folderID"` +} + +// swagger:parameters newFolder newFolder1 updateFolder +type folderObjectParam struct { + //Link of the folder in server. + // in:body + Folder models.Folder `json:"folder"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> MEMBER PARAMETERS <><><><><> // + +// swagger:parameters updateMember +type memberIDParam struct { + //Link of the member in server. + // in:path + MemberID int `json:"memberID"` +} + +// swagger:parameters newMember newMember1 updateOrgansisation +type memberObjectParam struct { + // Member object + // in:body + Member models.Member `json:"member"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> MESSAGE PARAMETERS <><><><><> // + +// swagger:parameters getMessageFromDate +type messageDate struct { + // Date of the message + // in:path + MessageDate int64 `json:"messageDate"` +} + +// swagger:parameters updateMessage deleteMessage +type messageIDParam struct { + //Link of the message in server. + // in:path + MessageID int `json:"messageID"` +} + +// swagger:parameters newMessage newMessage1 updateMessage getFolderFromMessage +type messageObjectParam struct { + //Link of the message in server. + // in:body + Message models.Message `json:"message"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> ORGANISATION PARAMETERS <><><><><> // + +// swagger:parameters updateOrganisation +type organisationIDParam struct { + //Link of the organisation in server. + // in:path + OrganisationID int `json:"organisationID"` +} + +// swagger:parameters newOrganisation newOrganisation1 updateOrgansisation +type organisationObjectParam struct { + // Organisation object + // in:body + Organisation models.Organisation `json:"organisation"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> PARMETER PARAMETERS <><><><><> // + +// swagger:parameters updateParameter +type parameterIDParam struct { + //Link of the parameter in server. + // in:path + ParameterID int `json:"parameterID"` +} + +// swagger:parameters newParameter newParameter1 updateOrgansisation +type parameterObjectParam struct { + // Parameter object + // in:body + Parameter models.Parameter `json:"parameter"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> ROLE PARAMETERS <><><><><> // + +// swagger:parameters getRoleFromName +type roleNameParam struct { + //Link of the role in server. + // in:path + RoleName string `json:"roleName"` +} + +// swagger:parameters updateRole deleteRole +type roleIDParam struct { + //Link of the role in server. + // in:path + RoleID int `json:"roleID"` +} + +// swagger:parameters newRole newRole1 updateRole getUserFromRole getMemberFromRole +type roleObjectParam struct { + // Role object + // in:body + Role models.Role `json:"role"` +} + +// rightsParameterModel is the object you can pass to get roles from rights. +// +// swagger:model rightsParameterModel +type rightsParameterModel struct { + // User can use private channel + CanUsePrivate bool `gorm:"column:canUsePrivate;not null" json:"can_use_private,omitempty"` + // User can moderate channels + CanModerate bool `gorm:"column:canModerate;not null" json:"can_moderate,omitempty"` + // User can archive channels + CanArchive bool `gorm:"column:canArchive;not null" json:"can_archive,omitempty"` + // User can invite others to private channel or organisation + CanInvite bool `gorm:"column:canInvite;not null" json:"can_invite,omitempty"` + // User can manage organisation/channel parameters and data + CanManage bool `gorm:"column:canManage;not null" json:"can_manage,omitempty"` + // User can manage other organisation/channel user + CanManageUser bool `gorm:"column:canManageUser;not null" json:"can_manage_user,omitempty"` +} + +// swagger:parameters getRoleFromRights +type rightsObjectParam struct { + // Right of the role we search + // in:body + Rights rightsParameterModel `json:"rights"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> USER PARAMETERS <><><><><> // + +// swagger:parameters getUserFromName +type userNameParam struct { + //Link of the user in server. + // in:path + UserName string `json:"userName"` +} + +// swagger:parameters getUserFromNickName +type nickNameParam struct { + //Link of the user in server. + // in:path + NickName string `json:"nickName"` +} + +// swagger:parameters getUserFromFirstName +type firstNameParam struct { + //Link of the user in server. + // in:path + FirstName string `json:"firstName"` +} + +// swagger:parameters getUserFromLastName +type lastNameeParam struct { + //Link of the user in server. + // in:path + LastName string `json:"lastName"` +} + +// swagger:parameters updateUser deleteUser +type userIDParam struct { + //Link of the user in server. + // in:path + UserID int `json:"userID"` +} + +// swagger:parameters newUser newUser1 updateUser getMemberFromUser getMessageFromUser +type userObjectParam struct { + //Link of the user in server. + // in:body + User models.User `json:"user"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // diff --git a/api/api_responses.go b/api/api_responses.go index 196a4f4..bf7d606 100644 --- a/api/api_responses.go +++ b/api/api_responses.go @@ -14,7 +14,6 @@ type generalOk struct { // What you want to say // in:body Message string `json:"message,omitempty"` - Status int `json:"-"` } // --------------------------------------------------- @@ -74,7 +73,6 @@ type deleteMessage struct { func newGeneralOk(message string) generalOk { return generalOk{ - Status: 200, Message: message, } } @@ -151,3 +149,130 @@ type emojiObjectSuccess struct { } // <><><><><> <><><><><> <><><><><> <><><><><> // + +// <><><><><> FOLDER RESPONSES <><><><><> // + +// folderSlice Array of folders +// +// swagger:response folderArraySuccess +type folderArraySuccess struct { + // in:body + Folders []models.Folder +} + +// folderObjectSuccess list of folders +// +// swagger:response folderObjectSuccess +type folderObjectSuccess struct { + // in:body + // List of folders returned + Folder models.Folder `json:"folder"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // + +// <><><><><> MEMBER RESPONSES <><><><><> // + +// memberSlice Array of members +// +// swagger:response memberArraySuccess +type memberArraySuccess struct { + // in:body + Members []models.Member +} + +// memberObjectSuccess list of members +// +// swagger:response memberObjectSuccess +type memberObjectSuccess struct { + // in:body + // List of members returned + Member models.Member `json:"member"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> MESSAGE RESPONSES <><><><><> // + +// messageSlice Array of messages +// +// swagger:response messageArraySuccess +type messageArraySuccess struct { + // in:body + Messages []models.Message +} + +// messageObjectSuccess list of messages +// +// swagger:response messageObjectSuccess +type messageObjectSuccess struct { + // in:body + // List of messages returned + Message models.Message `json:"message"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> ORGANISATION RESPONSES <><><><><> // + +// organisationObjectSuccess list of organisations +// +// swagger:response organisationObjectSuccess +type organisationObjectSuccess struct { + // in:body + // List of organisations returned + Organisation models.Organisation `json:"organisation"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // + +// <><><><><> PARAMETERS RESPONSES <><><><><> // + +// parameterObjectSuccess list of parameters +// +// swagger:response parameterObjectSuccess +type parameterObjectSuccess struct { + // in:body + // List of parameters returned + Parameter models.Parameter `json:"parameter"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> ROLE RESPONSES <><><><><> // + +// roleSlice Array of roles +// +// swagger:response roleArraySuccess +type roleArraySuccess struct { + // in:body + Roles []models.Role +} + +// roleObjectSuccess list of roles +// +// swagger:response roleObjectSuccess +type roleObjectSuccess struct { + // in:body + // List of roles returned + Role models.Role `json:"role"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // +// <><><><><> USER RESPONSES <><><><><> // + +// userSlice Array of users +// +// swagger:response userArraySuccess +type userArraySuccess struct { + // in:body + Users []models.User +} + +// userObjectSuccess list of users +// +// swagger:response userObjectSuccess +type userObjectSuccess struct { + // in:body + // List of users returned + User models.User `json:"user"` +} + +// <><><><><> <><><><><> <><><><><> <><><><><> // diff --git a/api/avatar_route.go b/api/avatar_route.go index 3acce0c..fadf0cb 100644 --- a/api/avatar_route.go +++ b/api/avatar_route.go @@ -43,7 +43,7 @@ func initAvatarRoute(router chi.Router) { // 503: databaseError // default: genericError r.Post("/", newAvatar) - // swagger:route GET /avatar/all Avatars getAllAvatar + // swagger:route GET /avatar/all Avatars getAllAvatar1 // // Get avatars // @@ -54,21 +54,22 @@ func initAvatarRoute(router chi.Router) { // 503: databaseError // default: genericError r.Get("/all", getAllAvatar) - // swagger:route POST /avatar/new Avatars newAvatar + // swagger:route POST /avatar/new Avatars newAvatar1 // // New avatar // // This will create an avatar for organisation avatars library. // // Responses: - // default: genericError - // 503: databaseError // 200: avatarObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newAvatar) r.Route("/link/", func(r chi.Router) { r.Route("/:avatarLink", func(r chi.Router) { r.Use(avatarContext) - // swagger:route GET /avatar/link/:avatarLink Avatars getAvatarFromLink + // swagger:route GET /avatar/link/{avatarLink} Avatars getAvatarFromLink // // Get avatar from link // @@ -84,7 +85,7 @@ func initAvatarRoute(router chi.Router) { r.Route("/name/", func(r chi.Router) { r.Route("/:avatarName", func(r chi.Router) { r.Use(avatarContext) - // swagger:route GET /avatar/name/:avatarName Avatars getAvatarFromName + // swagger:route GET /avatar/name/{avatarName} Avatars getAvatarFromName //y // Get avatar from name // @@ -99,26 +100,27 @@ func initAvatarRoute(router chi.Router) { }) r.Route("/:avatarID", func(r chi.Router) { r.Use(avatarContext) - // swagger:route PUT /avatar/:avatarID Avatars updateAvatar + // swagger:route PUT /avatar/{avatarID} Avatars updateAvatar // // Update avatar // // This will return the new avatar object // // Responses: - // 200: avatzarObjectSuccess + // 200: avatarObjectSuccess // 422: wrongEntity // 503: databaseError // default: genericError r.Put("/update", updateAvatar) - // swagger:route DELETE /avatar/:avatarID Avatars deleteAvatar + // swagger:route PUT /avatar/{avatarID} Avatars updateAvatar // - // Delete avatar + // Update avatar // - // This will return an object describing the deletion + // This will return the new avatar object // // Responses: - // 200: deleteMessage + // 200: avatarObjectSuccess + // 422: wrongEntity // 503: databaseError // default: genericError r.Delete("/delete", deleteAvatar) diff --git a/api/channel_route.go b/api/channel_route.go index 5a1df11..18cc44c 100644 --- a/api/channel_route.go +++ b/api/channel_route.go @@ -43,7 +43,7 @@ func initChannelRoute(router chi.Router) { // 503: databaseError // default: genericError r.Post("/", newChannel) - // swagger:route GET /channel/all Channels getAllChannel + // swagger:route GET /channel/all Channels getAllChannel1 // // Get channels // @@ -54,7 +54,7 @@ func initChannelRoute(router chi.Router) { // 503: databaseError // default: genericError r.Get("/all", getAllChannel) - // swagger:route POST /channel/new Channels newChannel + // swagger:route POST /channel/new Channels newChannel1 // // New channel // @@ -91,7 +91,7 @@ func initChannelRoute(router chi.Router) { r.Route("/type/", func(r chi.Router) { r.Route("/:channelType", func(r chi.Router) { r.Use(channelContext) - // swagger:route GET /channel/type/:channelType Channels getChannelFromType + // swagger:route GET /channel/type/{channelType} Channels getChannelFromType // // Get channels of provided type // @@ -107,7 +107,7 @@ func initChannelRoute(router chi.Router) { r.Route("/name/", func(r chi.Router) { r.Route("/:channelName", func(r chi.Router) { r.Use(channelContext) - // swagger:route GET /channel/name/:channelName Channels getChannelFromName + // swagger:route GET /channel/name/{channelName} Channels getChannelFromName // // Get nammed channel // @@ -122,7 +122,7 @@ func initChannelRoute(router chi.Router) { }) r.Route("/:channelID", func(r chi.Router) { r.Use(channelContext) - // swagger:route PUT /channel/:channelID Channels updateChannel + // swagger:route PUT /channel/{channelID} Channels updateChannel // // Update channel // @@ -134,7 +134,7 @@ func initChannelRoute(router chi.Router) { // 503: databaseError // default: genericError r.Put("/update", updateChannel) - // swagger:route DELETE /channel/:channelID Channels deleteChannel + // swagger:route DELETE /channel/{channelID} Channels deleteChannel // // Delete channel // diff --git a/api/emojis_route.go b/api/emojis_route.go index b2c53aa..fc8027b 100644 --- a/api/emojis_route.go +++ b/api/emojis_route.go @@ -21,31 +21,124 @@ const ( func initEmojiRoute(router chi.Router) { router.Route("/emoji", func(r chi.Router) { + // swagger:route GET /emoji Emojis getAllEmoji + // + // Get emojis + // + // This will get all the emojis available in the organisation. + // + // Responses: + // 200: emojiArraySuccess + // 503: databaseError + // default: genericError r.Get("/", getAllEmoji) + // swagger:route POST /emoji Emojis newEmoji + // + // New emoji + // + // This will create an emoji for organisation emojis library. + // + // Responses: + // 200: emojiObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newEmoji) + // swagger:route GET /emoji/all Emojis getAllEmoji1 + // + // Get emojis + // + // This will get all the emojis available in the organisation. + // + // Responses: + // 200: emojiArraySuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllEmoji) + // swagger:route POST /emoji Emojis newEmoji1 + // + // New emoji + // + // This will create an emoji for organisation emojis library. + // + // Responses: + // 200: emojiObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newEmoji) r.Route("/link/", func(r chi.Router) { r.Route("/:emojiLink", func(r chi.Router) { r.Use(emojiContext) + // swagger:route GET /emoji/link/{emojiLink} Emojis getEmojiFromLink + // + // Get emoji from link + // + // This will return the emoji object corresponding to provided link + // + // Responses: + // 200: emojiObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getEmojiFromLink) }) }) r.Route("/name/", func(r chi.Router) { r.Route("/:emojiName", func(r chi.Router) { r.Use(emojiContext) + // swagger:route GET /emoji/name/{emojiName} Emojis getEmojiFromName + // + // Get emoji from name + // + // This will return the emoji object corresponding to provided name + // + // Responses: + // 200: emojiObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getEmojiFromName) }) }) r.Route("/shortcut/", func(r chi.Router) { r.Route("/:emojiShortcut", func(r chi.Router) { r.Use(emojiContext) + // swagger:route GET /emoji/shortcut/{emojiShortcut} Emojis getEmojiFromShortcut + // + // Get emoji from shortcut + // + // This will return the emoji object corresponding to provided shortcut + // + // Responses: + // 200: emojiObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getEmojiFromShortcut) }) }) r.Route("/:emojiID", func(r chi.Router) { r.Use(emojiContext) + // swagger:route PUT /emoji/{emojiID} Emojis updateEmoji + // + // Update emoji + // + // This will return the new emoji object + // + // Responses: + // 200: avatarObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateEmoji) + // swagger:route DELETE /emoji/{emojiID} Emojis deleteEmoji + // + // Delete emoji + // + // This will return an object describing the deletion + // + // Responses: + // 200: deleteMessage + // 503: databaseError + // default: genericError r.Delete("/delete", deleteEmoji) }) }) diff --git a/api/folder_route.go b/api/folder_route.go index e4527f2..e0ee96e 100644 --- a/api/folder_route.go +++ b/api/folder_route.go @@ -12,34 +12,145 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + folderNameKey key = "folderName" + folderTypeKey key = "folderType" + folderLinkKey key = "folderLink" + oldFolderKey key = "oldFolder" +) + func initFolderRoute(router chi.Router) { router.Route("/folder", func(r chi.Router) { + // swagger:route GET /folder Folders getAllFolder + // + // Get folders + // + // This will get all the folders available in the organisation. + // + // Responses: + // 200: folderArraySuccess + // 503: databaseError + // default: genericError r.Get("/", getAllFolder) + // swagger:route POST /folder Folders newFolder + // + // New folder + // + // This will create an folder for organisation folders library. + // + // Responses: + // 200: folderObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newFolder) + // swagger:route GET /folder/all Folders getAllFolder1 + // + // Get folders + // + // This will get all the folders available in the organisation. + // + // Responses: + // 200: folderArraySuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllFolder) + // swagger:route POST /folder/new Folders newFolder1 + // + // New folder + // + // This will create an folder for organisation folders library. + // + // Responses: + // 200: folderObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newFolder) + // swagger:route POST /folder/message Folders getFolderFromMessage + // + // Get folders linked to message + // + // Return folders linked to provided message. + // + // Responses: + // 200: folderArraySuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/message", getFolderFromMessage) - r.Route("/foldername/", func(r chi.Router) { + r.Route("/name/", func(r chi.Router) { r.Route("/:folderName", func(r chi.Router) { r.Use(folderContext) + // swagger:route GET /folder/name/{folderName} Folders getFolderFromName + // + // Get folder from name + // + // This will return the folder object corresponding to provided name + // + // Responses: + // 200: folderObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getFolderFromName) }) }) r.Route("/link/", func(r chi.Router) { r.Route("/:folderLink", func(r chi.Router) { r.Use(folderContext) + // swagger:route GET /folder/link/{folderLink} Folders getFolderFromLink + // + // Get folder from link + // + // This will return the folder object corresponding to provided link + // + // Responses: + // 200: folderObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getFolderFromLink) }) }) r.Route("/type/", func(r chi.Router) { r.Route("/:folderType", func(r chi.Router) { r.Use(folderContext) + // swagger:route GET /folder/type/{folderType} Folders getFolderFromType + // + // Get folder from type + // + // This will return the folder object corresponding to provided type + // + // Responses: + // 200: folderObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getFolderFromType) }) }) r.Route("/:folderID", func(r chi.Router) { r.Use(folderContext) + // swagger:route PUT /folder/{folderID} Folders updateFolder + // + // Update folder + // + // This will return the new folder object + // + // Responses: + // 200: avatarObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateFolder) + // swagger:route DELETE /folder/{folderID} Folders deleteFolder + // + // Delete folder + // + // This will return an object describing the deletion + // + // Responses: + // 200: deleteMessage + // 503: databaseError + // default: genericError r.Delete("/delete", deleteFolder) }) }) @@ -52,13 +163,13 @@ func folderContext(next http.Handler) http.Handler { folderType := chi.URLParam(r, "folderType") folderLink := chi.URLParam(r, "folderLink") oldFolder := models.Folder{} - ctx := context.WithValue(r.Context(), "folderName", name) - ctx = context.WithValue(r.Context(), "folderType", folderType) - ctx = context.WithValue(ctx, "folderLink", folderLink) + ctx := context.WithValue(r.Context(), folderNameKey, name) + ctx = context.WithValue(r.Context(), folderTypeKey, folderType) + ctx = context.WithValue(ctx, folderLinkKey, folderLink) if err == nil { oldFolder = datastores.Store().Folder().GetByID(folderID, dbStore.db) } - ctx = context.WithValue(ctx, "oldFolder", oldFolder) + ctx = context.WithValue(ctx, oldFolderKey, oldFolder) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -79,7 +190,7 @@ func getFolderFromName(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - name := r.Context().Value("folderName").(string) + name := r.Context().Value(folderNameKey).(string) folder := store.Folder().GetByName(name, db) render.JSON(w, 200, folder) } @@ -88,7 +199,7 @@ func getFolderFromType(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - folderType := r.Context().Value("folderType").(string) + folderType := r.Context().Value(folderTypeKey).(string) folder := store.Folder().GetByType(folderType, db) render.JSON(w, 200, folder) } @@ -97,7 +208,7 @@ func getFolderFromLink(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - link := r.Context().Value("folderLink").(string) + link := r.Context().Value(folderLinkKey).(string) folder := store.Folder().GetByLink(link, db) render.JSON(w, 200, folder) } @@ -116,8 +227,8 @@ func getFolderFromMessage(w http.ResponseWriter, r *http.Request) { render.JSON(w, error422.StatusCode, error422) } else { if err := db.DB().Ping(); err == nil { - role := store.Folder().GetByMessage(data.Message, db) - render.JSON(w, 200, role) + folders := store.Folder().GetByMessage(data.Message, db) + render.JSON(w, 200, folders) } else { render.JSON(w, error503.StatusCode, error503) } @@ -160,7 +271,7 @@ func updateFolder(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - folder := r.Context().Value("oldFolder").(models.Folder) + folder := r.Context().Value(oldFolderKey).(models.Folder) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { diff --git a/api/member_route.go b/api/member_route.go index 74e676c..1e142a2 100644 --- a/api/member_route.go +++ b/api/member_route.go @@ -12,18 +12,119 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + oldMemberKey key = "oldMember" +) + func initMemberRoute(router chi.Router) { router.Route("/member", func(r chi.Router) { + // swagger:route GET /member Members getAllMember + // + // Get members + // + // This will get all the members available in the organisation. + // + // Responses: + // 200: memberArraySuccess + // 503: databaseError + // default: genericError r.Get("/", getAllMember) + // swagger:route POST /member Members newMember + // + // New member + // + // This will create an member for organisation members library. + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newMember) + // swagger:route GET /member/all Members getAllMember1 + // + // Get members + // + // This will get all the members available in the organisation. + // + // Responses: + // 200: memberArraySuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllMember) + // swagger:route POST /channel Members getMemberFromChannel + // + // Get member into channel + // + // This will return all users in provided channel + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/channel", getMemberFromChannel) + // swagger:route POST /user Members getMemberFromUser + // + // Get channel user is member of + // + // This will return all channel provided user is in + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/user", getMemberFromUser) + // swagger:route POST /user Members getMemberFromRole + // + // Get member having channel specifics roles + // + // This will return all members having a Specific role for a channel + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/role", getMemberFromRole) + // swagger:route POST /member/new Members newMember1 + // + // New member + // + // This will create an member for organisation members library. + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newMember) r.Route("/:memberID", func(r chi.Router) { r.Use(memberContext) + // swagger:route PUT /member/{memberID} Members updateMember + // + // Update member + // + // This will return the new member object + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateMember) + // swagger:route PUT /member/{memberID} Members updateMember + // + // Update member + // + // This will return the new member object + // + // Responses: + // 200: memberObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Delete("/delete", deleteMember) }) }) @@ -36,7 +137,7 @@ func memberContext(next http.Handler) http.Handler { if err == nil { oldMember = datastores.Store().Member().GetByID(memberID, dbStore.db) } - ctx := context.WithValue(r.Context(), "oldMember", oldMember) + ctx := context.WithValue(r.Context(), oldMemberKey, oldMember) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -155,7 +256,7 @@ func updateMember(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - member := r.Context().Value("oldMember").(models.Member) + member := r.Context().Value(oldMemberKey).(models.Member) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { @@ -173,7 +274,7 @@ func updateMember(w http.ResponseWriter, r *http.Request) { } func deleteMember(w http.ResponseWriter, r *http.Request) { - member := r.Context().Value("member").(models.Member) + member := r.Context().Value(oldMemberKey).(models.Member) store := datastores.Store() render := renderPackage.New() message := deleteMessageModel{ @@ -192,6 +293,6 @@ func deleteMember(w http.ResponseWriter, r *http.Request) { render.JSON(w, err.StatusCode, message.Message) } } else { - render.JSON(w, 503, error503) + render.JSON(w, error503.StatusCode, error503) } } diff --git a/api/message_route.go b/api/message_route.go index a3be376..a16547d 100644 --- a/api/message_route.go +++ b/api/message_route.go @@ -12,24 +12,124 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + messageDateKey key = "messageDate" + oldMessageKey key = "oldMessage" +) + func initMessageRoute(router chi.Router) { router.Route("/message", func(r chi.Router) { - r.Route("/get", func(r chi.Router) { - r.Get("/", getAllMessage) - r.Get("/all", getAllMessage) - r.Post("/channel", getMessageFromChannel) - r.Post("/creator", getMessageFromUser) - r.Route("/date/", func(r chi.Router) { - r.Route("/:date", func(r chi.Router) { - r.Use(messageContext) - r.Get("/", getMessageFromDate) - }) + // swagger:route GET /message Messages getAllMessage + // + // Get messages + // + // This will get all the messages available in the organisation. + // + // Responses: + // 200: messageArraySuccess + // 503: databaseError + // default: genericError + r.Get("/", getAllMessage) + // swagger:route POST /message Messages newMessage + // + // New message + // + // This will create an message for organisation messages library. + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError + r.Post("/", newMessage) + // swagger:route GET /message/all Messages getAllMessage1 + // + // Get messages + // + // This will get all the messages available in the organisation. + // + // Responses: + // 200: messageArraySuccess + // 503: databaseError + // default: genericError + r.Get("/all", getAllMessage) + // swagger:route POST /message/new Messages newMessage1 + // + // New message + // + // This will create an message for organisation messages library. + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError + r.Post("/new", newMessage) + // swagger:route POST /channel Messages getMessageFromChannel + // + // Get message from channel + // + // This will return all mesages in provided channel + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError + r.Post("/channel", getMessageFromChannel) + // swagger:route POST /user Messages getMessageFromUser + // + // Get message from user + // + // This will return all mesage created by provided user + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError + r.Post("/creator", getMessageFromUser) + r.Route("/date/", func(r chi.Router) { + r.Route("/:messageDate", func(r chi.Router) { + r.Use(messageContext) + // swagger:route GET /message/date/{messageDate} Messages getMessageFromDate + // + // Get message from date + // + // This will return the message object corresponding to provided date + // + // Responses: + // 200: messageObjectSuccess + // 503: databaseError + // default: genericError + r.Get("/", getMessageFromDate) }) }) - r.Post("/new", newMessage) r.Route("/:messageID", func(r chi.Router) { r.Use(messageContext) + // swagger:route PUT /message/{messageID} Messages updateMessage + // + // Update message + // + // This will return the new message object + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateMessage) + // swagger:route PUT /message/{messageID} Messages updateMessage + // + // Update message + // + // This will return the new message object + // + // Responses: + // 200: messageObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Delete("/delete", deleteMessageFunction) }) }) @@ -38,13 +138,13 @@ func initMessageRoute(router chi.Router) { func messageContext(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { messageID, err := strconv.ParseUint(chi.URLParam(r, "messageID"), 10, 64) - date, _ := strconv.ParseInt(chi.URLParam(r, "date"), 10, 64) + date, _ := strconv.ParseInt(chi.URLParam(r, "messageDate"), 10, 64) oldMessage := models.Message{} - ctx := context.WithValue(r.Context(), "date", date) + ctx := context.WithValue(r.Context(), messageDateKey, date) if err == nil { oldMessage = datastores.Store().Message().GetByID(messageID, dbStore.db) } - ctx = context.WithValue(ctx, "oldMessage", oldMessage) + ctx = context.WithValue(ctx, oldMessageKey, oldMessage) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -65,7 +165,7 @@ func getMessageFromDate(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - date := r.Context().Value("date").(int) + date := r.Context().Value(messageDateKey).(int) message := store.Message().GetByDate(date, db) render.JSON(w, 200, message) } @@ -150,7 +250,7 @@ func updateMessage(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - message := r.Context().Value("oldMessage").(models.Message) + message := r.Context().Value(oldMessageKey).(models.Message) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { @@ -168,7 +268,7 @@ func updateMessage(w http.ResponseWriter, r *http.Request) { } func deleteMessageFunction(w http.ResponseWriter, r *http.Request) { - message := r.Context().Value("message").(models.Message) + message := r.Context().Value(oldMessageKey).(models.Message) store := datastores.Store() render := renderPackage.New() dmessage := deleteMessageModel{ diff --git a/api/organisation_route.go b/api/organisation_route.go index 880475e..5eac838 100644 --- a/api/organisation_route.go +++ b/api/organisation_route.go @@ -12,14 +12,70 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + oldOrganisationKey key = "oldOrganisation" +) + func initOrganisationRoute(router chi.Router) { router.Route("/organisation", func(r chi.Router) { + // swagger:route GET /organisation Organisations getAllOrganisation + // + // Get organisations + // + // This will get all the organisations available in the organisation. + // + // Responses: + // 200: organisationObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getAllOrganisation) + // swagger:route POST /organisation Organisations newOrganisation + // + // New organisation + // + // This will create an organisation for organisation organisations library. + // + // Responses: + // 200: organisationObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newOrganisation) + // swagger:route GET /organisation/all Organisations getAllOrganisation1 + // + // Get organisations + // + // This will get all the organisations available in the organisation. + // + // Responses: + // 200: organisationObjectSuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllOrganisation) + // swagger:route POST /organisation/new Organisations newOrganisation1 + // + // New organisation + // + // This will create an organisation for organisation organisations library. + // + // Responses: + // 200: organisationObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newOrganisation) r.Route("/:organisationID", func(r chi.Router) { r.Use(organisationContext) + // swagger:route PUT /organisation/{organisationID} Organisations updateOrganisation + // + // Get organisation from link + // + // This will return the organisation object corresponding to provided link + // + // Responses: + // 200: organisationObjectSuccess + // 503: databaseError + // default: genericError r.Put("/update", updateOrganisation) }) }) @@ -32,7 +88,7 @@ func organisationContext(next http.Handler) http.Handler { if err == nil { oldOrganisation = datastores.Store().Organisation().Get(dbStore.db) } - ctx := context.WithValue(r.Context(), "oldOrganisation", oldOrganisation) + ctx := context.WithValue(r.Context(), oldOrganisationKey, oldOrganisation) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -85,7 +141,7 @@ func updateOrganisation(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - organisation := r.Context().Value("oldOrganisation").(models.Organisation) + organisation := r.Context().Value(oldOrganisationKey).(models.Organisation) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { diff --git a/api/parameter_route.go b/api/parameter_route.go index 8f967dc..0e39e6a 100644 --- a/api/parameter_route.go +++ b/api/parameter_route.go @@ -12,14 +12,71 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + oldParameterKey key = "oldParameter" +) + func initParameterRoute(router chi.Router) { router.Route("/parameter", func(r chi.Router) { + // swagger:route GET /parameter Parameters getAllParameter + // + // Get parameters + // + // This will get all the parameters available in the organisation. + // + // Responses: + // 200: parameterObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getAllParameter) + // swagger:route POST /parameter Parameters newParameter + // + // New parameter + // + // This will create an parameter for organisation parameters library. + // + // Responses: + // 200: parameterObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newParameter) + // swagger:route GET /parameter/all Parameters getAllParameter1 + // + // Get parameters + // + // This will get all the parameters available in the organisation. + // + // Responses: + // 200: parameterObjectSuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllParameter) + // swagger:route POST /parameter/new Parameters newParameter1 + // + // New parameter + // + // This will create an parameter for organisation parameters library. + // + // Responses: + // 200: parameterObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newParameter) r.Route("/:parameterID", func(r chi.Router) { r.Use(parameterContext) + // swagger:route PUT /parameter/{parameterID} Parameters updateParameter + // + // Update parameter + // + // This will return the new parameter object + // + // Responses: + // 200: avatarObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateParameter) }) }) @@ -32,7 +89,7 @@ func parameterContext(next http.Handler) http.Handler { if err == nil { parameter = datastores.Store().Parameter().Get(dbStore.db) } - ctx := context.WithValue(r.Context(), "parameter", parameter) + ctx := context.WithValue(r.Context(), oldParameterKey, parameter) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -85,7 +142,7 @@ func updateParameter(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - parameter := r.Context().Value("parameter").(models.Parameter) + parameter := r.Context().Value(oldParameterKey).(models.Parameter) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { diff --git a/api/role_route.go b/api/role_route.go index 006c6fb..5703dec 100644 --- a/api/role_route.go +++ b/api/role_route.go @@ -12,22 +12,110 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + roleNameKey key = "roleName" + oldRoleKey key = "oldRole" +) + func initRoleRoute(router chi.Router) { router.Route("/role", func(r chi.Router) { + // swagger:route GET /role Roles getAllRole + // + // Get roles + // + // This will get all the roles available in the organisation. + // + // Responses: + // 200: roleArraySuccess + // 503: databaseError + // default: genericError r.Get("/", getAllRole) + // swagger:route GET /role Roles getAllRole + // + // Get roles + // + // This will get all the roles available in the organisation. + // + // Responses: + // 200: roleArraySuccess + // 503: databaseError + // default: genericError r.Post("/", newRole) + // swagger:route GET /role/all Roles getAllRole1 + // + // Get roles + // + // This will get all the roles available in the organisation. + // + // Responses: + // 200: roleArraySuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllRole) + // swagger:route POST /role/new Roles newRole1 + // + // New role + // + // This will create an role for organisation roles library. + // + // Responses: + // 200: roleObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newRole) + // swagger:route POST /role/rights Roles getRoleFromRights + // + // Get role having provided rights + // + // Return an array of roles corresponding to rights + // + // Responses: + // 200: roleArraySuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/rights", getRoleFromRight) r.Route("/name/", func(r chi.Router) { r.Route("/:roleName", func(r chi.Router) { r.Use(roleContext) + // swagger:route GET /role/name/{roleName} Roles getRoleFromName + // + // Get role from name + // + // This will return the role object corresponding to provided name + // + // Responses: + // 200: roleObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getRoleFromName) }) }) r.Route("/:roleID", func(r chi.Router) { r.Use(roleContext) + // swagger:route PUT /role/{roleID} Roles updateRole + // + // Update role + // + // This will return the new role object + // + // Responses: + // 200: avatarObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateRole) + // swagger:route DELETE /role/{roleID} Roles deleteRole + // + // Delete role + // + // This will return an object describing the deletion + // + // Responses: + // 200: deleteMessage + // 503: databaseError + // default: genericError r.Delete("/delete", deleteRole) }) }) @@ -38,11 +126,11 @@ func roleContext(next http.Handler) http.Handler { roleID, err := strconv.ParseUint(chi.URLParam(r, "roleID"), 10, 64) name := chi.URLParam(r, "roleName") oldRole := models.Role{} - ctx := context.WithValue(r.Context(), "roleName", name) + ctx := context.WithValue(r.Context(), roleNameKey, name) if err == nil { oldRole = datastores.Store().Role().GetByID(roleID, dbStore.db) } - ctx = context.WithValue(ctx, "oldRole", oldRole) + ctx = context.WithValue(ctx, oldRoleKey, oldRole) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -63,7 +151,7 @@ func getRoleFromName(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - name := r.Context().Value("roleName").(string) + name := r.Context().Value(roleNameKey).(string) role := store.Role().GetByName(name, db) render.JSON(w, 200, role) } @@ -126,7 +214,7 @@ func updateRole(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - role := r.Context().Value("oldRole").(models.Role) + role := r.Context().Value(oldRoleKey).(models.Role) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { @@ -144,7 +232,7 @@ func updateRole(w http.ResponseWriter, r *http.Request) { } func deleteRole(w http.ResponseWriter, r *http.Request) { - role := r.Context().Value("role").(models.Role) + role := r.Context().Value(oldRoleKey).(models.Role) store := datastores.Store() render := renderPackage.New() message := deleteMessageModel{ diff --git a/api/user_route.go b/api/user_route.go index bb80206..545ff92 100644 --- a/api/user_route.go +++ b/api/user_route.go @@ -12,20 +12,98 @@ import ( renderPackage "github.com/unrolled/render" ) +const ( + userNameKey key = "userName" + nickNameKey key = "nickName" + firstNameKey key = "firstName" + lastNameKey key = "lastName" + userDateKey key = "userDate" + userEmailKey key = "userEmail" + oldUserKey key = "oldUser" +) + func initUserRoute(router chi.Router) { router.Route("/user", func(r chi.Router) { + // swagger:route GET /user Users getAllUser + // + // Get users + // + // This will get all the users available in the organisation. + // + // Responses: + // 200: userArraySuccess + // 503: databaseError + // default: genericError r.Get("/", getAllUser) + // swagger:route POST /user Users newUser + // + // New user + // + // This will create an user for organisation users library. + // + // Responses: + // 200: userObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/", newUser) + // swagger:route GET /user/all Users getAllUser1 + // + // Get users + // + // This will get all the users available in the organisation. + // + // Responses: + // 200: userArraySuccess + // 503: databaseError + // default: genericError r.Get("/all", getAllUser) + // swagger:route POST /user/new Users newUser1 + // + // New user + // + // This will create an user for organisation users library. + // + // Responses: + // 200: userObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/new", newUser) + // swagger:route GET /user/all Users getDeletedUser + // + // Get deleted user + // + // This will get all the deleted users still present in database. + // + // Responses: + // 200: userArraySuccess + // 503: databaseError + // default: genericError r.Get("/deleted", getDeletedUser) + // swagger:route POST /user/role Users getUserFromRole + // + // Get users from its role + // + // This will return the users having provided role. + // + // Responses: + // 200: userArraySuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Post("/role", getUserFromRole) - r.Route("/date/", func(r chi.Router) { - r.Route("/:date", func(r chi.Router) { - r.Use(userContext) - r.Get("/", getUserFromDate) - }) - }) + // swagger:route GET /user/date Users getOrderedByDate + // + // Get user ordered by date + // + // This will get all the users ordered by date. + // + // Responses: + // 200: userArraySuccess + // 503: databaseError + // default: genericError + r.Get("/date", getOrderedByDate) r.Route("/email/", func(r chi.Router) { r.Route("/:userEmail", func(r chi.Router) { r.Use(userContext) @@ -35,30 +113,92 @@ func initUserRoute(router chi.Router) { r.Route("/username/", func(r chi.Router) { r.Route("/:userName", func(r chi.Router) { r.Use(userContext) + // swagger:route GET /user/username/{userName} Users getUserFromName + //y + // Get user from username + // + // This will return the user object corresponding to provided username + // + // Responses: + // 200: userObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getUserFromName) }) }) r.Route("/nickname/", func(r chi.Router) { r.Route("/:nickName", func(r chi.Router) { r.Use(userContext) + // swagger:route GET /user/nickname/{nickName} Users getUserFromNickName + //y + // Get user from nickname + // + // This will return the user object corresponding to provided nickname + // + // Responses: + // 200: userObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getUserFromNickName) }) }) r.Route("/firstname/", func(r chi.Router) { r.Route("/:firstName", func(r chi.Router) { r.Use(userContext) + // swagger:route GET /user/firstname/{firstName} Users getUserFromFirstName + //y + // Get user from firstname + // + // This will return the user object corresponding to provided firstname + // + // Responses: + // 200: userObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getUserFromFirstName) }) }) r.Route("/lastname/", func(r chi.Router) { r.Route("/:lastName", func(r chi.Router) { r.Use(userContext) + // swagger:route GET /user/lastname/{lastName} Users getUserFromLastName + //y + // Get user from lastname + // + // This will return the user object corresponding to provided lastname + // + // Responses: + // 200: userObjectSuccess + // 503: databaseError + // default: genericError r.Get("/", getUserFromLastName) }) }) r.Route("/:userID", func(r chi.Router) { r.Use(userContext) + // swagger:route PUT /user/{userID} Users updateUser + // + // Update user + // + // This will return the new user object + // + // Responses: + // 200: userObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Put("/update", updateUser) + // swagger:route PUT /user/{userID} Users updateUser + // + // Update user + // + // This will return the new user object + // + // Responses: + // 200: userObjectSuccess + // 422: wrongEntity + // 503: databaseError + // default: genericError r.Delete("/delete", deleteUser) }) }) @@ -74,16 +214,16 @@ func userContext(next http.Handler) http.Handler { email := chi.URLParam(r, "email") date, _ := strconv.ParseInt(chi.URLParam(r, "date"), 10, 64) oldUser := models.User{} - ctx := context.WithValue(r.Context(), "userName", name) - ctx = context.WithValue(r.Context(), "nickName", nickName) - ctx = context.WithValue(ctx, "firstName", firstName) - ctx = context.WithValue(ctx, "lastName", lastName) - ctx = context.WithValue(ctx, "email", email) - ctx = context.WithValue(ctx, "date", date) + ctx := context.WithValue(r.Context(), userNameKey, name) + ctx = context.WithValue(r.Context(), nickNameKey, nickName) + ctx = context.WithValue(ctx, firstNameKey, firstName) + ctx = context.WithValue(ctx, lastNameKey, lastName) + ctx = context.WithValue(ctx, userEmailKey, email) + ctx = context.WithValue(ctx, userDateKey, date) if err == nil { oldUser = datastores.Store().User().GetByID(userID, dbStore.db) } - ctx = context.WithValue(ctx, "oldUser", oldUser) + ctx = context.WithValue(ctx, oldUserKey, oldUser) next.ServeHTTP(w, r.WithContext(ctx)) }) } @@ -125,7 +265,7 @@ func getUserFromNickName(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - name := r.Context().Value("nickName").(string) + name := r.Context().Value(nickNameKey).(string) user := store.User().GetByNickName(name, db) render.JSON(w, 200, user) } @@ -134,7 +274,7 @@ func getUserFromFirstName(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - name := r.Context().Value("firstName").(string) + name := r.Context().Value(firstNameKey).(string) user := store.User().GetByFirstName(name, db) render.JSON(w, 200, user) } @@ -143,7 +283,7 @@ func getUserFromLastName(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - name := r.Context().Value("lastName").(string) + name := r.Context().Value(lastNameKey).(string) user := store.User().GetByLastName(name, db) render.JSON(w, 200, user) } @@ -152,16 +292,16 @@ func getUserFromEmail(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - email := r.Context().Value("email").(string) + email := r.Context().Value(userEmailKey).(string) user := store.User().GetByEmail(email, db) render.JSON(w, 200, user) } -func getUserFromDate(w http.ResponseWriter, r *http.Request) { +func getOrderedByDate(w http.ResponseWriter, r *http.Request) { store := datastores.Store() render := renderPackage.New() db := dbStore.db - date := r.Context().Value("date").(int) + date := r.Context().Value(userDateKey).(int) user := store.User().GetOrderedByDate(date, db) render.JSON(w, 200, user) } @@ -224,7 +364,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { db := dbStore.db request := r.Body err := chiRender.Bind(request, &data) - user := r.Context().Value("oldUser").(models.User) + user := r.Context().Value(oldUserKey).(models.User) if err != nil { render.JSON(w, error422.StatusCode, error422) } else { @@ -242,7 +382,7 @@ func updateUser(w http.ResponseWriter, r *http.Request) { } func deleteUser(w http.ResponseWriter, r *http.Request) { - user := r.Context().Value("user").(models.User) + user := r.Context().Value(oldUserKey).(models.User) store := datastores.Store() render := renderPackage.New() message := deleteMessageModel{ diff --git a/swagger.yaml b/swagger.yaml index a19a3a5..acb466e 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -23,9 +23,13 @@ paths: tags: - "Test" description: "Hello World" - operationId: "getter" + operationId: "hello" parameters: [] responses: + 200: + description: "generalOk" + schema: + $ref: "#/definitions/generalOk" default: description: "genericError general error when unexpected errors occured" schema: @@ -61,42 +65,6 @@ paths: description: "This will create an avatar for organisation avatars library." operationId: "newAvatar" parameters: - - in: "body" - name: "avatar" - description: "Link of the avatar in server." - required: false - schema: - $ref: "#/definitions/Avatar" - x-go-name: "Avatar" - responses: - 200: - description: "avatarObjectSuccess list of avatars" - schema: - $ref: "#/definitions/Avatar" - 503: - description: "databaseError is an error object to tell what is happening\ - \ when we encounter issue with database" - schema: - $ref: "#/definitions/genericErrorModel" - default: - description: "genericError general error when unexpected errors occured" - schema: - $ref: "#/definitions/genericErrorModel" - /avatar/:avatarID: - put: - tags: - - "Avatars" - summary: "Update avatar" - description: "This will return the new avatar object" - operationId: "updateAvatar" - parameters: - - name: "avatarID" - in: "path" - description: "Link of the avatar in server." - required: true - type: "integer" - format: "int64" - x-go-name: "AvatarID" - in: "body" name: "avatar" description: "Link of the avatar in server." @@ -123,41 +91,13 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - delete: - tags: - - "Avatars" - summary: "Delete avatar" - description: "This will return an object describing the deletion" - operationId: "deleteAvatar" - parameters: - - name: "avatarID" - in: "path" - description: "Link of the avatar in server." - required: true - type: "integer" - format: "int64" - x-go-name: "AvatarID" - responses: - 200: - description: "deleteMessage" - schema: - $ref: "#/definitions/deleteMessage" - 503: - description: "databaseError is an error object to tell what is happening\ - \ when we encounter issue with database" - schema: - $ref: "#/definitions/genericErrorModel" - default: - description: "genericError general error when unexpected errors occured" - schema: - $ref: "#/definitions/genericErrorModel" /avatar/all: get: tags: - "Avatars" summary: "Get avatars" description: "This will get all the avatars available in the organisation." - operationId: "getAllAvatar" + operationId: "getAllAvatar1" parameters: [] responses: 200: @@ -175,7 +115,7 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /avatar/link/:avatarLink: + /avatar/link/{avatarLink}: get: tags: - "Avatars" @@ -203,7 +143,7 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /avatar/name/:avatarName: + /avatar/name/{avatarName}: get: tags: - "Avatars" @@ -237,7 +177,7 @@ paths: - "Avatars" summary: "New avatar" description: "This will create an avatar for organisation avatars library." - operationId: "newAvatar" + operationId: "newAvatar1" parameters: - in: "body" name: "avatar" @@ -251,30 +191,11 @@ paths: description: "avatarObjectSuccess list of avatars" schema: $ref: "#/definitions/Avatar" - 503: - description: "databaseError is an error object to tell what is happening\ - \ when we encounter issue with database" - schema: - $ref: "#/definitions/genericErrorModel" - default: - description: "genericError general error when unexpected errors occured" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" schema: $ref: "#/definitions/genericErrorModel" - /channel: - get: - tags: - - "Channels" - summary: "Get channels" - description: "This will get all the channels available in the organisation." - operationId: "getAllChannel" - parameters: [] - responses: - 200: - description: "channelSlice Array of channels" - schema: - type: "array" - items: - $ref: "#/definitions/Channel" 503: description: "databaseError is an error object to tell what is happening\ \ when we encounter issue with database" @@ -284,25 +205,33 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - post: + /avatar/{avatarID}: + put: tags: - - "Channels" - summary: "New channel" - description: "This will create an channel for organisation channels library." - operationId: "newChannel" + - "Avatars" + summary: "Update avatar" + description: "This will return the new avatar object" + operationId: "updateAvatar" parameters: + - name: "avatarID" + in: "path" + description: "Link of the avatar in server." + required: true + type: "integer" + format: "int64" + x-go-name: "AvatarID" - in: "body" - name: "channel" - description: "Link of the channel in server." + name: "avatar" + description: "Link of the avatar in server." required: false schema: - $ref: "#/definitions/Channel" - x-go-name: "Channel" + $ref: "#/definitions/Avatar" + x-go-name: "Avatar" responses: 200: - description: "channelObjectSuccess list of channels" + description: "avatarObjectSuccess list of avatars" schema: - $ref: "#/definitions/Channel" + $ref: "#/definitions/Avatar" 422: description: "wrongEntityError is an error object to inform that the provided\ \ object was not correctly formated" @@ -317,38 +246,21 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /channel/:channelID: - put: + /channel: + get: tags: - "Channels" - summary: "Update channel" - description: "This will return the new channel object" - operationId: "updateChannel" - parameters: - - name: "channelID" - in: "path" - description: "Link of the channel in server." - required: true - type: "integer" - format: "int64" - x-go-name: "ChannelID" - - in: "body" - name: "channel" - description: "Link of the channel in server." - required: false - schema: - $ref: "#/definitions/Channel" - x-go-name: "Channel" + summary: "Get channels" + description: "This will get all the channels available in the organisation." + operationId: "getAllChannel" + parameters: [] responses: 200: - description: "channelObjectSuccess list of channels" - schema: - $ref: "#/definitions/Channel" - 422: - description: "wrongEntityError is an error object to inform that the provided\ - \ object was not correctly formated" + description: "channelSlice Array of channels" schema: - $ref: "#/definitions/genericErrorModel" + type: "array" + items: + $ref: "#/definitions/Channel" 503: description: "databaseError is an error object to tell what is happening\ \ when we encounter issue with database" @@ -358,25 +270,30 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - delete: + post: tags: - - "Channels" - summary: "Delete channel" - description: "This will return an object describing the deletion" - operationId: "deleteChannel" + - "Messages" + summary: "Get message from channel" + description: "This will return all mesages in provided channel" + operationId: "getMessageFromChannel" parameters: - - name: "channelID" - in: "path" + - in: "body" + name: "channel" description: "Link of the channel in server." - required: true - type: "integer" - format: "int64" - x-go-name: "ChannelID" + required: false + schema: + $ref: "#/definitions/Channel" + x-go-name: "Channel" responses: 200: - description: "deleteMessage" + description: "messageObjectSuccess list of messages" schema: - $ref: "#/definitions/deleteMessage" + $ref: "#/definitions/Message" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" 503: description: "databaseError is an error object to tell what is happening\ \ when we encounter issue with database" @@ -392,7 +309,7 @@ paths: - "Channels" summary: "Get channels" description: "This will get all the channels available in the organisation." - operationId: "getAllChannel" + operationId: "getAllChannel1" parameters: [] responses: 200: @@ -410,7 +327,7 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /channel/name/:channelName: + /channel/name/{channelName}: get: tags: - "Channels" @@ -444,7 +361,7 @@ paths: - "Channels" summary: "New channel" description: "This will create an channel for organisation channels library." - operationId: "newChannel" + operationId: "newChannel1" parameters: - in: "body" name: "channel" @@ -520,7 +437,7 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /channel/type/:channelType: + /channel/type/{channelType}: get: tags: - "Channels" @@ -551,40 +468,1821 @@ paths: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /panic: - get: + /channel/{channelID}: + put: tags: - - "Test" - summary: "Should result in 500" - description: "Test panic cautching" - operationId: "getter" - parameters: [] + - "Channels" + summary: "Update channel" + description: "This will return the new channel object" + operationId: "updateChannel" + parameters: + - name: "channelID" + in: "path" + description: "Link of the channel in server." + required: true + type: "integer" + format: "int64" + x-go-name: "ChannelID" + - in: "body" + name: "channel" + description: "Link of the channel in server." + required: false + schema: + $ref: "#/definitions/Channel" + x-go-name: "Channel" responses: + 200: + description: "channelObjectSuccess list of channels" + schema: + $ref: "#/definitions/Channel" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" default: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" - /ping: - get: + delete: tags: - - "Test" - summary: "Pong" - description: "Test api ping" - operationId: "getter" - parameters: [] + - "Channels" + summary: "Delete channel" + description: "This will return an object describing the deletion" + operationId: "deleteChannel" + parameters: + - name: "channelID" + in: "path" + description: "Link of the channel in server." + required: true + type: "integer" + format: "int64" + x-go-name: "ChannelID" responses: + 200: + description: "deleteMessage" + schema: + $ref: "#/definitions/deleteMessage" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" default: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" -definitions: - Avatar: - type: "object" - required: - - "link" - - "name" - properties: - id: + /emoji: + get: + tags: + - "Emojis" + summary: "Get emojis" + description: "This will get all the emojis available in the organisation." + operationId: "getAllEmoji" + parameters: [] + responses: + 200: + description: "emojiSlice Array of emojis" + schema: + type: "array" + items: + $ref: "#/definitions/Emoji" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Emojis" + summary: "New emoji" + description: "This will create an emoji for organisation emojis library." + operationId: "newEmoji1" + parameters: + - in: "body" + name: "emoji" + description: "Link of the emoji in server." + required: false + schema: + $ref: "#/definitions/Emoji" + x-go-name: "Emoji" + responses: + 200: + description: "emojiObjectSuccess list of emojis" + schema: + $ref: "#/definitions/Emoji" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /emoji/all: + get: + tags: + - "Emojis" + summary: "Get emojis" + description: "This will get all the emojis available in the organisation." + operationId: "getAllEmoji1" + parameters: [] + responses: + 200: + description: "emojiSlice Array of emojis" + schema: + type: "array" + items: + $ref: "#/definitions/Emoji" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /emoji/link/{emojiLink}: + get: + tags: + - "Emojis" + summary: "Get emoji from link" + description: "This will return the emoji object corresponding to provided link" + operationId: "getEmojiFromLink" + parameters: + - name: "emojiLink" + in: "path" + description: "Link of the emoji in server." + required: true + type: "string" + x-go-name: "EmojiLink" + responses: + 200: + description: "emojiObjectSuccess list of emojis" + schema: + $ref: "#/definitions/Emoji" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /emoji/name/{emojiName}: + get: + tags: + - "Emojis" + summary: "Get emoji from name" + description: "This will return the emoji object corresponding to provided name" + operationId: "getEmojiFromName" + parameters: + - name: "emojiName" + in: "path" + description: "Link of the emoji in server." + required: true + type: "string" + x-go-name: "EmojiName" + responses: + 200: + description: "emojiObjectSuccess list of emojis" + schema: + $ref: "#/definitions/Emoji" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /emoji/shortcut/{emojiShortcut}: + get: + tags: + - "Emojis" + summary: "Get emoji from shortcut" + description: "This will return the emoji object corresponding to provided shortcut" + operationId: "getEmojiFromShortcut" + parameters: + - name: "emojiShortcut" + in: "path" + description: "Link of the emoji in server." + required: true + type: "string" + x-go-name: "EmojiShortcut" + responses: + 200: + description: "emojiObjectSuccess list of emojis" + schema: + $ref: "#/definitions/Emoji" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /emoji/{emojiID}: + put: + tags: + - "Emojis" + summary: "Update emoji" + description: "This will return the new emoji object" + operationId: "updateEmoji" + parameters: + - name: "emojiID" + in: "path" + description: "Link of the emoji in server." + required: true + type: "integer" + format: "int64" + x-go-name: "EmojiID" + - in: "body" + name: "emoji" + description: "Link of the emoji in server." + required: false + schema: + $ref: "#/definitions/Emoji" + x-go-name: "Emoji" + responses: + 200: + description: "avatarObjectSuccess list of avatars" + schema: + $ref: "#/definitions/Avatar" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + delete: + tags: + - "Emojis" + summary: "Delete emoji" + description: "This will return an object describing the deletion" + operationId: "deleteEmoji" + parameters: + - name: "emojiID" + in: "path" + description: "Link of the emoji in server." + required: true + type: "integer" + format: "int64" + x-go-name: "EmojiID" + responses: + 200: + description: "deleteMessage" + schema: + $ref: "#/definitions/deleteMessage" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder: + get: + tags: + - "Folders" + summary: "Get folders" + description: "This will get all the folders available in the organisation." + operationId: "getAllFolder" + parameters: [] + responses: + 200: + description: "folderSlice Array of folders" + schema: + type: "array" + items: + $ref: "#/definitions/Folder" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Folders" + summary: "New folder" + description: "This will create an folder for organisation folders library." + operationId: "newFolder" + parameters: + - in: "body" + name: "folder" + description: "Link of the folder in server." + required: false + schema: + $ref: "#/definitions/Folder" + x-go-name: "Folder" + responses: + 200: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/all: + get: + tags: + - "Folders" + summary: "Get folders" + description: "This will get all the folders available in the organisation." + operationId: "getAllFolder1" + parameters: [] + responses: + 200: + description: "folderSlice Array of folders" + schema: + type: "array" + items: + $ref: "#/definitions/Folder" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/link/{folderLink}: + get: + tags: + - "Folders" + summary: "Get folder from link" + description: "This will return the folder object corresponding to provided link" + operationId: "getFolderFromLink" + parameters: + - name: "folderLink" + in: "path" + description: "Link of the folder in server." + required: true + type: "string" + x-go-name: "FolderLink" + responses: + 200: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/message: + post: + tags: + - "Folders" + summary: "Get folders linked to message" + description: "Return folders linked to provided message." + operationId: "getFolderFromMessage" + parameters: + - in: "body" + name: "message" + description: "Link of the message in server." + required: false + schema: + $ref: "#/definitions/Message" + x-go-name: "Message" + responses: + 200: + description: "folderSlice Array of folders" + schema: + type: "array" + items: + $ref: "#/definitions/Folder" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/name/{folderName}: + get: + tags: + - "Folders" + summary: "Get folder from name" + description: "This will return the folder object corresponding to provided name" + operationId: "getFolderFromName" + parameters: + - name: "folderName" + in: "path" + description: "Link of the folder in server." + required: true + type: "string" + x-go-name: "FolderName" + responses: + 200: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/new: + post: + tags: + - "Folders" + summary: "New folder" + description: "This will create an folder for organisation folders library." + operationId: "newFolder1" + parameters: + - in: "body" + name: "folder" + description: "Link of the folder in server." + required: false + schema: + $ref: "#/definitions/Folder" + x-go-name: "Folder" + responses: + 200: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/type/{folderType}: + get: + tags: + - "Folders" + summary: "Get folder from type" + description: "This will return the folder object corresponding to provided type" + operationId: "getFolderFromType" + parameters: + - name: "folderType" + in: "path" + description: "Link of the folder in server." + required: true + type: "string" + x-go-name: "FolderType" + responses: + 200: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /folder/{folderID}: + put: + tags: + - "Folders" + summary: "Update folder" + description: "This will return the new folder object" + operationId: "updateFolder" + parameters: + - name: "folderID" + in: "path" + description: "Link of the folder in server." + required: true + type: "integer" + format: "int64" + x-go-name: "FolderID" + - in: "body" + name: "folder" + description: "Link of the folder in server." + required: false + schema: + $ref: "#/definitions/Folder" + x-go-name: "Folder" + responses: + 200: + description: "avatarObjectSuccess list of avatars" + schema: + $ref: "#/definitions/Avatar" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + delete: + tags: + - "Folders" + summary: "Delete folder" + description: "This will return an object describing the deletion" + operationId: "deleteFolder" + parameters: + - name: "folderID" + in: "path" + description: "Link of the folder in server." + required: true + type: "integer" + format: "int64" + x-go-name: "FolderID" + responses: + 200: + description: "deleteMessage" + schema: + $ref: "#/definitions/deleteMessage" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /member: + get: + tags: + - "Members" + summary: "Get members" + description: "This will get all the members available in the organisation." + operationId: "getAllMember" + parameters: [] + responses: + 200: + description: "memberSlice Array of members" + schema: + type: "array" + items: + $ref: "#/definitions/Member" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Members" + summary: "New member" + description: "This will create an member for organisation members library." + operationId: "newMember" + parameters: + - in: "body" + name: "member" + description: "Member object" + required: false + schema: + $ref: "#/definitions/Member" + x-go-name: "Member" + responses: + 200: + description: "memberObjectSuccess list of members" + schema: + $ref: "#/definitions/Member" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /member/all: + get: + tags: + - "Members" + summary: "Get members" + description: "This will get all the members available in the organisation." + operationId: "getAllMember1" + parameters: [] + responses: + 200: + description: "memberSlice Array of members" + schema: + type: "array" + items: + $ref: "#/definitions/Member" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /member/new: + post: + tags: + - "Members" + summary: "New member" + description: "This will create an member for organisation members library." + operationId: "newMember1" + parameters: + - in: "body" + name: "member" + description: "Member object" + required: false + schema: + $ref: "#/definitions/Member" + x-go-name: "Member" + responses: + 200: + description: "memberObjectSuccess list of members" + schema: + $ref: "#/definitions/Member" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /member/{memberID}: + put: + tags: + - "Members" + summary: "Update member" + description: "This will return the new member object" + operationId: "updateMember" + parameters: + - name: "memberID" + in: "path" + description: "Link of the member in server." + required: true + type: "integer" + format: "int64" + x-go-name: "MemberID" + responses: + 200: + description: "memberObjectSuccess list of members" + schema: + $ref: "#/definitions/Member" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /message: + get: + tags: + - "Messages" + summary: "Get messages" + description: "This will get all the messages available in the organisation." + operationId: "getAllMessage" + parameters: [] + responses: + 200: + description: "messageSlice Array of messages" + schema: + type: "array" + items: + $ref: "#/definitions/Message" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Messages" + summary: "New message" + description: "This will create an message for organisation messages library." + operationId: "newMessage" + parameters: + - in: "body" + name: "message" + description: "Link of the message in server." + required: false + schema: + $ref: "#/definitions/Message" + x-go-name: "Message" + responses: + 200: + description: "messageObjectSuccess list of messages" + schema: + $ref: "#/definitions/Message" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /message/all: + get: + tags: + - "Messages" + summary: "Get messages" + description: "This will get all the messages available in the organisation." + operationId: "getAllMessage1" + parameters: [] + responses: + 200: + description: "messageSlice Array of messages" + schema: + type: "array" + items: + $ref: "#/definitions/Message" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /message/date/{messageDate}: + get: + tags: + - "Messages" + summary: "Get message from date" + description: "This will return the message object corresponding to provided\ + \ date" + operationId: "getMessageFromDate" + parameters: + - name: "messageDate" + in: "path" + description: "Date of the message" + required: true + type: "integer" + format: "int64" + x-go-name: "MessageDate" + responses: + 200: + description: "messageObjectSuccess list of messages" + schema: + $ref: "#/definitions/Message" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /message/new: + post: + tags: + - "Messages" + summary: "New message" + description: "This will create an message for organisation messages library." + operationId: "newMessage1" + parameters: + - in: "body" + name: "message" + description: "Link of the message in server." + required: false + schema: + $ref: "#/definitions/Message" + x-go-name: "Message" + responses: + 200: + description: "messageObjectSuccess list of messages" + schema: + $ref: "#/definitions/Message" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /message/{messageID}: + put: + tags: + - "Messages" + summary: "Update message" + description: "This will return the new message object" + operationId: "updateMessage" + parameters: + - name: "messageID" + in: "path" + description: "Link of the message in server." + required: true + type: "integer" + format: "int64" + x-go-name: "MessageID" + - in: "body" + name: "message" + description: "Link of the message in server." + required: false + schema: + $ref: "#/definitions/Message" + x-go-name: "Message" + responses: + 200: + description: "messageObjectSuccess list of messages" + schema: + $ref: "#/definitions/Message" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /organisation: + get: + tags: + - "Organisations" + summary: "Get organisations" + description: "This will get all the organisations available in the organisation." + operationId: "getAllOrganisation" + parameters: [] + responses: + 200: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Organisations" + summary: "New organisation" + description: "This will create an organisation for organisation organisations\ + \ library." + operationId: "newOrganisation" + parameters: + - in: "body" + name: "organisation" + description: "Organisation object" + required: false + schema: + $ref: "#/definitions/Organisation" + x-go-name: "Organisation" + responses: + 200: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /organisation/all: + get: + tags: + - "Organisations" + summary: "Get organisations" + description: "This will get all the organisations available in the organisation." + operationId: "getAllOrganisation1" + parameters: [] + responses: + 200: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /organisation/new: + post: + tags: + - "Organisations" + summary: "New organisation" + description: "This will create an organisation for organisation organisations\ + \ library." + operationId: "newOrganisation1" + parameters: + - in: "body" + name: "organisation" + description: "Organisation object" + required: false + schema: + $ref: "#/definitions/Organisation" + x-go-name: "Organisation" + responses: + 200: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /organisation/{organisationID}: + put: + tags: + - "Organisations" + summary: "Get organisation from link" + description: "This will return the organisation object corresponding to provided\ + \ link" + operationId: "updateOrganisation" + parameters: + - name: "organisationID" + in: "path" + description: "Link of the organisation in server." + required: true + type: "integer" + format: "int64" + x-go-name: "OrganisationID" + responses: + 200: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /panic: + get: + tags: + - "Test" + summary: "Should result in 500" + description: "Test panic cautching" + operationId: "panic" + parameters: [] + responses: + 500: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /parameter: + get: + tags: + - "Parameters" + summary: "Get parameters" + description: "This will get all the parameters available in the organisation." + operationId: "getAllParameter" + parameters: [] + responses: + 200: + description: "parameterObjectSuccess list of parameters" + schema: + $ref: "#/definitions/Parameter" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Parameters" + summary: "New parameter" + description: "This will create an parameter for organisation parameters library." + operationId: "newParameter" + parameters: + - in: "body" + name: "parameter" + description: "Parameter object" + required: false + schema: + $ref: "#/definitions/Parameter" + x-go-name: "Parameter" + responses: + 200: + description: "parameterObjectSuccess list of parameters" + schema: + $ref: "#/definitions/Parameter" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /parameter/all: + get: + tags: + - "Parameters" + summary: "Get parameters" + description: "This will get all the parameters available in the organisation." + operationId: "getAllParameter1" + parameters: [] + responses: + 200: + description: "parameterObjectSuccess list of parameters" + schema: + $ref: "#/definitions/Parameter" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /parameter/new: + post: + tags: + - "Parameters" + summary: "New parameter" + description: "This will create an parameter for organisation parameters library." + operationId: "newParameter1" + parameters: + - in: "body" + name: "parameter" + description: "Parameter object" + required: false + schema: + $ref: "#/definitions/Parameter" + x-go-name: "Parameter" + responses: + 200: + description: "parameterObjectSuccess list of parameters" + schema: + $ref: "#/definitions/Parameter" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /parameter/{parameterID}: + put: + tags: + - "Parameters" + summary: "Update parameter" + description: "This will return the new parameter object" + operationId: "updateParameter" + parameters: + - name: "parameterID" + in: "path" + description: "Link of the parameter in server." + required: true + type: "integer" + format: "int64" + x-go-name: "ParameterID" + responses: + 200: + description: "avatarObjectSuccess list of avatars" + schema: + $ref: "#/definitions/Avatar" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /ping: + get: + tags: + - "Test" + summary: "Pong" + description: "Test api ping" + operationId: "ping" + parameters: [] + responses: + 200: + description: "generalOk" + schema: + $ref: "#/definitions/generalOk" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role: + get: + tags: + - "Roles" + summary: "Get roles" + description: "This will get all the roles available in the organisation." + operationId: "getAllRole" + parameters: [] + responses: + 200: + description: "roleSlice Array of roles" + schema: + type: "array" + items: + $ref: "#/definitions/Role" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role/all: + get: + tags: + - "Roles" + summary: "Get roles" + description: "This will get all the roles available in the organisation." + operationId: "getAllRole1" + parameters: [] + responses: + 200: + description: "roleSlice Array of roles" + schema: + type: "array" + items: + $ref: "#/definitions/Role" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role/name/{roleName}: + get: + tags: + - "Roles" + summary: "Get role from name" + description: "This will return the role object corresponding to provided name" + operationId: "getRoleFromName" + parameters: + - name: "roleName" + in: "path" + description: "Link of the role in server." + required: true + type: "string" + x-go-name: "RoleName" + responses: + 200: + description: "roleObjectSuccess list of roles" + schema: + $ref: "#/definitions/Role" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role/new: + post: + tags: + - "Roles" + summary: "New role" + description: "This will create an role for organisation roles library." + operationId: "newRole1" + parameters: + - in: "body" + name: "role" + description: "Role object" + required: false + schema: + $ref: "#/definitions/Role" + x-go-name: "Role" + responses: + 200: + description: "roleObjectSuccess list of roles" + schema: + $ref: "#/definitions/Role" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role/rights: + post: + tags: + - "Roles" + summary: "Get role having provided rights" + description: "Return an array of roles corresponding to rights" + operationId: "getRoleFromRights" + parameters: + - in: "body" + name: "rights" + description: "Right of the role we search" + required: false + schema: + $ref: "#/definitions/rightsParameterModel" + x-go-name: "Rights" + responses: + 200: + description: "roleSlice Array of roles" + schema: + type: "array" + items: + $ref: "#/definitions/Role" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /role/{roleID}: + put: + tags: + - "Roles" + summary: "Update role" + description: "This will return the new role object" + operationId: "updateRole" + parameters: + - name: "roleID" + in: "path" + description: "Link of the role in server." + required: true + type: "integer" + format: "int64" + x-go-name: "RoleID" + - in: "body" + name: "role" + description: "Role object" + required: false + schema: + $ref: "#/definitions/Role" + x-go-name: "Role" + responses: + 200: + description: "avatarObjectSuccess list of avatars" + schema: + $ref: "#/definitions/Avatar" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + delete: + tags: + - "Roles" + summary: "Delete role" + description: "This will return an object describing the deletion" + operationId: "deleteRole" + parameters: + - name: "roleID" + in: "path" + description: "Link of the role in server." + required: true + type: "integer" + format: "int64" + x-go-name: "RoleID" + responses: + 200: + description: "deleteMessage" + schema: + $ref: "#/definitions/deleteMessage" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user: + get: + tags: + - "Users" + summary: "Get users" + description: "This will get all the users available in the organisation." + operationId: "getAllUser" + parameters: [] + responses: + 200: + description: "userSlice Array of users" + schema: + type: "array" + items: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + post: + tags: + - "Users" + summary: "New user" + description: "This will create an user for organisation users library." + operationId: "newUser" + parameters: + - in: "body" + name: "user" + description: "Link of the user in server." + required: false + schema: + $ref: "#/definitions/User" + x-go-name: "User" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/all: + get: + tags: + - "Users" + summary: "Get deleted user" + description: "This will get all the deleted users still present in database." + operationId: "getDeletedUser" + parameters: [] + responses: + 200: + description: "userSlice Array of users" + schema: + type: "array" + items: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/date: + get: + tags: + - "Users" + summary: "Get user ordered by date" + description: "This will get all the users ordered by date." + operationId: "getOrderedByDate" + parameters: [] + responses: + 200: + description: "userSlice Array of users" + schema: + type: "array" + items: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/firstname/{firstName}: + get: + tags: + - "Users" + summary: "y\nGet user from firstname" + description: "This will return the user object corresponding to provided firstname" + operationId: "getUserFromFirstName" + parameters: + - name: "firstName" + in: "path" + description: "Link of the user in server." + required: true + type: "string" + x-go-name: "FirstName" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/lastname/{lastName}: + get: + tags: + - "Users" + summary: "y\nGet user from lastname" + description: "This will return the user object corresponding to provided lastname" + operationId: "getUserFromLastName" + parameters: + - name: "lastName" + in: "path" + description: "Link of the user in server." + required: true + type: "string" + x-go-name: "LastName" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/new: + post: + tags: + - "Users" + summary: "New user" + description: "This will create an user for organisation users library." + operationId: "newUser1" + parameters: + - in: "body" + name: "user" + description: "Link of the user in server." + required: false + schema: + $ref: "#/definitions/User" + x-go-name: "User" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/nickname/{nickName}: + get: + tags: + - "Users" + summary: "y\nGet user from nickname" + description: "This will return the user object corresponding to provided nickname" + operationId: "getUserFromNickName" + parameters: + - name: "nickName" + in: "path" + description: "Link of the user in server." + required: true + type: "string" + x-go-name: "NickName" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/role: + post: + tags: + - "Users" + summary: "Get users from its role" + description: "This will return the users having provided role." + operationId: "getUserFromRole" + parameters: + - in: "body" + name: "role" + description: "Role object" + required: false + schema: + $ref: "#/definitions/Role" + x-go-name: "Role" + responses: + 200: + description: "userSlice Array of users" + schema: + type: "array" + items: + $ref: "#/definitions/User" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/username/{userName}: + get: + tags: + - "Users" + summary: "y\nGet user from username" + description: "This will return the user object corresponding to provided username" + operationId: "getUserFromName" + parameters: + - name: "userName" + in: "path" + description: "Link of the user in server." + required: true + type: "string" + x-go-name: "UserName" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" + /user/{userID}: + put: + tags: + - "Users" + summary: "Update user" + description: "This will return the new user object" + operationId: "updateUser" + parameters: + - name: "userID" + in: "path" + description: "Link of the user in server." + required: true + type: "integer" + format: "int64" + x-go-name: "UserID" + - in: "body" + name: "user" + description: "Link of the user in server." + required: false + schema: + $ref: "#/definitions/User" + x-go-name: "User" + responses: + 200: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" + 422: + description: "wrongEntityError is an error object to inform that the provided\ + \ object was not correctly formated" + schema: + $ref: "#/definitions/genericErrorModel" + 503: + description: "databaseError is an error object to tell what is happening\ + \ when we encounter issue with database" + schema: + $ref: "#/definitions/genericErrorModel" + default: + description: "genericError general error when unexpected errors occured" + schema: + $ref: "#/definitions/genericErrorModel" +definitions: + Avatar: + type: "object" + required: + - "link" + - "name" + properties: + id: type: "integer" format: "uint64" description: "id of the avatar" @@ -991,6 +2689,38 @@ definitions: $ref: "#/definitions/Avatar" description: "avatarSlice Array of avatars" x-go-package: "github.com/titouanfreville/popcubeapi/api" + avatarIDParam: + type: "object" + properties: + avatarID: + type: "integer" + format: "int64" + description: "Link of the avatar in server.\nin:path" + x-go-name: "AvatarID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + avatarLinkParam: + type: "object" + properties: + avatarLink: + type: "string" + description: "Link of the avatar in server.\nin:path" + x-go-name: "AvatarLink" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + avatarNameParam: + type: "object" + properties: + avatarName: + type: "string" + description: "Link of the avatar in server.\nin:path" + x-go-name: "AvatarName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + avatarObjectParam: + type: "object" + properties: + avatar: + description: "Link of the avatar in server.\nin:body" + $ref: "#/definitions/Avatar" + x-go-package: "github.com/titouanfreville/popcubeapi/api" avatarObjectSuccess: type: "object" properties: @@ -1009,6 +2739,30 @@ definitions: $ref: "#/definitions/Channel" description: "channelSlice Array of channels" x-go-package: "github.com/titouanfreville/popcubeapi/api" + channelIDParam: + type: "object" + properties: + channelID: + type: "integer" + format: "int64" + description: "Link of the channel in server.\nin:path" + x-go-name: "ChannelID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + channelNameParam: + type: "object" + properties: + channelName: + type: "string" + description: "Link of the channel in server.\nin:path" + x-go-name: "ChannelName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + channelObjectParam: + type: "object" + properties: + channel: + description: "Link of the channel in server.\nin:body" + $ref: "#/definitions/Channel" + x-go-package: "github.com/titouanfreville/popcubeapi/api" channelObjectSuccess: type: "object" properties: @@ -1017,6 +2771,14 @@ definitions: $ref: "#/definitions/Channel" description: "channelObjectSuccess list of channels" x-go-package: "github.com/titouanfreville/popcubeapi/api" + channelTypeParam: + type: "object" + properties: + channelType: + type: "string" + description: "Link of the channel in server.\nin:path" + x-go-name: "ChannelType" + x-go-package: "github.com/titouanfreville/popcubeapi/api" databaseError: type: "object" properties: @@ -1057,6 +2819,130 @@ definitions: x-go-name: "Success" title: "deleteMessageModel is an object to confirm correct deletion of an item." x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiArraySuccess: + type: "object" + properties: + Emojis: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/Emoji" + description: "emojiSlice Array of emojis" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiIDParam: + type: "object" + properties: + emojiID: + type: "integer" + format: "int64" + description: "Link of the emoji in server.\nin:path" + x-go-name: "EmojiID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiLinkParam: + type: "object" + properties: + emojiLink: + type: "string" + description: "Link of the emoji in server.\nin:path" + x-go-name: "EmojiLink" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiNameParam: + type: "object" + properties: + emojiName: + type: "string" + description: "Link of the emoji in server.\nin:path" + x-go-name: "EmojiName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiObjectParam: + type: "object" + properties: + emoji: + description: "Link of the emoji in server.\nin:body" + $ref: "#/definitions/Emoji" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiObjectSuccess: + type: "object" + properties: + emoji: + description: "in:body\nList of emojis returned" + $ref: "#/definitions/Emoji" + description: "emojiObjectSuccess list of emojis" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + emojiShortcutParam: + type: "object" + properties: + emojiShortcut: + type: "string" + description: "Link of the emoji in server.\nin:path" + x-go-name: "EmojiShortcut" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + firstNameParam: + type: "object" + properties: + firstName: + type: "string" + description: "Link of the user in server.\nin:path" + x-go-name: "FirstName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderArraySuccess: + type: "object" + properties: + Folders: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/Folder" + description: "folderSlice Array of folders" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderIDParam: + type: "object" + properties: + folderID: + type: "integer" + format: "int64" + description: "Link of the folder in server.\nin:path" + x-go-name: "FolderID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderLinkParam: + type: "object" + properties: + folderLink: + type: "string" + description: "Link of the folder in server.\nin:path" + x-go-name: "FolderLink" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderNameParam: + type: "object" + properties: + folderName: + type: "string" + description: "Link of the folder in server.\nin:path" + x-go-name: "FolderName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderObjectParam: + type: "object" + properties: + folder: + description: "Link of the folder in server.\nin:body" + $ref: "#/definitions/Folder" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderObjectSuccess: + type: "object" + properties: + folder: + description: "in:body\nList of folders returned" + $ref: "#/definitions/Folder" + description: "folderObjectSuccess list of folders" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + folderTypeParam: + type: "object" + properties: + folderType: + type: "string" + description: "Link of the folder in server.\nin:path" + x-go-name: "FolderType" + x-go-package: "github.com/titouanfreville/popcubeapi/api" generalOk: type: "object" properties: @@ -1104,6 +2990,267 @@ definitions: title: "AppError Type used to structure error reporting for popcube chat project." x-go-name: "AppError" x-go-package: "github.com/titouanfreville/popcubeapi/utils" + lastNameeParam: + type: "object" + properties: + lastName: + type: "string" + description: "Link of the user in server.\nin:path" + x-go-name: "LastName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + memberArraySuccess: + type: "object" + properties: + Members: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/Member" + description: "memberSlice Array of members" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + memberIDParam: + type: "object" + properties: + memberID: + type: "integer" + format: "int64" + description: "Link of the member in server.\nin:path" + x-go-name: "MemberID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + memberObjectParam: + type: "object" + properties: + member: + description: "Member object\nin:body" + $ref: "#/definitions/Member" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + memberObjectSuccess: + type: "object" + properties: + member: + description: "in:body\nList of members returned" + $ref: "#/definitions/Member" + description: "memberObjectSuccess list of members" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + messageArraySuccess: + type: "object" + properties: + Messages: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/Message" + description: "messageSlice Array of messages" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + messageDate: + type: "object" + properties: + messageDate: + type: "integer" + format: "int64" + description: "Date of the message\nin:path" + x-go-name: "MessageDate" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + messageIDParam: + type: "object" + properties: + messageID: + type: "integer" + format: "int64" + description: "Link of the message in server.\nin:path" + x-go-name: "MessageID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + messageObjectParam: + type: "object" + properties: + message: + description: "Link of the message in server.\nin:body" + $ref: "#/definitions/Message" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + messageObjectSuccess: + type: "object" + properties: + message: + description: "in:body\nList of messages returned" + $ref: "#/definitions/Message" + description: "messageObjectSuccess list of messages" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + nickNameParam: + type: "object" + properties: + nickName: + type: "string" + description: "Link of the user in server.\nin:path" + x-go-name: "NickName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + organisationIDParam: + type: "object" + properties: + organisationID: + type: "integer" + format: "int64" + description: "Link of the organisation in server.\nin:path" + x-go-name: "OrganisationID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + organisationObjectParam: + type: "object" + properties: + organisation: + description: "Organisation object\nin:body" + $ref: "#/definitions/Organisation" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + organisationObjectSuccess: + type: "object" + properties: + organisation: + description: "in:body\nList of organisations returned" + $ref: "#/definitions/Organisation" + description: "organisationObjectSuccess list of organisations" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + parameterIDParam: + type: "object" + properties: + parameterID: + type: "integer" + format: "int64" + description: "Link of the parameter in server.\nin:path" + x-go-name: "ParameterID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + parameterObjectParam: + type: "object" + properties: + parameter: + description: "Parameter object\nin:body" + $ref: "#/definitions/Parameter" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + parameterObjectSuccess: + type: "object" + properties: + parameter: + description: "in:body\nList of parameters returned" + $ref: "#/definitions/Parameter" + description: "parameterObjectSuccess list of parameters" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + rightsObjectParam: + type: "object" + properties: + rights: + description: "Right of the role we search\nin:body" + $ref: "#/definitions/rightsParameterModel" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + rightsParameterModel: + type: "object" + properties: + can_archive: + type: "boolean" + description: "User can archive channels" + x-go-name: "CanArchive" + can_invite: + type: "boolean" + description: "User can invite others to private channel or organisation" + x-go-name: "CanInvite" + can_manage: + type: "boolean" + description: "User can manage organisation/channel parameters and data" + x-go-name: "CanManage" + can_manage_user: + type: "boolean" + description: "User can manage other organisation/channel user" + x-go-name: "CanManageUser" + can_moderate: + type: "boolean" + description: "User can moderate channels" + x-go-name: "CanModerate" + can_use_private: + type: "boolean" + description: "User can use private channel" + x-go-name: "CanUsePrivate" + title: "rightsParameterModel is the object you can pass to get roles from rights." + x-go-package: "github.com/titouanfreville/popcubeapi/api" + roleArraySuccess: + type: "object" + properties: + Roles: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/Role" + description: "roleSlice Array of roles" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + roleIDParam: + type: "object" + properties: + roleID: + type: "integer" + format: "int64" + description: "Link of the role in server.\nin:path" + x-go-name: "RoleID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + roleNameParam: + type: "object" + properties: + roleName: + type: "string" + description: "Link of the role in server.\nin:path" + x-go-name: "RoleName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + roleObjectParam: + type: "object" + properties: + role: + description: "Role object\nin:body" + $ref: "#/definitions/Role" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + roleObjectSuccess: + type: "object" + properties: + role: + description: "in:body\nList of roles returned" + $ref: "#/definitions/Role" + description: "roleObjectSuccess list of roles" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + userArraySuccess: + type: "object" + properties: + Users: + type: "array" + description: "in:body" + items: + $ref: "#/definitions/User" + description: "userSlice Array of users" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + userIDParam: + type: "object" + properties: + userID: + type: "integer" + format: "int64" + description: "Link of the user in server.\nin:path" + x-go-name: "UserID" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + userNameParam: + type: "object" + properties: + userName: + type: "string" + description: "Link of the user in server.\nin:path" + x-go-name: "UserName" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + userObjectParam: + type: "object" + properties: + user: + description: "Link of the user in server.\nin:body" + $ref: "#/definitions/User" + x-go-package: "github.com/titouanfreville/popcubeapi/api" + userObjectSuccess: + type: "object" + properties: + user: + description: "in:body\nList of users returned" + $ref: "#/definitions/User" + description: "userObjectSuccess list of users" + x-go-package: "github.com/titouanfreville/popcubeapi/api" wrongEntityError: type: "object" properties: @@ -1141,10 +3288,78 @@ responses: $ref: "#/definitions/genericErrorModel" defaultOk: description: "generalOk default object style to return if correct" + emojiArraySuccess: + description: "emojiSlice Array of emojis" + schema: + type: "array" + items: + $ref: "#/definitions/Emoji" + emojiObjectSuccess: + description: "emojiObjectSuccess list of emojis" + schema: + $ref: "#/definitions/Emoji" + folderArraySuccess: + description: "folderSlice Array of folders" + schema: + type: "array" + items: + $ref: "#/definitions/Folder" + folderObjectSuccess: + description: "folderObjectSuccess list of folders" + schema: + $ref: "#/definitions/Folder" genericError: description: "genericError general error when unexpected errors occured" schema: $ref: "#/definitions/genericErrorModel" + memberArraySuccess: + description: "memberSlice Array of members" + schema: + type: "array" + items: + $ref: "#/definitions/Member" + memberObjectSuccess: + description: "memberObjectSuccess list of members" + schema: + $ref: "#/definitions/Member" + messageArraySuccess: + description: "messageSlice Array of messages" + schema: + type: "array" + items: + $ref: "#/definitions/Message" + messageObjectSuccess: + description: "messageObjectSuccess list of messages" + schema: + $ref: "#/definitions/Message" + organisationObjectSuccess: + description: "organisationObjectSuccess list of organisations" + schema: + $ref: "#/definitions/Organisation" + parameterObjectSuccess: + description: "parameterObjectSuccess list of parameters" + schema: + $ref: "#/definitions/Parameter" + roleArraySuccess: + description: "roleSlice Array of roles" + schema: + type: "array" + items: + $ref: "#/definitions/Role" + roleObjectSuccess: + description: "roleObjectSuccess list of roles" + schema: + $ref: "#/definitions/Role" + userArraySuccess: + description: "userSlice Array of users" + schema: + type: "array" + items: + $ref: "#/definitions/User" + userObjectSuccess: + description: "userObjectSuccess list of users" + schema: + $ref: "#/definitions/User" wrongEntity: description: "wrongEntityError is an error object to inform that the provided\ \ object was not correctly formated"