From 9d1306f36ceef1d4d7d3911f2484ebe5ce9f962a Mon Sep 17 00:00:00 2001 From: Kavika Date: Sat, 6 Apr 2024 12:42:16 +1100 Subject: [PATCH 1/8] feat(docs): updates to user and organisation api spec --- backend/api.yaml | 170 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 165 insertions(+), 5 deletions(-) diff --git a/backend/api.yaml b/backend/api.yaml index c6567fc9..e53f6576 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -234,6 +234,44 @@ paths: error: type: string example: Not logged in. + /organisation: + post: + description: Creates a new organisation. + tags: + - Organisation + requestBody: + required: true + content: + application/json: + schema: + properties: + name: + type: string + example: "UNSW Software Development Society" + admin: + type: integer + format: int64 + example: 1541815603606036480 + description: User ID of admin + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully created organisation. + '403': + description: User is not a super user. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized /organisation/{id}: get: parameters: @@ -267,6 +305,37 @@ paths: created_at: type: string example: 2024-02-10T18:25:43.511Z + delete: + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Deletes specified organisation. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully deleted organisation. + '403': + description: User is not a super user. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized /organisation/{id}/campaigns: get: parameters: @@ -331,9 +400,10 @@ paths: application/json: schema: properties: - message: + upload_url: type: string - example: Successfully updated logo. + description: Presigned S3 url to upload file. + example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host '401': description: Not logged in. content: @@ -351,8 +421,48 @@ paths: properties: error: type: string - example: Unauthorised. + example: Unauthorized /organisation/{id}/members: + get: + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Returns list of members of specified organisation. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + members: + type: array + items: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + name: + type: string + example: Clancy Lion + '403': + description: User is not an organisation admin or member. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized put: parameters: - name: id @@ -370,8 +480,8 @@ paths: properties: members: type: array + uniqueItems: true items: - uniqueItems: true type: integer format: int64 example: [1541815603606036480, 1541815603606036827, 1541815287306036429] @@ -405,4 +515,54 @@ paths: properties: error: type: string - example: Unauthorised. \ No newline at end of file + example: Unauthorized + /organisation/{id}/campaign: + post: + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Creates a new campaign inside specified organisation. + tags: + - Organisation + requestBody: + required: true + content: + application/json: + schema: + properties: + name: + type: string + example: 2024 Subcommittee Recruitment + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully created campaign. + '403': + description: User is not an admin of specified organisation. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized \ No newline at end of file From 0a4105acec63c38059eb5bce4d3dd02769ed1be7 Mon Sep 17 00:00:00 2001 From: Kavika Date: Sat, 6 Apr 2024 13:17:34 +1100 Subject: [PATCH 2/8] feat(docs): draft spec for campaign api --- backend/api.yaml | 235 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) diff --git a/backend/api.yaml b/backend/api.yaml index e53f6576..cb80ef4f 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -9,6 +9,21 @@ servers: description: Local server paths: + /auth/logout: + post: + description: Invalidates current token. + tags: + - Auth + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + messages: + type: string + example: Successfully logged out. /user: get: description: Returns info about currently logged in user. @@ -559,6 +574,226 @@ paths: example: Successfully created campaign. '403': description: User is not an admin of specified organisation. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + /campaign: + get: + description: Returns all active campaigns. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + campaigns: + type: array + items: + type: object + properties: + id: + type: integer + format: int64 + example: 6996987893965262849 + organisation_id: + type: integer + format: int64 + example: 1541815603606036827 + organisation_name: + type: string + example: UNSW Software Development Society + name: + type: string + example: 2024 Subcommittee Recruitment + cover_image: + type: string + example: 2d19617b-46fd-4927-9f53-77d69232ba5d + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + /campaign/{id}: + get: + parameters: + - name: id + in: path + description: Campaign ID + required: true + schema: + type: integer + format: int64 + description: Returns info about specified campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + id: + type: integer + format: int64 + example: 6996987893965262849 + organisation_id: + type: integer + format: int64 + example: 1541815603606036827 + organisation_name: + type: string + example: UNSW Software Development Society + name: + type: string + example: 2024 Subcommittee Recruitment + cover_image: + type: string + example: 2d19617b-46fd-4927-9f53-77d69232ba5d + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + put: + parameters: + - name: id + in: path + description: Campaign ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + name: + type: string + example: 2024 Subcommittee Recruitment + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + description: Updates details of specified campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated campaign. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an organisation admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + delete: + parameters: + - name: id + in: path + description: Campaign ID + required: true + schema: + type: integer + format: int64 + description: Deletes specified campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully deleted campaign. + '403': + description: User is not an admin of campaign's organisation. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + /campaign/{id}/banner: + patch: + parameters: + - name: id + in: path + description: Campaign ID + required: true + schema: + type: integer + format: int64 + description: Updates banner image for specified campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + upload_url: + type: string + description: Presigned S3 url to upload file. + example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an organisation admin. content: application/json: schema: From ac0eb77bbfa750da9e3b1452dd3612785bf2d4d0 Mon Sep 17 00:00:00 2001 From: Kavika Date: Sat, 6 Apr 2024 13:22:27 +1100 Subject: [PATCH 3/8] fix(ci): update rust workflow to use actions/cache --- .github/workflows/rust.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fe8c05d7..59dc859e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,6 +3,9 @@ name: Rust on: pull_request: branches: [main, "renovate/*", "CHAOS-224-KHAOS-rewrite"] + paths: + - backend/server/** + - backend/prisma-cli/** push: branches: ["renovate/*"] @@ -37,11 +40,18 @@ jobs: with: profile: minimal toolchain: stable - - uses: Swatinem/rust-cache@v2 + - name: Setup cargo cache + uses: actions/cache@v3 with: - workspaces: | - prisma-cli - server + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + backend/prisma-cli/target/ + backend/server/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- - name: Migrate DB working-directory: backend/prisma-cli run: cargo run db push From 1acf31b402144af7e6178a7fc004d1b17efeaf39 Mon Sep 17 00:00:00 2001 From: Alex_Miao_WSL Date: Wed, 25 Sep 2024 17:04:55 +1000 Subject: [PATCH 4/8] rewrite API yamal file using components/schema up to /api/v1/role/:role_id --- backend/api.yaml | 514 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 471 insertions(+), 43 deletions(-) diff --git a/backend/api.yaml b/backend/api.yaml index 8b3f9ef2..89b0fc3a 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -136,6 +136,12 @@ paths: name: type: string example: Clancy Lion + pronouns: + type: string + example: They/Them + gender: + type: string + example: Male degree_name: type: string example: Computer Science @@ -185,6 +191,75 @@ paths: error: type: string example: Not logged in. + + /user/pronouns: + patch: + operationId: updateUserPronouns + description: Updates currently logged in user's pronouns. + tags: + - User + requestBody: + required: true + content: + application/json: + schema: + properties: + zid: + type: string + example: "z5123456" + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated pronouns. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + /user/gender: + patch: + operationId: updateUserGender + description: Updates currently logged in user's gender. + tags: + - User + requestBody: + required: true + content: + application/json: + schema: + properties: + zid: + type: string + example: "z5123456" + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated gender. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. /user/zid: patch: operationId: updateUserZid @@ -256,6 +331,26 @@ paths: error: type: string example: Not logged in. + /user/applications: + get: + operationId: getUserApplications + description: Returns info about applications made by currently logged in user. + tags: + - User + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + campaigns: + type: array + items: + $ref: '#/components/schemas/ApplicationDetails' + + + /organisation: post: operationId: createOrganisation @@ -385,27 +480,7 @@ paths: campaigns: type: array items: - type: object - properties: - id: - type: integer - format: int64 - example: 6996987893965262849 - name: - type: string - example: 2024 Subcommittee Recruitment - cover_image: - type: string - example: 2d19617b-46fd-4927-9f53-77d69232ba5d - description: - type: string - example: Are you excited to make a difference? - starts_at: - type: string - example: 2024-03-15T18:25:43.511Z - ends_at: - type: string - example: 2024-04-15T18:25:43.511Z + $ref: '#/components/schemas/OrganisationCampaign' /organisation/{id}/logo: patch: operationId: updateOrganisationLogoById @@ -449,7 +524,8 @@ paths: error: type: string example: Unauthorized - /organisation/{id}/members: + + /organisation/{id}/member: get: operationId: getOrganisationMembersById parameters: @@ -548,6 +624,210 @@ paths: error: type: string example: Unauthorized + delete: + operationId: deleteOrganisationMemberById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + user_id: + type: integer + format: int64 + description: Specifies member for deletion in organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated members. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an organisation admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + /organisation/{id}/admin: + get: + operationId: getOrganisationAdminsById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Returns list of admins of specified organisation. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + members: + type: array + items: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + name: + type: string + example: Clancy Lion + role: + type: string + example: Admin + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + put: + operationId: updateOrganisationAdminsById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + members: + type: array + uniqueItems: true + items: + type: integer + format: int64 + example: [1541815603606036480, 1541815603606036827, 1541815287306036429] + description: Specifies Admins for specified organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated members. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + delete: + operationId: deleteOrganisationAdminById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + user_id: + type: integer + format: int64 + description: Specifies Admin for deletion in organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully deleted Admin. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + + + /organisation/{id}/campaign: post: operationId: createCampaign @@ -904,26 +1184,49 @@ paths: schema: properties: campaigns: + type: array + items: + $ref: '#components/schemas/RoleDetails' + + /campaign/{id}/applications: + get: + operationId: getApplicationsById + parameters: + - name: id + in: path + description: campaign ID + required: true + schema: + type: integer + format: int64 + description: Returns info about all Applications in given Campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + applications: type: array items: type: object properties: - name: - type: string - example: Chief Mouser - description: - type: string - example: Larry the cat gone missing! now we need someone else to handle the rat issues at 10th Downing st. - min_available: - type: int32 - example: 1 - max_available: - type: int32 - example: 3 - finalised: - type: boolean - description: Whether this role has been finalised (e.g. max avaliable number) - example: False + id: + type: int64 + example: 6996987893965262849 + campaign_id: + type: int64 + example: 6956987893465262847 + user: + $ref: '#/components/schemas/UserDetails' + status: + private_status: + applied_roles: + + /role/{id}: get: operationId: getRoleById @@ -934,7 +1237,7 @@ paths: required: true schema: type: integer - format: int32 + format: int64 description: Returns info about specified role. tags: - Role @@ -973,14 +1276,14 @@ paths: put: operationId: updateRoleById - parameters: + parameters: - name: id in: path description: Role ID required: true schema: type: integer - format: int32 + format: int64 description: Update a role given the role id. tags: - Role @@ -1036,7 +1339,7 @@ paths: required: true schema: type: integer - format: int32 + format: int64 description: Deletes specified role. tags: - Role @@ -1058,4 +1361,129 @@ paths: properties: error: type: string - example: Unauthorized \ No newline at end of file + example: Unauthorized + + + + +components: + schemas: + ApplicationStatus: + type: string + enum: + - Pending + - Rejected + - Successful + + OrganisationCampaign: + type: object + properties: + id: + type: integer + format: int64 + example: 6996987893965262849 + name: + type: string + example: 2024 Subcommittee Recruitment + cover_image: + type: string + example: 2d19617b-46fd-4927-9f53-77d69232ba5d + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + + RoleDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 7036987893965262849 + campaign_id: + type: integer + format: int64 + example: 1116987453965262849 + name: + type: string + example: Chief Mouser + description: + type: string + example: Larry the cat gone missing! now we need someone else to handle the rat issues at 10th Downing st. + min_available: + type: int32 + example: 1 + max_available: + type: int32 + example: 3 + finalised: + type: boolean + description: Whether this role has been finalised (e.g. max avaliable number) + example: False + + UserDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + email: + type: string + example: me@example.com + zid: + type: string + example: z5555555 + name: + type: string + example: Clancy Lion + pronouns: + type: string + example: They/Them + gender: + type: string + example: Male + degree_name: + type: string + example: Computer Science + degree_starting_year: + type: integer + example: 2024 + + ApplicationDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + campaign_id: + type: integer + format: int64 + example: 5141815603606036480 + user: + $ref: '#/components/schemas/UserDetails' + status: + $ref: '#/components/schemas/ApplicationStatus' + private_status: + $ref: '#/components/schemas/ApplicationStatus' + applied_roles: + type: array + items: + $ref: '#/components/schemas/ApplicationAppliedRoleDetails' + + ApplicationAppliedRoleDetails: + type: object + properties: + campaign_role_id: + type: integer + format: int64 + example: 1541815603606036480 + role_name: + type: String + example: UI/UX subcom \ No newline at end of file From 79cc9f0f0a8c97748d69ff456e7b99aec9be58df Mon Sep 17 00:00:00 2001 From: Alex_Miao_WSL Date: Wed, 25 Sep 2024 18:03:22 +1000 Subject: [PATCH 5/8] rewrite API yamal file using components/schema up to /api/v1/role/:role_id I guess --- backend/api.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/api.yaml b/backend/api.yaml index 89b0fc3a..85697590 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -505,7 +505,7 @@ paths: upload_url: type: string description: Presigned S3 url to upload file. - example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host + example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: @@ -1085,7 +1085,7 @@ paths: upload_url: type: string description: Presigned S3 url to upload file. - example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host + example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: From fab37c461f5720191cae88624f8962423d532106 Mon Sep 17 00:00:00 2001 From: Alex Miao <79033892+AlexMIaoPU@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:05:53 +1000 Subject: [PATCH 6/8] rewrite API yamal file using components/schema up to /api/v1/role/:role_id I guess --- backend/api.yaml | 518 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 473 insertions(+), 45 deletions(-) diff --git a/backend/api.yaml b/backend/api.yaml index 8b3f9ef2..1387dbbe 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -136,6 +136,12 @@ paths: name: type: string example: Clancy Lion + pronouns: + type: string + example: They/Them + gender: + type: string + example: Male degree_name: type: string example: Computer Science @@ -185,6 +191,75 @@ paths: error: type: string example: Not logged in. + + /user/pronouns: + patch: + operationId: updateUserPronouns + description: Updates currently logged in user's pronouns. + tags: + - User + requestBody: + required: true + content: + application/json: + schema: + properties: + zid: + type: string + example: "z5123456" + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated pronouns. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + /user/gender: + patch: + operationId: updateUserGender + description: Updates currently logged in user's gender. + tags: + - User + requestBody: + required: true + content: + application/json: + schema: + properties: + zid: + type: string + example: "z5123456" + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated gender. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. /user/zid: patch: operationId: updateUserZid @@ -256,6 +331,26 @@ paths: error: type: string example: Not logged in. + /user/applications: + get: + operationId: getUserApplications + description: Returns info about applications made by currently logged in user. + tags: + - User + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + campaigns: + type: array + items: + $ref: '#/components/schemas/ApplicationDetails' + + + /organisation: post: operationId: createOrganisation @@ -385,27 +480,7 @@ paths: campaigns: type: array items: - type: object - properties: - id: - type: integer - format: int64 - example: 6996987893965262849 - name: - type: string - example: 2024 Subcommittee Recruitment - cover_image: - type: string - example: 2d19617b-46fd-4927-9f53-77d69232ba5d - description: - type: string - example: Are you excited to make a difference? - starts_at: - type: string - example: 2024-03-15T18:25:43.511Z - ends_at: - type: string - example: 2024-04-15T18:25:43.511Z + $ref: '#/components/schemas/OrganisationCampaign' /organisation/{id}/logo: patch: operationId: updateOrganisationLogoById @@ -430,7 +505,7 @@ paths: upload_url: type: string description: Presigned S3 url to upload file. - example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host + example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: @@ -449,7 +524,8 @@ paths: error: type: string example: Unauthorized - /organisation/{id}/members: + + /organisation/{id}/member: get: operationId: getOrganisationMembersById parameters: @@ -548,6 +624,210 @@ paths: error: type: string example: Unauthorized + delete: + operationId: deleteOrganisationMemberById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + user_id: + type: integer + format: int64 + description: Specifies member for deletion in organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated members. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an organisation admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + /organisation/{id}/admin: + get: + operationId: getOrganisationAdminsById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + description: Returns list of admins of specified organisation. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + members: + type: array + items: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + name: + type: string + example: Clancy Lion + role: + type: string + example: Admin + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + put: + operationId: updateOrganisationAdminsById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + members: + type: array + uniqueItems: true + items: + type: integer + format: int64 + example: [1541815603606036480, 1541815603606036827, 1541815287306036429] + description: Specifies Admins for specified organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated members. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + delete: + operationId: deleteOrganisationAdminById + parameters: + - name: id + in: path + description: Organisation ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + user_id: + type: integer + format: int64 + description: Specifies Admin for deletion in organistion. + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully deleted Admin. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not a SuperUser. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + + + /organisation/{id}/campaign: post: operationId: createCampaign @@ -805,7 +1085,7 @@ paths: upload_url: type: string description: Presigned S3 url to upload file. - example: https://presignedurldemo.s3.eu-west-2.amazonaws.com/6996987893965262849/2d19617b-46fd-4927-9f53-77d69232ba5d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJJWZ7B6WCRGMKFGQ%2F20180210%2Feu-west-2%2Fs3%2Faws4_request&X-Amz-Date=20180210T171315Z&X-Amz-Expires=1800&X-Amz-Signature=12b74b0788aa036bc7c3d03b3f20c61f1f91cc9ad8873e3314255dc479a25351&X-Amz-SignedHeaders=host + example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: @@ -904,26 +1184,49 @@ paths: schema: properties: campaigns: + type: array + items: + $ref: '#components/schemas/RoleDetails' + + /campaign/{id}/applications: + get: + operationId: getApplicationsById + parameters: + - name: id + in: path + description: campaign ID + required: true + schema: + type: integer + format: int64 + description: Returns info about all Applications in given Campaign. + tags: + - Campaign + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + applications: type: array items: type: object properties: - name: - type: string - example: Chief Mouser - description: - type: string - example: Larry the cat gone missing! now we need someone else to handle the rat issues at 10th Downing st. - min_available: - type: int32 - example: 1 - max_available: - type: int32 - example: 3 - finalised: - type: boolean - description: Whether this role has been finalised (e.g. max avaliable number) - example: False + id: + type: int64 + example: 6996987893965262849 + campaign_id: + type: int64 + example: 6956987893465262847 + user: + $ref: '#/components/schemas/UserDetails' + status: + private_status: + applied_roles: + + /role/{id}: get: operationId: getRoleById @@ -934,7 +1237,7 @@ paths: required: true schema: type: integer - format: int32 + format: int64 description: Returns info about specified role. tags: - Role @@ -973,14 +1276,14 @@ paths: put: operationId: updateRoleById - parameters: + parameters: - name: id in: path description: Role ID required: true schema: type: integer - format: int32 + format: int64 description: Update a role given the role id. tags: - Role @@ -1036,7 +1339,7 @@ paths: required: true schema: type: integer - format: int32 + format: int64 description: Deletes specified role. tags: - Role @@ -1058,4 +1361,129 @@ paths: properties: error: type: string - example: Unauthorized \ No newline at end of file + example: Unauthorized + + + + +components: + schemas: + ApplicationStatus: + type: string + enum: + - Pending + - Rejected + - Successful + + OrganisationCampaign: + type: object + properties: + id: + type: integer + format: int64 + example: 6996987893965262849 + name: + type: string + example: 2024 Subcommittee Recruitment + cover_image: + type: string + example: 2d19617b-46fd-4927-9f53-77d69232ba5d + description: + type: string + example: Are you excited to make a difference? + starts_at: + type: string + example: 2024-03-15T18:25:43.511Z + ends_at: + type: string + example: 2024-04-15T18:25:43.511Z + + RoleDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 7036987893965262849 + campaign_id: + type: integer + format: int64 + example: 1116987453965262849 + name: + type: string + example: Chief Mouser + description: + type: string + example: Larry the cat gone missing! now we need someone else to handle the rat issues at 10th Downing st. + min_available: + type: int32 + example: 1 + max_available: + type: int32 + example: 3 + finalised: + type: boolean + description: Whether this role has been finalised (e.g. max avaliable number) + example: False + + UserDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + email: + type: string + example: me@example.com + zid: + type: string + example: z5555555 + name: + type: string + example: Clancy Lion + pronouns: + type: string + example: They/Them + gender: + type: string + example: Male + degree_name: + type: string + example: Computer Science + degree_starting_year: + type: integer + example: 2024 + + ApplicationDetails: + type: object + properties: + id: + type: integer + format: int64 + example: 1541815603606036480 + campaign_id: + type: integer + format: int64 + example: 5141815603606036480 + user: + $ref: '#/components/schemas/UserDetails' + status: + $ref: '#/components/schemas/ApplicationStatus' + private_status: + $ref: '#/components/schemas/ApplicationStatus' + applied_roles: + type: array + items: + $ref: '#/components/schemas/ApplicationAppliedRoleDetails' + + ApplicationAppliedRoleDetails: + type: object + properties: + campaign_role_id: + type: integer + format: int64 + example: 1541815603606036480 + role_name: + type: String + example: UI/UX subcom From a19671e39230f20aadc689a2a459887543c7b836 Mon Sep 17 00:00:00 2001 From: Alex_Miao_WSL Date: Sun, 6 Oct 2024 20:13:05 +1100 Subject: [PATCH 7/8] finished API doc --- backend/api.yaml | 635 +++++++++++++++++++++-------------------------- 1 file changed, 279 insertions(+), 356 deletions(-) diff --git a/backend/api.yaml b/backend/api.yaml index 7ae4430a..729d4030 100644 --- a/backend/api.yaml +++ b/backend/api.yaml @@ -142,12 +142,6 @@ paths: gender: type: string example: Male - pronouns: - type: string - example: They/Them - gender: - type: string - example: Male degree_name: type: string example: Computer Science @@ -267,74 +261,7 @@ paths: type: string example: Not logged in. - /user/pronouns: - patch: - operationId: updateUserPronouns - description: Updates currently logged in user's pronouns. - tags: - - User - requestBody: - required: true - content: - application/json: - schema: - properties: - zid: - type: string - example: "z5123456" - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully updated pronouns. - '401': - description: Not logged in. - content: - application/json: - schema: - properties: - error: - type: string - example: Not logged in. - /user/gender: - patch: - operationId: updateUserGender - description: Updates currently logged in user's gender. - tags: - - User - requestBody: - required: true - content: - application/json: - schema: - properties: - zid: - type: string - example: "z5123456" - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully updated gender. - '401': - description: Not logged in. - content: - application/json: - schema: - properties: - error: - type: string - example: Not logged in. + /user/zid: patch: operationId: updateUserZid @@ -406,6 +333,7 @@ paths: error: type: string example: Not logged in. + /user/applications: get: operationId: getUserApplications @@ -423,26 +351,15 @@ paths: type: array items: $ref: '#/components/schemas/ApplicationDetails' - - - - /user/applications: - get: - operationId: getUserApplications - description: Returns info about applications made by currently logged in user. - tags: - - User - responses: - '200': - description: OK + '401': + description: Not logged in. content: application/json: schema: properties: - campaigns: - type: array - items: - $ref: '#/components/schemas/ApplicationDetails' + error: + type: string + example: Not logged in. @@ -519,67 +436,17 @@ paths: created_at: type: string example: 2024-02-10T18:25:43.511Z - delete: - operationId: deleteOrganisationById - parameters: - - name: id - in: path - description: Organisation ID - required: true - schema: - type: integer - format: int64 - description: Deletes specified organisation. - tags: - - Organisation - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully deleted organisation. - '403': - description: User is not a super user. + '401': + description: Not logged in. content: application/json: schema: properties: error: type: string - example: Unauthorized - /organisation/{id}/campaigns: - get: - operationId: getOrganisationCampaignsById - parameters: - - name: id - in: path - description: Organisation ID - required: true - schema: - type: integer - format: int64 - description: Returns active campaigns for specified organisation. - tags: - - Organisation - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - campaigns: - type: array - items: - $ref: '#/components/schemas/OrganisationCampaign' - $ref: '#/components/schemas/OrganisationCampaign' - /organisation/{id}/logo: - patch: - operationId: updateOrganisationLogoById + example: Not logged in. + delete: + operationId: deleteOrganisationById parameters: - name: id in: path @@ -588,7 +455,7 @@ paths: schema: type: integer format: int64 - description: Updates logo for specified organistion. + description: Deletes specified organisation. tags: - Organisation responses: @@ -598,11 +465,9 @@ paths: application/json: schema: properties: - upload_url: + message: type: string - description: Presigned S3 url to upload file. - example: https://www.youtube.com/watch?v=dQw4w9WgXcQ - example: https://www.youtube.com/watch?v=dQw4w9WgXcQ + example: Successfully deleted organisation. '401': description: Not logged in. content: @@ -613,7 +478,7 @@ paths: type: string example: Not logged in. '403': - description: User is not an organisation admin. + description: User is not a super user. content: application/json: schema: @@ -621,12 +486,9 @@ paths: error: type: string example: Unauthorized - - /organisation/{id}/member: - - /organisation/{id}/member: + /organisation/{id}/campaigns: get: - operationId: getOrganisationMembersById + operationId: getOrganisationCampaignsById parameters: - name: id in: path @@ -635,7 +497,7 @@ paths: schema: type: integer format: int64 - description: Returns list of members of specified organisation. + description: Returns active campaigns for specified organisation. tags: - Organisation responses: @@ -645,66 +507,10 @@ paths: application/json: schema: properties: - members: + campaigns: type: array items: - type: object - properties: - id: - type: integer - format: int64 - example: 1541815603606036480 - name: - type: string - example: Clancy Lion - role: - type: string - example: Admin - '403': - description: User is not an organisation admin or member. - content: - application/json: - schema: - properties: - error: - type: string - example: Unauthorized - put: - operationId: updateOrganisationMembersById - parameters: - - name: id - in: path - description: Organisation ID - required: true - schema: - type: integer - format: int64 - requestBody: - required: true - content: - application/json: - schema: - properties: - members: - type: array - uniqueItems: true - items: - type: integer - format: int64 - example: [1541815603606036480, 1541815603606036827, 1541815287306036429] - description: Specifies members for specified organistion. - tags: - - Organisation - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully updated members. + $ref: '#/components/schemas/OrganisationCampaign' '401': description: Not logged in. content: @@ -714,17 +520,10 @@ paths: error: type: string example: Not logged in. - '403': - description: User is not an organisation admin. - content: - application/json: - schema: - properties: - error: - type: string - example: Unauthorized - delete: - operationId: deleteOrganisationMemberById + + /organisation/{id}/logo: + patch: + operationId: updateOrganisationLogoById parameters: - name: id in: path @@ -733,16 +532,7 @@ paths: schema: type: integer format: int64 - requestBody: - required: true - content: - application/json: - schema: - properties: - user_id: - type: integer - format: int64 - description: Specifies member for deletion in organistion. + description: Updates logo for specified organistion. tags: - Organisation responses: @@ -752,9 +542,10 @@ paths: application/json: schema: properties: - message: + upload_url: type: string - example: Successfully updated members. + description: Presigned S3 url to upload file. + example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: @@ -774,9 +565,9 @@ paths: type: string example: Unauthorized - /organisation/{id}/admin: + /organisation/{id}/member: get: - operationId: getOrganisationAdminsById + operationId: getOrganisationMembersById parameters: - name: id in: path @@ -785,7 +576,7 @@ paths: schema: type: integer format: int64 - description: Returns list of admins of specified organisation. + description: Returns list of members of specified organisation. tags: - Organisation responses: @@ -811,7 +602,7 @@ paths: type: string example: Admin '403': - description: User is not a SuperUser. + description: User is not an organisation admin or member. content: application/json: schema: @@ -820,7 +611,7 @@ paths: type: string example: Unauthorized put: - operationId: updateOrganisationAdminsById + operationId: updateOrganisationMembersById parameters: - name: id in: path @@ -842,57 +633,7 @@ paths: type: integer format: int64 example: [1541815603606036480, 1541815603606036827, 1541815287306036429] - description: Specifies Admins for specified organistion. - tags: - - Organisation - responses: - '200': - description: OK - content: - application/json: - schema: - properties: - message: - type: string - example: Successfully updated members. - '401': - description: Not logged in. - content: - application/json: - schema: - properties: - error: - type: string - example: Not logged in. - '403': - description: User is not a SuperUser. - content: - application/json: - schema: - properties: - error: - type: string - example: Unauthorized - delete: - operationId: deleteOrganisationAdminById - parameters: - - name: id - in: path - description: Organisation ID - required: true - schema: - type: integer - format: int64 - requestBody: - required: true - content: - application/json: - schema: - properties: - user_id: - type: integer - format: int64 - description: Specifies Admin for deletion in organistion. + description: Specifies members for specified organistion. tags: - Organisation responses: @@ -904,7 +645,7 @@ paths: properties: message: type: string - example: Successfully deleted Admin. + example: Successfully updated members. '401': description: Not logged in. content: @@ -915,7 +656,7 @@ paths: type: string example: Not logged in. '403': - description: User is not a SuperUser. + description: User is not an organisation admin. content: application/json: schema: @@ -923,10 +664,6 @@ paths: error: type: string example: Unauthorized - - - - delete: operationId: deleteOrganisationMemberById parameters: @@ -1128,9 +865,6 @@ paths: type: string example: Unauthorized - - - /organisation/{id}/campaign: post: operationId: createCampaign @@ -1389,7 +1123,6 @@ paths: type: string description: Presigned S3 url to upload file. example: https://www.youtube.com/watch?v=dQw4w9WgXcQ - example: https://www.youtube.com/watch?v=dQw4w9WgXcQ '401': description: Not logged in. content: @@ -1491,32 +1224,24 @@ paths: type: array items: $ref: '#components/schemas/RoleDetails' - - /campaign/{id}/applications: - get: - operationId: getApplicationsById - parameters: - - name: id - in: path - description: campaign ID - required: true - schema: - type: integer - format: int64 - description: Returns info about all Applications in given Campaign. - tags: - - Campaign - responses: - '200': - description: OK + '401': + description: Not logged in. content: application/json: schema: properties: - applications: - type: array - items: - $ref: '#components/schemas/RoleDetails' + error: + type: string + example: Not logged in. + '403': + description: User is not a Campaign Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized /campaign/{id}/applications: get: @@ -1542,32 +1267,25 @@ paths: applications: type: array items: - type: object - properties: - id: - type: int64 - example: 6996987893965262849 - campaign_id: - type: int64 - example: 6956987893465262847 - user: - $ref: '#/components/schemas/UserDetails' - status: - private_status: - applied_roles: - - - id: - type: int64 - example: 6996987893965262849 - campaign_id: - type: int64 - example: 6956987893465262847 - user: - $ref: '#/components/schemas/UserDetails' - status: - private_status: - applied_roles: + $ref: '#components/schemas/ApplicationDetails' + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not a Campaign Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized /role/{id}: @@ -1581,7 +1299,6 @@ paths: schema: type: integer format: int64 - format: int64 description: Returns info about specified role. tags: - Role @@ -1620,7 +1337,6 @@ paths: put: operationId: updateRoleById - parameters: parameters: - name: id in: path @@ -1629,7 +1345,6 @@ paths: schema: type: integer format: int64 - format: int64 description: Update a role given the role id. tags: - Role @@ -1666,6 +1381,15 @@ paths: message: type: string example: Successfully update organisation. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. '403': description: User is not a Campaign Admin. content: @@ -1686,7 +1410,6 @@ paths: schema: type: integer format: int64 - format: int64 description: Deletes specified role. tags: - Role @@ -1700,6 +1423,15 @@ paths: message: type: string example: Successfully deleted role. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. '403': description: User is not an admin of role's Campaign. content: @@ -1710,8 +1442,199 @@ paths: type: string example: Unauthorized + /role/{id}/applications: + get: + operationId: getApplicationsByRoleID + parameters: + - name: id + in: path + description: Role ID + required: true + schema: + type: integer + format: int64 + description: Returns all applications to a specific role + tags: + - Role + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + applications: + type: array + items: + $ref: '#components/schemas/ApplicationDetails' + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an Application Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + /application/{id}: + get: + operationId: getApplicationByID + parameters: + - name: id + in: path + description: Application ID + required: true + schema: + type: integer + format: int64 + description: Returns an applications given its ID + tags: + - Application + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + application: + type: + $ref: '#components/schemas/ApplicationDetails' + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an Application Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + + + /application/{id}/private: + put: + operationId: updateApplicationPrivateStatus + parameters: + - name: id + in: path + description: Application ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + data: + type: + $ref: '#components/schemas/ApplicationStatus' + + description: Change Private Status of a specific Application + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated Application Private Status. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an Application Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized + /application/{id}/status: + put: + operationId: updateApplicationStatus + parameters: + - name: id + in: path + description: Application ID + required: true + schema: + type: integer + format: int64 + requestBody: + required: true + content: + application/json: + schema: + properties: + data: + type: + $ref: '#components/schemas/ApplicationStatus' + description: Change Status of a specific Application + tags: + - Organisation + responses: + '200': + description: OK + content: + application/json: + schema: + properties: + message: + type: string + example: Successfully updated Application Status. + '401': + description: Not logged in. + content: + application/json: + schema: + properties: + error: + type: string + example: Not logged in. + '403': + description: User is not an Application Admin. + content: + application/json: + schema: + properties: + error: + type: string + example: Unauthorized components: schemas: From 40768fc16b54d1f04331a6ccadedd4ff22349115 Mon Sep 17 00:00:00 2001 From: Kavika Date: Mon, 14 Oct 2024 17:17:57 +1100 Subject: [PATCH 8/8] Update rust.yml --- .github/workflows/rust.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bb758e56..8788bb70 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,9 +3,6 @@ name: Rust on: pull_request: branches: [main, "renovate/*", "CHAOS-224-KHAOS-rewrite"] - paths: - - backend/server/** - - backend/prisma-cli/** push: branches: ["renovate/*"]