Skip to content

Commit

Permalink
Add support for organizations in client credentials to management api
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Nov 1, 2023
1 parent 57223c7 commit 1f21236
Show file tree
Hide file tree
Showing 4 changed files with 486 additions and 75 deletions.
65 changes: 65 additions & 0 deletions src/management/__generated/managers/client-grants-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import type {
ClientGrant,
ClientGrantCreate,
GetClientGrants200Response,
GetClientGrantsOrganizations200Response,
PatchClientGrantsByIdRequest,
GetClientGrants200ResponseOneOf,
GetClientGrantsOrganizations200ResponseOneOf,
GetClientGrantsOrganizations200ResponseOneOfInner,
DeleteClientGrantsByIdRequest,
GetClientGrantsRequest,
GetClientGrantsOrganizationsRequest,
PatchClientGrantsByIdOperationRequest,
} from '../models/index.js';

Expand Down Expand Up @@ -83,6 +87,10 @@ export class ClientGrantsManager extends BaseAPI {
key: 'client_id',
config: {},
},
{
key: 'allow_any_organization',
config: {},
},
]);

const response = await this.request(
Expand All @@ -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<ApiResponse<GetClientGrantsOrganizations200ResponseOneOf>>;
async getOrganizations(
requestParameters?: GetClientGrantsOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetClientGrantsOrganizations200ResponseOneOfInner>>>;
async getOrganizations(
requestParameters: GetClientGrantsOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetClientGrantsOrganizations200Response>> {
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
Expand Down
140 changes: 130 additions & 10 deletions src/management/__generated/managers/organizations-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,33 @@ 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,
GetMembers200ResponseOneOf,
GetMembers200ResponseOneOfInner,
GetOrganizationMemberRoles200ResponseOneOf,
GetOrganizationMemberRoles200ResponseOneOfInner,
GetOrganizations200ResponseOneOf,
GetClientGrantsOrganizations200ResponseOneOf,
GetOrganizationsClientGrants200ResponseOneOf,
DeleteClientGrantsByGrantIdRequest,
DeleteEnabledConnectionsByConnectionIdRequest,
DeleteInvitationsByInvitationIdRequest,
DeleteMembersOperationRequest,
Expand All @@ -39,12 +44,14 @@ import type {
GetOrganizationMemberRolesRequest,
GetOrganizationsRequest,
GetOrganizationsByIdRequest,
GetOrganizationsClientGrantsRequest,
PatchEnabledConnectionsByConnectionIdOperationRequest,
PatchOrganizationsByIdOperationRequest,
PostEnabledConnectionsOperationRequest,
PostInvitationsOperationRequest,
PostMembersOperationRequest,
PostOrganizationMemberRolesOperationRequest,
PostOrganizationsClientGrantsOperationRequest,
} from '../models/index.js';

const { BaseAPI } = runtime;
Expand All @@ -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<ApiResponse<void>> {
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
*
Expand Down Expand Up @@ -465,7 +496,7 @@ export class OrganizationsManager extends BaseAPI {
async getByName(
requestParameters: GetNameByNameRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOfInner>> {
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['name']);

const response = await this.request(
Expand Down Expand Up @@ -552,15 +583,15 @@ export class OrganizationsManager extends BaseAPI {
async getAll(
requestParameters: GetOrganizationsRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOf>>;
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOf>>;
async getAll(
requestParameters?: GetOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetOrganizations200ResponseOneOfInner>>>;
): Promise<ApiResponse<Array<GetClientGrantsOrganizations200ResponseOneOfInner>>>;
async getAll(
requestParameters: GetOrganizationsRequest = {},
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200Response>> {
): Promise<ApiResponse<GetClientGrantsOrganizations200Response>> {
const queryParameters = runtime.applyQueryParams(requestParameters, [
{
key: 'page',
Expand Down Expand Up @@ -610,7 +641,7 @@ export class OrganizationsManager extends BaseAPI {
async get(
requestParameters: GetOrganizationsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOfInner>> {
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);

const response = await this.request(
Expand All @@ -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<ApiResponse<GetOrganizationsClientGrants200ResponseOneOf>>;
async getClientGrants(
requestParameters?: GetOrganizationsClientGrantsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetOrganizationsClientGrants200ResponseOneOfInner>>>;
async getClientGrants(
requestParameters: GetOrganizationsClientGrantsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizationsClientGrants200Response>> {
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.
*
Expand Down Expand Up @@ -671,7 +759,7 @@ export class OrganizationsManager extends BaseAPI {
requestParameters: PatchOrganizationsByIdOperationRequest,
bodyParameters: PatchOrganizationsByIdRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOfInner>> {
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOfInner>> {
runtime.validateRequiredRequestParams(requestParameters, ['id']);

const headerParameters: runtime.HTTPHeaders = {};
Expand Down Expand Up @@ -831,7 +919,7 @@ export class OrganizationsManager extends BaseAPI {
async create(
bodyParameters: PostOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOfInner>> {
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOfInner>> {
const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';
Expand All @@ -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<ApiResponse<GetOrganizationsClientGrants200ResponseOneOfInner>> {
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);
}
}
8 changes: 4 additions & 4 deletions src/management/__generated/managers/users-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import type {
Log,
GetPermissions200ResponseOneOf,
GetPermissions200ResponseOneOfInner,
GetOrganizations200ResponseOneOf,
GetOrganizations200ResponseOneOfInner,
GetClientGrantsOrganizations200ResponseOneOf,
GetClientGrantsOrganizations200ResponseOneOfInner,
GetOrganizationMemberRoles200ResponseOneOf,
GetOrganizationMemberRoles200ResponseOneOfInner,
GetUsers200ResponseOneOf,
Expand Down Expand Up @@ -503,11 +503,11 @@ export class UsersManager extends BaseAPI {
async getUserOrganizations(
requestParameters: GetUserOrganizationsRequest & { include_totals: true },
initOverrides?: InitOverride
): Promise<ApiResponse<GetOrganizations200ResponseOneOf>>;
): Promise<ApiResponse<GetClientGrantsOrganizations200ResponseOneOf>>;
async getUserOrganizations(
requestParameters?: GetUserOrganizationsRequest,
initOverrides?: InitOverride
): Promise<ApiResponse<Array<GetOrganizations200ResponseOneOfInner>>>;
): Promise<ApiResponse<Array<GetClientGrantsOrganizations200ResponseOneOfInner>>>;
async getUserOrganizations(
requestParameters: GetUserOrganizationsRequest,
initOverrides?: InitOverride
Expand Down
Loading

0 comments on commit 1f21236

Please sign in to comment.