Skip to content

Commit bfb0ab6

Browse files
feat(iam): add support for creating member within a CreateUser (#1416)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 5fb4b17 commit bfb0ab6

File tree

5 files changed

+62
-5
lines changed

5 files changed

+62
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export class API extends ParentAPI {
330330
* @param request - The request {@link CreateUserRequest}
331331
* @returns A Promise of User
332332
*/
333-
createUser = (request: Readonly<CreateUserRequest>) =>
333+
createUser = (request: Readonly<CreateUserRequest> = {}) =>
334334
this.client.fetch<User>(
335335
{
336336
body: JSON.stringify(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type {
1515
CreatePolicyRequest,
1616
CreateSSHKeyRequest,
1717
CreateUserRequest,
18+
CreateUserRequestMember,
1819
DeleteAPIKeyRequest,
1920
DeleteApplicationRequest,
2021
DeleteGroupRequest,

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
CreatePolicyRequest,
2121
CreateSSHKeyRequest,
2222
CreateUserRequest,
23+
CreateUserRequestMember,
2324
EncodedJWT,
2425
Group,
2526
JWT,
@@ -239,6 +240,7 @@ export const unmarshalUser = (data: unknown): User => {
239240
twoFactorEnabled: data.two_factor_enabled,
240241
type: data.type,
241242
updatedAt: unmarshalDate(data.updated_at),
243+
username: data.username,
242244
} as User
243245
}
244246

@@ -569,13 +571,32 @@ export const marshalCreateSSHKeyRequest = (
569571
public_key: request.publicKey,
570572
})
571573

574+
const marshalCreateUserRequestMember = (
575+
request: CreateUserRequestMember,
576+
defaults: DefaultValues,
577+
): Record<string, unknown> => ({
578+
email: request.email,
579+
password: request.password,
580+
send_password_email: request.sendPasswordEmail,
581+
username: request.username,
582+
})
583+
572584
export const marshalCreateUserRequest = (
573585
request: CreateUserRequest,
574586
defaults: DefaultValues,
575587
): Record<string, unknown> => ({
576-
email: request.email,
577588
organization_id: request.organizationId ?? defaults.defaultOrganizationId,
578589
tags: request.tags,
590+
...resolveOneOf<string | Record<string, unknown>>([
591+
{ param: 'email', value: request.email },
592+
{
593+
param: 'member',
594+
value:
595+
request.member !== undefined
596+
? marshalCreateUserRequestMember(request.member, defaults)
597+
: undefined,
598+
},
599+
]),
579600
})
580601

581602
export const marshalRemoveGroupMemberRequest = (

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export type PermissionSetScopeType =
8787

8888
export type UserStatus = 'unknown_status' | 'invitation_pending' | 'activated'
8989

90-
export type UserType = 'unknown_type' | 'guest' | 'owner'
90+
export type UserType = 'unknown_type' | 'guest' | 'owner' | 'member'
9191

9292
export interface RuleSpecs {
9393
/** Names of permission sets bound to the rule. */
@@ -110,6 +110,17 @@ export interface RuleSpecs {
110110
organizationId?: string
111111
}
112112

113+
export interface CreateUserRequestMember {
114+
/** Email of the user to create. */
115+
email: string
116+
/** Whether or not to send an email containing the member's password. */
117+
sendPasswordEmail: boolean
118+
/** The member's username. */
119+
username: string
120+
/** The member's password. */
121+
password: string
122+
}
123+
113124
export interface JWT {
114125
/** JWT ID. */
115126
jti: string
@@ -372,6 +383,8 @@ export interface User {
372383
id: string
373384
/** Email of user. */
374385
email: string
386+
/** User identifier unique to the Organization. */
387+
username: string
375388
/** Date user was created. */
376389
createdAt?: Date
377390
/** Date of last user update. */
@@ -535,10 +548,20 @@ export type CreateSSHKeyRequest = {
535548
export type CreateUserRequest = {
536549
/** ID of the Organization. */
537550
organizationId?: string
538-
/** Email of the user. */
539-
email: string
551+
/**
552+
* Email of the user.
553+
*
554+
* One-of ('type'): at most one of 'email', 'member' could be set.
555+
*/
556+
email?: string
540557
/** Tags associated with the user. */
541558
tags?: string[]
559+
/**
560+
* A new IAM Member to create.
561+
*
562+
* One-of ('type'): at most one of 'email', 'member' could be set.
563+
*/
564+
member?: CreateUserRequestMember
542565
}
543566

544567
export type DeleteAPIKeyRequest = {

packages/clients/src/api/iam/v1alpha1/validation-rules.gen.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ export const CreateSSHKeyRequest = {
5555
},
5656
}
5757

58+
export const CreateUserRequestMember = {
59+
password: {
60+
ignoreEmpty: true,
61+
maxLength: 72,
62+
},
63+
username: {
64+
maxLength: 64,
65+
minLength: 2,
66+
pattern: /^[a-zA-Z0-9._-]+$/,
67+
},
68+
}
69+
5870
export const GetQuotumRequest = {
5971
quotumName: {
6072
minLength: 1,

0 commit comments

Comments
 (0)