Skip to content

Commit 4f4db14

Browse files
authored
feat(iam/v1alpha1): add method to create a user (#775)
1 parent 1c7dc52 commit 4f4db14

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

packages/clients/src/api/iam/v1alpha1/api.gen.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
marshalCreateGroupRequest,
1616
marshalCreatePolicyRequest,
1717
marshalCreateSSHKeyRequest,
18+
marshalCreateUserRequest,
1819
marshalRemoveGroupMemberRequest,
1920
marshalSetGroupMembersRequest,
2021
marshalSetRulesRequest,
@@ -54,6 +55,7 @@ import type {
5455
CreateGroupRequest,
5556
CreatePolicyRequest,
5657
CreateSSHKeyRequest,
58+
CreateUserRequest,
5759
DeleteAPIKeyRequest,
5860
DeleteApplicationRequest,
5961
DeleteGroupRequest,
@@ -299,6 +301,26 @@ export class API extends ParentAPI {
299301
)}`,
300302
})
301303

304+
/**
305+
* Create a new user. Create a new user. You must define the `organization_id`
306+
* and the `email` in your request.
307+
*
308+
* @param request - The request {@link CreateUserRequest}
309+
* @returns A Promise of User
310+
*/
311+
createUser = (request: Readonly<CreateUserRequest>) =>
312+
this.client.fetch<User>(
313+
{
314+
body: JSON.stringify(
315+
marshalCreateUserRequest(request, this.client.settings),
316+
),
317+
headers: jsonContentHeaders,
318+
method: 'POST',
319+
path: `/iam/v1alpha1/users`,
320+
},
321+
unmarshalUser,
322+
)
323+
302324
protected pageOfListApplications = (
303325
request: Readonly<ListApplicationsRequest> = {},
304326
) =>

packages/clients/src/api/iam/v1alpha1/index.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type {
1313
CreateGroupRequest,
1414
CreatePolicyRequest,
1515
CreateSSHKeyRequest,
16+
CreateUserRequest,
1617
DeleteAPIKeyRequest,
1718
DeleteApplicationRequest,
1819
DeleteGroupRequest,

packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import type {
1818
CreateGroupRequest,
1919
CreatePolicyRequest,
2020
CreateSSHKeyRequest,
21+
CreateUserRequest,
2122
Group,
2223
JWT,
2324
ListAPIKeysResponse,
@@ -507,6 +508,14 @@ export const marshalCreateSSHKeyRequest = (
507508
public_key: request.publicKey,
508509
})
509510

511+
export const marshalCreateUserRequest = (
512+
request: CreateUserRequest,
513+
defaults: DefaultValues,
514+
): Record<string, unknown> => ({
515+
email: request.email,
516+
organization_id: request.organizationId ?? defaults.defaultOrganizationId,
517+
})
518+
510519
export const marshalRemoveGroupMemberRequest = (
511520
request: RemoveGroupMemberRequest,
512521
defaults: DefaultValues,

packages/clients/src/api/iam/v1alpha1/types.gen.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,13 @@ export type DeleteUserRequest = {
510510
userId: string
511511
}
512512

513+
export type CreateUserRequest = {
514+
/** ID of the Organization. */
515+
organizationId?: string
516+
/** Email of the user. */
517+
email: string
518+
}
519+
513520
export type ListApplicationsRequest = {
514521
/** Criteria for sorting results. */
515522
orderBy?: ListApplicationsRequestOrderBy

0 commit comments

Comments
 (0)