diff --git a/packages/clients/src/api/iam/v1alpha1/api.gen.ts b/packages/clients/src/api/iam/v1alpha1/api.gen.ts index 64c83304b..886eb0857 100644 --- a/packages/clients/src/api/iam/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/api.gen.ts @@ -25,9 +25,11 @@ import { unmarshalAPIKey, unmarshalApplication, unmarshalGroup, + unmarshalJWT, unmarshalListAPIKeysResponse, unmarshalListApplicationsResponse, unmarshalListGroupsResponse, + unmarshalListJWTsResponse, unmarshalListPermissionSetsResponse, unmarshalListPoliciesResponse, unmarshalListQuotaResponse, @@ -53,23 +55,28 @@ import type { DeleteAPIKeyRequest, DeleteApplicationRequest, DeleteGroupRequest, + DeleteJWTRequest, DeletePolicyRequest, DeleteSSHKeyRequest, DeleteUserRequest, GetAPIKeyRequest, GetApplicationRequest, GetGroupRequest, + GetJWTRequest, GetPolicyRequest, GetQuotumRequest, GetSSHKeyRequest, GetUserRequest, Group, + JWT, ListAPIKeysRequest, ListAPIKeysResponse, ListApplicationsRequest, ListApplicationsResponse, ListGroupsRequest, ListGroupsResponse, + ListJWTsRequest, + ListJWTsResponse, ListPermissionSetsRequest, ListPermissionSetsResponse, ListPoliciesRequest, @@ -931,4 +938,58 @@ export class API extends ParentAPI { }, unmarshalQuotum, ) + + protected pageOfListJWTs = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/iam/v1alpha1/jwts`, + urlParams: urlParams( + ['audience_id', request.audienceId], + ['expired', request.expired], + ['order_by', request.orderBy ?? 'created_at_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + ), + }, + unmarshalListJWTsResponse, + ) + + /** + * List JWTs + * + * @param request - The request {@link ListJWTsRequest} + * @returns A Promise of ListJWTsResponse + */ + listJWTs = (request: Readonly) => + enrichForPagination('jwts', this.pageOfListJWTs, request) + + /** + * Get a JWT + * + * @param request - The request {@link GetJWTRequest} + * @returns A Promise of JWT + */ + getJWT = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/iam/v1alpha1/jwts/${validatePathParam('jti', request.jti)}`, + }, + unmarshalJWT, + ) + + /** + * Delete a JWT + * + * @param request - The request {@link DeleteJWTRequest} + */ + deleteJWT = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/iam/v1alpha1/jwts/${validatePathParam('jti', request.jti)}`, + }) } diff --git a/packages/clients/src/api/iam/v1alpha1/index.gen.ts b/packages/clients/src/api/iam/v1alpha1/index.gen.ts index 5867a240c..7238401cf 100644 --- a/packages/clients/src/api/iam/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/index.gen.ts @@ -15,17 +15,20 @@ export type { DeleteAPIKeyRequest, DeleteApplicationRequest, DeleteGroupRequest, + DeleteJWTRequest, DeletePolicyRequest, DeleteSSHKeyRequest, DeleteUserRequest, GetAPIKeyRequest, GetApplicationRequest, GetGroupRequest, + GetJWTRequest, GetPolicyRequest, GetQuotumRequest, GetSSHKeyRequest, GetUserRequest, Group, + JWT, ListAPIKeysRequest, ListAPIKeysRequestOrderBy, ListAPIKeysResponse, @@ -35,6 +38,9 @@ export type { ListGroupsRequest, ListGroupsRequestOrderBy, ListGroupsResponse, + ListJWTsRequest, + ListJWTsRequestOrderBy, + ListJWTsResponse, ListPermissionSetsRequest, ListPermissionSetsRequestOrderBy, ListPermissionSetsResponse, diff --git a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts index 6f88115a5..4bc09df5f 100644 --- a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts @@ -18,9 +18,11 @@ import type { CreatePolicyRequest, CreateSSHKeyRequest, Group, + JWT, ListAPIKeysResponse, ListApplicationsResponse, ListGroupsResponse, + ListJWTsResponse, ListPermissionSetsResponse, ListPoliciesResponse, ListQuotaResponse, @@ -105,6 +107,25 @@ export const unmarshalGroup = (data: unknown) => { } as Group } +export const unmarshalJWT = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'JWT' failed as data isn't a dictionary.`, + ) + } + + return { + audienceId: data.audience_id, + createdAt: unmarshalDate(data.created_at), + expiresAt: unmarshalDate(data.expires_at), + ip: data.ip, + issuerId: data.issuer_id, + jti: data.jti, + updatedAt: unmarshalDate(data.updated_at), + userAgent: data.user_agent, + } as JWT +} + const unmarshalPermissionSet = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( @@ -260,6 +281,19 @@ export const unmarshalListGroupsResponse = (data: unknown) => { } as ListGroupsResponse } +export const unmarshalListJWTsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListJWTsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + jwts: unmarshalArrayOfObject(data.jwts, unmarshalJWT), + totalCount: data.total_count, + } as ListJWTsResponse +} + export const unmarshalListPermissionSetsResponse = (data: unknown) => { if (!isJSONObject(data)) { throw new TypeError( diff --git a/packages/clients/src/api/iam/v1alpha1/types.gen.ts b/packages/clients/src/api/iam/v1alpha1/types.gen.ts index 081ece89c..2da7f4ed0 100644 --- a/packages/clients/src/api/iam/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/types.gen.ts @@ -29,6 +29,12 @@ export type ListGroupsRequestOrderBy = | 'name_asc' | 'name_desc' +export type ListJWTsRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'updated_at_asc' + | 'updated_at_desc' + export type ListPermissionSetsRequestOrderBy = | 'name_asc' | 'name_desc' @@ -145,6 +151,26 @@ export interface Group { applicationIds: string[] } +/** Jwt */ +export interface JWT { + /** JWT ID */ + jti: string + /** ID of the user who issued the JWT */ + issuerId: string + /** ID of the user targeted by the JWT */ + audienceId: string + /** Creation date of the JWT */ + createdAt?: Date + /** Last update date of the JWT */ + updatedAt?: Date + /** Expiration date of the JWT */ + expiresAt?: Date + /** IP address used during the creation of the JWT */ + ip: string + /** User-agent used during the creation of the JWT */ + userAgent: string +} + /** List api keys response */ export interface ListAPIKeysResponse { /** List of API keys */ @@ -169,6 +195,11 @@ export interface ListGroupsResponse { totalCount: number } +export interface ListJWTsResponse { + jwts: JWT[] + totalCount: number +} + /** List permission sets response */ export interface ListPermissionSetsResponse { /** List of permission sets */ @@ -843,3 +874,26 @@ export type GetQuotumRequest = { /** ID of the organization */ organizationId?: string } + +export type ListJWTsRequest = { + /** Criteria for sorting results */ + orderBy?: ListJWTsRequestOrderBy + /** ID of the user to search */ + audienceId: string + /** Number of results per page. Value must be between 1 and 100 */ + pageSize?: number + /** Number of page. Value must be greater to 1 */ + page?: number + /** Filter out expired JWTs or not */ + expired?: boolean +} + +export type GetJWTRequest = { + /** JWT ID of the JWT to get */ + jti: string +} + +export type DeleteJWTRequest = { + /** JWT ID of the JWT to delete */ + jti: string +} diff --git a/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts b/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts index 95393223d..7556569bc 100644 --- a/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts @@ -102,6 +102,16 @@ export const ListGroupsRequest = { }, } +export const ListJWTsRequest = { + page: { + greaterThanOrEqual: 1, + }, + pageSize: { + greaterThanOrEqual: 1, + lessThanOrEqual: 100, + }, +} + export const ListPermissionSetsRequest = { page: { greaterThanOrEqual: 1,