-
Notifications
You must be signed in to change notification settings - Fork 399
upcoming: [UIE-9343] - Add API endpoints and types for /v4/images/sharegroups/members and /v4/images/sharegroups/tokens
#12984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8fa8476
e2fdce2
e96cc59
c12d9ab
ef8a7da
a2f46d8
4cfe29d
cce9401
cd173b6
c317f6e
07522b7
8cd958e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@linode/api-v4": Upcoming Features | ||
| --- | ||
|
|
||
| Add endpoints for `/v4/images/sharegroups/members` and `/v4/images/sharegroups/tokens` ([#12984](https://github.com/linode/manager/pull/12984)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| import { | ||
| addSharegroupMemberSchema, | ||
| generateSharegroupTokenSchema, | ||
| updateSharegroupMemberSchema, | ||
| updateSharegroupTokenSchema, | ||
| } from '@linode/validation/lib/images.schema'; | ||
|
|
||
| import { BETA_API_ROOT } from '../constants'; | ||
| import Request, { | ||
| setData, | ||
| setMethod, | ||
| setParams, | ||
| setURL, | ||
| setXFilter, | ||
| } from '../request'; | ||
|
|
||
| import type { Filter, ResourcePage as Page, Params } from '../types'; | ||
| import type { | ||
| AddSharegroupMemberPayload, | ||
| GenerateSharegroupTokenPayload, | ||
| Image, | ||
| Sharegroup, | ||
| SharegroupMember, | ||
| SharegroupToken, | ||
| UpdateSharegroupMemberPayload, | ||
| } from './types'; | ||
|
|
||
| /** | ||
| * Add Member to the Sharegroup | ||
| * | ||
| * @param sharegroupId {string} ID of the Sharegroup to add member | ||
| * @param data {AddSharegroupMemberPayload} the Member details | ||
| */ | ||
| export const addMembersToSharegroup = ( | ||
| sharegroupId: number, | ||
| data: AddSharegroupMemberPayload, | ||
| ) => { | ||
| return Request<Sharegroup>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/${encodeURIComponent(sharegroupId)}/images`, | ||
| ), | ||
| setMethod('POST'), | ||
| setData(data, addSharegroupMemberSchema), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Generate user token for the Sharegroup | ||
| * | ||
| * @param data {GenerateSharegroupTokenPayload} the token details | ||
| */ | ||
| export const generateSharegroupToken = ( | ||
| data: GenerateSharegroupTokenPayload, | ||
| ) => { | ||
| return Request<SharegroupToken>( | ||
| setURL(`${BETA_API_ROOT}/images/sharegroups/tokens`), | ||
| setMethod('POST'), | ||
| setData(data, generateSharegroupTokenSchema), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Get details of the Sharegroup the token has been accepted into | ||
| * | ||
| * @param token_uuid {string} Token UUID of the user | ||
| */ | ||
| export const getSharegroupFromToken = (token_uuid: string) => { | ||
|
Check warning on line 67 in packages/api-v4/src/images/sharegroup.ts
|
||
| Request<Sharegroup>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/tokens/${encodeURIComponent(token_uuid)}/sharegroup`, | ||
| ), | ||
| setMethod('GET'), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Get a paginated list of Sharegroup Images the token has been accepted into | ||
| * | ||
| * @param token_uuid {string} Token UUID of the user | ||
| */ | ||
| export const getSharegroupImagesFromToken = ( | ||
| token_uuid: string, | ||
|
Check warning on line 82 in packages/api-v4/src/images/sharegroup.ts
|
||
| params: Params = {}, | ||
| filters: Filter = {}, | ||
| ) => { | ||
| Request<Page<Image>>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/tokens/${encodeURIComponent(token_uuid)}/sharegroups/images`, | ||
| ), | ||
| setMethod('GET'), | ||
| setParams(params), | ||
| setXFilter(filters), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Get a paginated list of members part of the Sharegroup | ||
| * | ||
| * @param sharegroupId {string} ID of the Sharegroup to look up | ||
| */ | ||
| export const getSharegroupMembers = ( | ||
| sharegroupId: string, | ||
| params: Params = {}, | ||
| filters: Filter = {}, | ||
| ) => { | ||
| Request<Page<SharegroupMember>>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/${encodeURIComponent(sharegroupId)}/members`, | ||
| ), | ||
| setMethod('GET'), | ||
| setParams(params), | ||
| setXFilter(filters), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Get member details of a user from the Sharegroup | ||
| * | ||
| * @param sharegroupId {string} ID of the Sharegroup to look up | ||
| * @param token_uuid {string} Token UUID of the user to look up | ||
| */ | ||
| export const getSharegroupMember = ( | ||
| sharegroupId: string, | ||
| token_uuid: string, | ||
|
Check warning on line 124 in packages/api-v4/src/images/sharegroup.ts
|
||
| ) => { | ||
| Request<SharegroupMember>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/${encodeURIComponent(sharegroupId)}/members/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('GET'), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Returns a paginated list of tokens created by the user | ||
| */ | ||
| export const getUserSharegroupTokens = ( | ||
| params: Params = {}, | ||
| filters: Filter = {}, | ||
| ) => { | ||
| Request<Page<SharegroupToken>>( | ||
| setURL(`${BETA_API_ROOT}/images/sharegroups/tokens`), | ||
| setMethod('GET'), | ||
| setParams(params), | ||
| setXFilter(filters), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Get details about a specific token created by the user | ||
| * | ||
| * @param token_uuid Token UUID of the user to look up | ||
| */ | ||
| export const getUserSharegroupToken = (token_uuid: string) => { | ||
|
Check warning on line 154 in packages/api-v4/src/images/sharegroup.ts
|
||
| Request<SharegroupToken>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/tokens/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('GET'), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Update a user token's label | ||
| * | ||
| * @param token_uuid {string} token UUID of the user | ||
| * @param data {UpdateSharegroupMemberPayload} the updated label | ||
| */ | ||
| export const updateSharegroupToken = ( | ||
| token_uuid: string, | ||
|
Check warning on line 170 in packages/api-v4/src/images/sharegroup.ts
|
||
| data: UpdateSharegroupMemberPayload, | ||
| ) => { | ||
| return Request<SharegroupToken>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/tokens/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('PUT'), | ||
| setData(data, updateSharegroupTokenSchema), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Update a Sharegroup member's label | ||
| * | ||
| * @param token_uuid {string} token UUID of the user | ||
| * @param data {UpdateSharegroupMemberPayload} the updated label | ||
| */ | ||
| interface UpdateSharegroupMember { | ||
| data: UpdateSharegroupMemberPayload; | ||
| sharegroupId: string; | ||
| token_uuid: string; | ||
| } | ||
|
|
||
| export const updateSharegroupMember = ({ | ||
| sharegroupId, | ||
| token_uuid, | ||
|
Check warning on line 196 in packages/api-v4/src/images/sharegroup.ts
|
||
| data, | ||
| }: UpdateSharegroupMember) => { | ||
| return Request<SharegroupMember>( | ||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/${encodeURIComponent(sharegroupId)}/members/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('PUT'), | ||
| setData(data, updateSharegroupMemberSchema), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Delete a user token | ||
| * | ||
| * @param token_uuid {string} Token UUID of the user to delete | ||
| */ | ||
| export const deleteSharegroupToken = (token_uuid: string) => { | ||
|
Check warning on line 213 in packages/api-v4/src/images/sharegroup.ts
|
||
| return Request<{}>( | ||
|
Check warning on line 214 in packages/api-v4/src/images/sharegroup.ts
|
||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/tokens/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('DELETE'), | ||
| ); | ||
| }; | ||
|
|
||
| /** | ||
| * Delete a sharegroup Member | ||
| * | ||
| * @param token_uuid {string} Token UUID of the member to delete | ||
| */ | ||
| export const deleteSharegroupMember = ( | ||
| sharegroupId: string, | ||
| token_uuid: string, | ||
|
Check warning on line 229 in packages/api-v4/src/images/sharegroup.ts
|
||
| ) => { | ||
| return Request<{}>( | ||
|
Check warning on line 231 in packages/api-v4/src/images/sharegroup.ts
|
||
| setURL( | ||
| `${BETA_API_ROOT}/images/sharegroups/${encodeURIComponent(sharegroupId)}/members/${encodeURIComponent(token_uuid)}`, | ||
| ), | ||
| setMethod('DELETE'), | ||
| ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be consistent with the file naming as well (all lower caps)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did find nodePool.ts to follow the camelCasing though π€
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but nodePool is camel case everywhere. this file name is the only instance of shareGroups being camel case
It's not a big deal, just a consistency nit. does not matter much to me