From 1f212361dc0f821871b0e16c324de549d4bdd4fe Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Wed, 1 Nov 2023 10:36:25 +0000 Subject: [PATCH] Add support for organizations in client credentials to management api --- .../managers/client-grants-manager.ts | 65 ++++ .../managers/organizations-manager.ts | 140 ++++++- .../__generated/managers/users-manager.ts | 8 +- src/management/__generated/models/index.ts | 348 +++++++++++++++--- 4 files changed, 486 insertions(+), 75 deletions(-) diff --git a/src/management/__generated/managers/client-grants-manager.ts b/src/management/__generated/managers/client-grants-manager.ts index 1217f9202..8d53459e0 100644 --- a/src/management/__generated/managers/client-grants-manager.ts +++ b/src/management/__generated/managers/client-grants-manager.ts @@ -4,10 +4,14 @@ import type { ClientGrant, ClientGrantCreate, GetClientGrants200Response, + GetClientGrantsOrganizations200Response, PatchClientGrantsByIdRequest, GetClientGrants200ResponseOneOf, + GetClientGrantsOrganizations200ResponseOneOf, + GetClientGrantsOrganizations200ResponseOneOfInner, DeleteClientGrantsByIdRequest, GetClientGrantsRequest, + GetClientGrantsOrganizationsRequest, PatchClientGrantsByIdOperationRequest, } from '../models/index.js'; @@ -83,6 +87,10 @@ export class ClientGrantsManager extends BaseAPI { key: 'client_id', config: {}, }, + { + key: 'allow_any_organization', + config: {}, + }, ]); const response = await this.request( @@ -97,6 +105,63 @@ export class ClientGrantsManager extends BaseAPI { return runtime.JSONApiResponse.fromResponse(response); } + /** + * Get the organizations associated to a client grant + * + * @throws {RequiredError} + */ + async getOrganizations( + requestParameters: GetClientGrantsOrganizationsRequest & { include_totals: true }, + initOverrides?: InitOverride + ): Promise>; + async getOrganizations( + requestParameters?: GetClientGrantsOrganizationsRequest, + initOverrides?: InitOverride + ): Promise>>; + async getOrganizations( + requestParameters: GetClientGrantsOrganizationsRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const queryParameters = runtime.applyQueryParams(requestParameters, [ + { + key: 'page', + config: {}, + }, + { + key: 'per_page', + config: {}, + }, + { + key: 'include_totals', + config: {}, + }, + { + key: 'from', + config: {}, + }, + { + key: 'take', + config: {}, + }, + ]); + + const response = await this.request( + { + path: `/client-grants/{id}/organizations`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'GET', + query: queryParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + /** * Update a client grant. * Update client grant diff --git a/src/management/__generated/managers/organizations-manager.ts b/src/management/__generated/managers/organizations-manager.ts index a2940a518..21035c79e 100644 --- a/src/management/__generated/managers/organizations-manager.ts +++ b/src/management/__generated/managers/organizations-manager.ts @@ -3,20 +3,23 @@ import type { InitOverride, ApiResponse } from '../../../lib/runtime.js'; import type { DeleteMembersRequest, DeleteOrganizationMemberRolesRequest, + GetClientGrantsOrganizations200Response, + GetClientGrantsOrganizations200ResponseOneOfInner, GetEnabledConnections200Response, GetEnabledConnections200ResponseOneOfInner, GetInvitations200Response, GetInvitations200ResponseOneOfInner, GetMembers200Response, GetOrganizationMemberRoles200Response, - GetOrganizations200Response, - GetOrganizations200ResponseOneOfInner, + GetOrganizationsClientGrants200Response, + GetOrganizationsClientGrants200ResponseOneOfInner, PatchEnabledConnectionsByConnectionIdRequest, PatchOrganizationsByIdRequest, PostEnabledConnectionsRequest, PostInvitationsRequest, PostMembersRequest, PostOrganizationMemberRolesRequest, + PostOrganizationsClientGrantsRequest, PostOrganizationsRequest, GetEnabledConnections200ResponseOneOf, GetInvitations200ResponseOneOf, @@ -24,7 +27,9 @@ import type { GetMembers200ResponseOneOfInner, GetOrganizationMemberRoles200ResponseOneOf, GetOrganizationMemberRoles200ResponseOneOfInner, - GetOrganizations200ResponseOneOf, + GetClientGrantsOrganizations200ResponseOneOf, + GetOrganizationsClientGrants200ResponseOneOf, + DeleteClientGrantsByGrantIdRequest, DeleteEnabledConnectionsByConnectionIdRequest, DeleteInvitationsByInvitationIdRequest, DeleteMembersOperationRequest, @@ -39,12 +44,14 @@ import type { GetOrganizationMemberRolesRequest, GetOrganizationsRequest, GetOrganizationsByIdRequest, + GetOrganizationsClientGrantsRequest, PatchEnabledConnectionsByConnectionIdOperationRequest, PatchOrganizationsByIdOperationRequest, PostEnabledConnectionsOperationRequest, PostInvitationsOperationRequest, PostMembersOperationRequest, PostOrganizationMemberRolesOperationRequest, + PostOrganizationsClientGrantsOperationRequest, } from '../models/index.js'; const { BaseAPI } = runtime; @@ -53,6 +60,30 @@ const { BaseAPI } = runtime; * */ export class OrganizationsManager extends BaseAPI { + /** + * Remove a client grant from an organization + * + * @throws {RequiredError} + */ + async deleteClientGrant( + requestParameters: DeleteClientGrantsByGrantIdRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id', 'grant_id']); + + const response = await this.request( + { + path: `/organizations/{id}/client-grants/{grant_id}` + .replace('{id}', encodeURIComponent(String(requestParameters.id))) + .replace('{grant_id}', encodeURIComponent(String(requestParameters.grant_id))), + method: 'DELETE', + }, + initOverrides + ); + + return runtime.VoidApiResponse.fromResponse(response); + } + /** * Delete connections from an organization * @@ -465,7 +496,7 @@ export class OrganizationsManager extends BaseAPI { async getByName( requestParameters: GetNameByNameRequest, initOverrides?: InitOverride - ): Promise> { + ): Promise> { runtime.validateRequiredRequestParams(requestParameters, ['name']); const response = await this.request( @@ -552,15 +583,15 @@ export class OrganizationsManager extends BaseAPI { async getAll( requestParameters: GetOrganizationsRequest & { include_totals: true }, initOverrides?: InitOverride - ): Promise>; + ): Promise>; async getAll( requestParameters?: GetOrganizationsRequest, initOverrides?: InitOverride - ): Promise>>; + ): Promise>>; async getAll( requestParameters: GetOrganizationsRequest = {}, initOverrides?: InitOverride - ): Promise> { + ): Promise> { const queryParameters = runtime.applyQueryParams(requestParameters, [ { key: 'page', @@ -610,7 +641,7 @@ export class OrganizationsManager extends BaseAPI { async get( requestParameters: GetOrganizationsByIdRequest, initOverrides?: InitOverride - ): Promise> { + ): Promise> { runtime.validateRequiredRequestParams(requestParameters, ['id']); const response = await this.request( @@ -627,6 +658,63 @@ export class OrganizationsManager extends BaseAPI { return runtime.JSONApiResponse.fromResponse(response); } + /** + * Get client grants associated to an organization + * + * @throws {RequiredError} + */ + async getClientGrants( + requestParameters: GetOrganizationsClientGrantsRequest & { include_totals: true }, + initOverrides?: InitOverride + ): Promise>; + async getClientGrants( + requestParameters?: GetOrganizationsClientGrantsRequest, + initOverrides?: InitOverride + ): Promise>>; + async getClientGrants( + requestParameters: GetOrganizationsClientGrantsRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const queryParameters = runtime.applyQueryParams(requestParameters, [ + { + key: 'audience', + config: {}, + }, + { + key: 'client_id', + config: {}, + }, + { + key: 'page', + config: {}, + }, + { + key: 'per_page', + config: {}, + }, + { + key: 'include_totals', + config: {}, + }, + ]); + + const response = await this.request( + { + path: `/organizations/{id}/client-grants`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'GET', + query: queryParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + /** * Modify an enabled_connection belonging to an Organization. * @@ -671,7 +759,7 @@ export class OrganizationsManager extends BaseAPI { requestParameters: PatchOrganizationsByIdOperationRequest, bodyParameters: PatchOrganizationsByIdRequest, initOverrides?: InitOverride - ): Promise> { + ): Promise> { runtime.validateRequiredRequestParams(requestParameters, ['id']); const headerParameters: runtime.HTTPHeaders = {}; @@ -831,7 +919,7 @@ export class OrganizationsManager extends BaseAPI { async create( bodyParameters: PostOrganizationsRequest, initOverrides?: InitOverride - ): Promise> { + ): Promise> { const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; @@ -848,4 +936,36 @@ export class OrganizationsManager extends BaseAPI { return runtime.JSONApiResponse.fromResponse(response); } + + /** + * Associate a client grant with an organization + * + * @throws {RequiredError} + */ + async addClientGrant( + requestParameters: PostOrganizationsClientGrantsOperationRequest, + bodyParameters: PostOrganizationsClientGrantsRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request( + { + path: `/organizations/{id}/client-grants`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'POST', + headers: headerParameters, + body: bodyParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } } diff --git a/src/management/__generated/managers/users-manager.ts b/src/management/__generated/managers/users-manager.ts index 85b82fff9..3d5b2c7a9 100644 --- a/src/management/__generated/managers/users-manager.ts +++ b/src/management/__generated/managers/users-manager.ts @@ -30,8 +30,8 @@ import type { Log, GetPermissions200ResponseOneOf, GetPermissions200ResponseOneOfInner, - GetOrganizations200ResponseOneOf, - GetOrganizations200ResponseOneOfInner, + GetClientGrantsOrganizations200ResponseOneOf, + GetClientGrantsOrganizations200ResponseOneOfInner, GetOrganizationMemberRoles200ResponseOneOf, GetOrganizationMemberRoles200ResponseOneOfInner, GetUsers200ResponseOneOf, @@ -503,11 +503,11 @@ export class UsersManager extends BaseAPI { async getUserOrganizations( requestParameters: GetUserOrganizationsRequest & { include_totals: true }, initOverrides?: InitOverride - ): Promise>; + ): Promise>; async getUserOrganizations( requestParameters?: GetUserOrganizationsRequest, initOverrides?: InitOverride - ): Promise>>; + ): Promise>>; async getUserOrganizations( requestParameters: GetUserOrganizationsRequest, initOverrides?: InitOverride diff --git a/src/management/__generated/models/index.ts b/src/management/__generated/models/index.ts index e7d2d79fa..f9937d1d9 100644 --- a/src/management/__generated/models/index.ts +++ b/src/management/__generated/models/index.ts @@ -1877,7 +1877,26 @@ export interface ClientGrant { * */ scope: Array; + /** + * Defines whether organizations can be used with client credentials exchanges for this grant. + * + */ + organization_usage: ClientGrantOrganizationUsageEnum; + /** + * If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. + * + */ + allow_any_organization: boolean; } + +export const ClientGrantOrganizationUsageEnum = { + deny: 'deny', + allow: 'allow', + require: 'require', +} as const; +export type ClientGrantOrganizationUsageEnum = + (typeof ClientGrantOrganizationUsageEnum)[keyof typeof ClientGrantOrganizationUsageEnum]; + /** * */ @@ -1892,12 +1911,31 @@ export interface ClientGrantCreate { * */ audience: string; + /** + * Defines whether organizations can be used with client credentials exchanges for this grant. + * + */ + organization_usage?: ClientGrantCreateOrganizationUsageEnum; + /** + * If enabled, any organization can be used with this grant. If disabled (default), the grant must be explicitly assigned to the desired organizations. + * + */ + allow_any_organization?: boolean; /** * Scopes allowed for this client grant. * */ scope: Array; } + +export const ClientGrantCreateOrganizationUsageEnum = { + deny: 'deny', + allow: 'allow', + require: 'require', +} as const; +export type ClientGrantCreateOrganizationUsageEnum = + (typeof ClientGrantCreateOrganizationUsageEnum)[keyof typeof ClientGrantCreateOrganizationUsageEnum]; + /** * Configuration related to JWTs for the client. */ @@ -4664,6 +4702,98 @@ export interface GetClientGrants200ResponseOneOf { */ client_grants: Array; } +/** + * + */ +export type GetClientGrantsOrganizations200Response = + | Array + | GetClientGrantsOrganizations200ResponseOneOf + | GetClientGrantsOrganizations200ResponseOneOf1; +/** + * + */ +export interface GetClientGrantsOrganizations200ResponseOneOf { + /** + */ + start: number; + /** + */ + limit: number; + /** + */ + total: number; + /** + */ + organizations: Array; +} +/** + * + */ +export interface GetClientGrantsOrganizations200ResponseOneOf1 { + /** + */ + next: string; + /** + */ + organizations: Array; +} +/** + * + */ +export interface GetClientGrantsOrganizations200ResponseOneOfInner { + [key: string]: any | any; + /** + * Organization identifier + * + */ + id: string; + /** + * The name of this organization. + * + */ + name: string; + /** + * Friendly name of this organization. + * + */ + display_name: string; + /** + */ + branding: GetClientGrantsOrganizations200ResponseOneOfInnerBranding; + /** + * Metadata associated with the organization, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. + * + */ + metadata: { [key: string]: any }; +} +/** + * Theme defines how to style the login pages + */ +export interface GetClientGrantsOrganizations200ResponseOneOfInnerBranding { + /** + * URL of logo to display on login page + * + */ + logo_url: string; + /** + */ + colors: GetClientGrantsOrganizations200ResponseOneOfInnerBrandingColors; +} +/** + * Color scheme used to customize the login pages + */ +export interface GetClientGrantsOrganizations200ResponseOneOfInnerBrandingColors { + /** + * HEX Color for primary elements + * + */ + primary: string; + /** + * HEX Color for background + * + */ + page_background: string; +} /** * */ @@ -6088,14 +6218,13 @@ export interface GetOrganizationMemberRoles200ResponseOneOfInner { /** * */ -export type GetOrganizations200Response = - | Array - | GetOrganizations200ResponseOneOf - | GetOrganizations200ResponseOneOf1; +export type GetOrganizationsClientGrants200Response = + | Array + | GetOrganizationsClientGrants200ResponseOneOf; /** * */ -export interface GetOrganizations200ResponseOneOf { +export interface GetOrganizationsClientGrants200ResponseOneOf { /** */ start: number; @@ -6107,75 +6236,32 @@ export interface GetOrganizations200ResponseOneOf { total: number; /** */ - organizations: Array; + grants: Array; } /** * */ -export interface GetOrganizations200ResponseOneOf1 { +export interface GetOrganizationsClientGrants200ResponseOneOfInner { /** - */ - next: string; - /** - */ - organizations: Array; -} -/** - * - */ -export interface GetOrganizations200ResponseOneOfInner { - [key: string]: any | any; - /** - * Organization identifier + * ID of the client grant. * */ id: string; /** - * The name of this organization. - * - */ - name: string; - /** - * Friendly name of this organization. - * - */ - display_name: string; - /** - */ - branding: GetOrganizations200ResponseOneOfInnerBranding; - /** - * Metadata associated with the organization, in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. - * - */ - metadata: { [key: string]: any }; -} -/** - * Theme defines how to style the login pages - */ -export interface GetOrganizations200ResponseOneOfInnerBranding { - /** - * URL of logo to display on login page + * ID of the client. * */ - logo_url: string; - /** - */ - colors: GetOrganizations200ResponseOneOfInnerBrandingColors; -} -/** - * Color scheme used to customize the login pages - */ -export interface GetOrganizations200ResponseOneOfInnerBrandingColors { + client_id: string; /** - * HEX Color for primary elements + * The audience (API identifier) of this client grant * */ - primary: string; + audience: string; /** - * HEX Color for background + * Scopes allowed for this client grant. * */ - page_background: string; + scope: Array; } /** * @@ -6569,8 +6655,8 @@ export interface GetUniversalLogin200ResponseOneOf { * */ export type GetUserOrganizations200Response = - | Array - | GetOrganizations200ResponseOneOf; + | Array + | GetClientGrantsOrganizations200ResponseOneOf; /** * */ @@ -7420,7 +7506,27 @@ export interface PatchClientGrantsByIdRequest { * */ scope?: Array; + /** + * Controls how organizations may be used with this grant + * + */ + organization_usage?: PatchClientGrantsByIdRequestOrganizationUsageEnum; + /** + * Controls allowing any organization to be used with this grant + * + */ + allow_any_organization?: boolean | null; } + +export const PatchClientGrantsByIdRequestOrganizationUsageEnum = { + deny: 'deny', + allow: 'allow', + require: 'require', + null: 'null', +} as const; +export type PatchClientGrantsByIdRequestOrganizationUsageEnum = + (typeof PatchClientGrantsByIdRequestOrganizationUsageEnum)[keyof typeof PatchClientGrantsByIdRequestOrganizationUsageEnum]; + /** * */ @@ -7710,7 +7816,7 @@ export interface PatchOrganizationsByIdRequestBranding { logo_url?: string; /** */ - colors?: GetOrganizations200ResponseOneOfInnerBrandingColors; + colors?: GetClientGrantsOrganizations200ResponseOneOfInnerBrandingColors; } /** * @@ -9431,6 +9537,16 @@ export interface PostOrganizationMemberRolesRequest { */ roles: Array; } +/** + * + */ +export interface PostOrganizationsClientGrantsRequest { + /** + * A Client Grant ID to add to the organization. + * + */ + grant_id: string; +} /** * */ @@ -9470,7 +9586,7 @@ export interface PostOrganizationsRequestBranding { logo_url?: string; /** */ - colors?: GetOrganizations200ResponseOneOfInnerBrandingColors; + colors?: GetClientGrantsOrganizations200ResponseOneOfInnerBrandingColors; } /** * Connection to be added to the organization. @@ -12211,6 +12327,16 @@ export interface DeleteClientGrantsByIdRequest { */ id: string; } + +/** + * + */ +export const GetClientGrantsAllowAnyOrganizationEnum = { + true: true, +} as const; +export type GetClientGrantsAllowAnyOrganizationEnum = + (typeof GetClientGrantsAllowAnyOrganizationEnum)[keyof typeof GetClientGrantsAllowAnyOrganizationEnum]; + /** * */ @@ -12240,6 +12366,46 @@ export interface GetClientGrantsRequest { * */ client_id?: string; + /** + * Optional filter on allow_any_organization. + * + */ + allow_any_organization?: GetClientGrantsAllowAnyOrganizationEnum; +} +/** + * + */ +export interface GetClientGrantsOrganizationsRequest { + /** + * ID of the client grant + * + */ + id: string; + /** + * Page index of the results to return. First page is 0. + * + */ + page?: number; + /** + * Number of results per page. Defaults to 50. + * + */ + per_page?: number; + /** + * Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). + * + */ + include_totals?: boolean; + /** + * Optional Id from which to start selection. + * + */ + from?: string; + /** + * Number of results per page. Defaults to 50. + * + */ + take?: number; } /** * @@ -13193,6 +13359,21 @@ export interface GetLogsByIdRequest { */ id: string; } +/** + * + */ +export interface DeleteClientGrantsByGrantIdRequest { + /** + * Organization identifier + * + */ + id: string; + /** + * The Client Grant ID to remove from the organization + * + */ + grant_id: string; +} /** * */ @@ -13493,6 +13674,41 @@ export interface GetOrganizationsByIdRequest { */ id: string; } +/** + * + */ +export interface GetOrganizationsClientGrantsRequest { + /** + * Organization identifier + * + */ + id: string; + /** + * Optional filter on audience of the client grant. + * + */ + audience?: string; + /** + * Optional filter on client_id of the client grant. + * + */ + client_id?: string; + /** + * Page index of the results to return. First page is 0. + * + */ + page?: number; + /** + * Number of results per page. Defaults to 50. + * + */ + per_page?: number; + /** + * Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). + * + */ + include_totals?: boolean; +} /** * */ @@ -13563,6 +13779,16 @@ export interface PostOrganizationMemberRolesOperationRequest { */ user_id: string; } +/** + * + */ +export interface PostOrganizationsClientGrantsOperationRequest { + /** + * Organization identifier + * + */ + id: string; +} /** *