diff --git a/packages/clients/src/api/iam/v1alpha1/api.gen.ts b/packages/clients/src/api/iam/v1alpha1/api.gen.ts index 108ec7086..8d044f608 100644 --- a/packages/clients/src/api/iam/v1alpha1/api.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/api.gen.ts @@ -23,6 +23,7 @@ import { marshalUpdateAPIKeyRequest, marshalUpdateApplicationRequest, marshalUpdateGroupRequest, + marshalUpdateOrganizationSecuritySettingsRequest, marshalUpdatePolicyRequest, marshalUpdateSSHKeyRequest, marshalUpdateUserPasswordRequest, @@ -45,6 +46,7 @@ import { unmarshalListSSHKeysResponse, unmarshalListUsersResponse, unmarshalLog, + unmarshalOrganizationSecuritySettings, unmarshalPolicy, unmarshalQuotum, unmarshalSSHKey, @@ -77,6 +79,7 @@ import type { GetGroupRequest, GetJWTRequest, GetLogRequest, + GetOrganizationSecuritySettingsRequest, GetPolicyRequest, GetQuotumRequest, GetSSHKeyRequest, @@ -109,6 +112,7 @@ import type { ListUsersResponse, LockUserRequest, Log, + OrganizationSecuritySettings, Policy, Quotum, RemoveGroupMemberRequest, @@ -120,6 +124,7 @@ import type { UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, UpdateUserPasswordRequest, @@ -1276,4 +1281,48 @@ export class API extends ParentAPI { }, unmarshalLog, ) + + /** + * Get security settings of an Organization. Retrieve information about the + * security settings of an Organization, specified by the `organization_id` + * parameter. + * + * @param request - The request {@link GetOrganizationSecuritySettingsRequest} + * @returns A Promise of OrganizationSecuritySettings + */ + getOrganizationSecuritySettings = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/iam/v1alpha1/organizations/${validatePathParam('organizationId', request.organizationId ?? this.client.settings.defaultOrganizationId)}/security-settings`, + }, + unmarshalOrganizationSecuritySettings, + ) + + /** + * Update the security settings of an Organization. + * + * @param request - The request + * {@link UpdateOrganizationSecuritySettingsRequest} + * @returns A Promise of OrganizationSecuritySettings + */ + updateOrganizationSecuritySettings = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalUpdateOrganizationSecuritySettingsRequest( + request, + this.client.settings, + ), + ), + headers: jsonContentHeaders, + method: 'PATCH', + path: `/iam/v1alpha1/organizations/${validatePathParam('organizationId', request.organizationId ?? this.client.settings.defaultOrganizationId)}/security-settings`, + }, + unmarshalOrganizationSecuritySettings, + ) } diff --git a/packages/clients/src/api/iam/v1alpha1/index.gen.ts b/packages/clients/src/api/iam/v1alpha1/index.gen.ts index 991ba5f4f..68b33821c 100644 --- a/packages/clients/src/api/iam/v1alpha1/index.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/index.gen.ts @@ -29,6 +29,7 @@ export type { GetGroupRequest, GetJWTRequest, GetLogRequest, + GetOrganizationSecuritySettingsRequest, GetPolicyRequest, GetQuotumRequest, GetSSHKeyRequest, @@ -75,6 +76,7 @@ export type { Log, LogAction, LogResourceType, + OrganizationSecuritySettings, PermissionSet, PermissionSetScopeType, Policy, @@ -90,6 +92,7 @@ export type { UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, UpdateUserPasswordRequest, diff --git a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts index 3d006df06..a0d1539d8 100644 --- a/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/marshalling.gen.ts @@ -38,6 +38,7 @@ import type { ListSSHKeysResponse, ListUsersResponse, Log, + OrganizationSecuritySettings, PermissionSet, Policy, Quotum, @@ -51,6 +52,7 @@ import type { UpdateAPIKeyRequest, UpdateApplicationRequest, UpdateGroupRequest, + UpdateOrganizationSecuritySettingsRequest, UpdatePolicyRequest, UpdateSSHKeyRequest, UpdateUserPasswordRequest, @@ -503,6 +505,22 @@ export const unmarshalListUsersResponse = ( } as ListUsersResponse } +export const unmarshalOrganizationSecuritySettings = ( + data: unknown, +): OrganizationSecuritySettings => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'OrganizationSecuritySettings' failed as data isn't a dictionary.`, + ) + } + + return { + enforcePasswordRenewal: data.enforce_password_renewal, + gracePeriodDuration: data.grace_period_duration, + loginAttemptsBeforeLocked: data.login_attempts_before_locked, + } as OrganizationSecuritySettings +} + export const unmarshalSetRulesResponse = (data: unknown): SetRulesResponse => { if (!isJSONObject(data)) { throw new TypeError( @@ -696,6 +714,15 @@ export const marshalUpdateGroupRequest = ( tags: request.tags, }) +export const marshalUpdateOrganizationSecuritySettingsRequest = ( + request: UpdateOrganizationSecuritySettingsRequest, + defaults: DefaultValues, +): Record => ({ + enforce_password_renewal: request.enforcePasswordRenewal, + grace_period_duration: request.gracePeriodDuration, + login_attempts_before_locked: request.loginAttemptsBeforeLocked, +}) + export const marshalUpdatePolicyRequest = ( request: UpdatePolicyRequest, defaults: DefaultValues, diff --git a/packages/clients/src/api/iam/v1alpha1/types.gen.ts b/packages/clients/src/api/iam/v1alpha1/types.gen.ts index 9d7d78179..d778504b0 100644 --- a/packages/clients/src/api/iam/v1alpha1/types.gen.ts +++ b/packages/clients/src/api/iam/v1alpha1/types.gen.ts @@ -671,6 +671,11 @@ export type GetLogRequest = { logId: string } +export type GetOrganizationSecuritySettingsRequest = { + /** ID of the Organization. */ + organizationId?: string +} + export type GetPolicyRequest = { /** Id of policy to search. */ policyId: string @@ -988,6 +993,15 @@ export type LockUserRequest = { userId: string } +export interface OrganizationSecuritySettings { + /** Defines whether password renewal is enforced during first login. */ + enforcePasswordRenewal: boolean + /** Duration of the grace period to renew password or enable MFA. */ + gracePeriodDuration?: string + /** Number of login attempts before the account is locked. */ + loginAttemptsBeforeLocked: number +} + export type RemoveGroupMemberRequest = { /** ID of the group. */ groupId: string @@ -1062,6 +1076,17 @@ export type UpdateGroupRequest = { tags?: string[] } +export type UpdateOrganizationSecuritySettingsRequest = { + /** ID of the Organization. */ + organizationId?: string + /** Defines whether password renewal is enforced during first login. */ + enforcePasswordRenewal?: boolean + /** Duration of the grace period to renew password or enable MFA. */ + gracePeriodDuration?: string + /** Number of login attempts before the account is locked. */ + loginAttemptsBeforeLocked?: number +} + export type UpdatePolicyRequest = { /** Id of policy to update. */ policyId: string