From 3f19f5f1fc9f22dfbc1ccf99d3e858e992be5849 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 31 Jul 2023 14:25:43 +0200 Subject: [PATCH] feat(IAM Identity): Add support for IAM enterprise Signed-off-by: Michael Beck --- examples/iam-identity.v1.test.js | 968 ++++- iam-identity/v1.ts | 4076 ++++++++++++++++++---- test/integration/iam-identity.v1.test.js | 698 +++- test/unit/iam-identity.v1.test.js | 2999 +++++++++++++++- 4 files changed, 8050 insertions(+), 691 deletions(-) diff --git a/examples/iam-identity.v1.test.js b/examples/iam-identity.v1.test.js index 9a16150d..e9755fec 100644 --- a/examples/iam-identity.v1.test.js +++ b/examples/iam-identity.v1.test.js @@ -34,6 +34,9 @@ const { expectToBePromise } = require('ibm-cloud-sdk-core/lib/sdk-test-helpers') // IAM_IDENTITY_APIKEY= // IAM_IDENTITY_ACCOUNT_ID= // IAM_IDENTITY_IAM_ID= +// IAM_IDENTITY_IAM_ID_MEMBER= +// IAM_IDENTITY_ENTERPISE_ACCOUNT_ID= +// IAM_IDENTITY_ENTERPISE_SUBACCOUNT_ID= // // These configuration properties can be exported as environment variables, or stored // in a configuration file and then: @@ -52,7 +55,7 @@ const consoleLogMock = jest.spyOn(console, 'log'); const consoleWarnMock = jest.spyOn(console, 'warn'); describe('IamIdentityV1', () => { - jest.setTimeout(30000); + jest.setTimeout(300000); // begin-common @@ -63,12 +66,15 @@ describe('IamIdentityV1', () => { const config = readExternalSources(IamIdentityV1.DEFAULT_SERVICE_NAME); const apikeyName = 'Example-ApiKey'; const serviceIdName = 'Example-ServiceId'; + const realmName = 'https://sdk.test.realm/1234'; let accountId = config.accountId; let iamId = config.iamId; let iamIdMember = config.iamIdMember; let iamApikey = config.apikey; - + let enterpriseAccountId = config.enterpriseAccountId; + let enterpriseSubAccountId = config.enterpriseSubaccountId; + let apikeyId = null; let apikeyEtag = null; @@ -89,7 +95,20 @@ describe('IamIdentityV1', () => { let reportReference = null; let reportReferenceMfa=null; - test('createApiKey request example', async () => { + let profileTemplateId; + let profileTemplateVersion; + let profileTemplateEtag; + let profileTemplateAssignmentId; + let profileTemplateAssignmentEtag; + + let accountSettingsTemplateId; + let accountSettingsTemplateVersion; + let accountSettingsTemplateEtag; + let accountSettingsTemplateAssignmentId; + let accountSettingsTemplateAssignmentEtag; + + +test('createApiKey request example', async () => { consoleLogMock.mockImplementation(output => { originalLog(output); @@ -666,7 +685,7 @@ describe('IamIdentityV1', () => { const params = { profileId: profileId, type: 'Profile-SAML', - realmName: 'https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', + realmName: realmName, expiration: 43200, conditions, }; @@ -768,7 +787,7 @@ describe('IamIdentityV1', () => { ruleId: claimRuleId, ifMatch: claimRuleEtag, type: 'Profile-SAML', - realmName: 'https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20', + realmName: realmName, expiration: 33200, conditions, }; @@ -1327,4 +1346,943 @@ describe('IamIdentityV1', () => { } // end-get_mfa_status }); + + test('scenarioProfileTemplateEx()', async () => { + await createProfileTemplateEx(); + }); + + async function createProfileTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('createProfileTemplate() result:'); + // begin-create_profile_template + const condition = { + claim: "blueGroups", + operator: "EQUALS", + value: "\"cloud-docs-dev\"", + } + const claimRule = { + name: "My Rule", + realm_name: realmName, + type: 'Profile-SAML', + expiration: 43200, + conditions: [condition], + } + const profile = { + rules: [claimRule], + name: "Profile-From-Example-Template", + description: "Trusted profile created from a template", + } + const templateParams = { + name: "Example-Profile-Template", + description: "IAM enterprise trusted profile template example", + accountId: enterpriseAccountId, + profile: profile, + } + + try { + const res = await iamIdentityService.createProfileTemplate(templateParams); + profileTemplateEtag = res.headers.etag; + const { result } = res; + profileTemplateId = result.id; + profileTemplateVersion = result.version; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_profile_template + + await getProfileTemplateEx(); + } + + async function getProfileTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getProfileTemplate() result:'); + // begin-get_profile_template_version + const params = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + try { + const res = await iamIdentityService.getProfileTemplateVersion(params); + profileTemplateEtag = res.headers.etag; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_profile_template_version + + await listProfileTemplatesEx(); + } + + async function listProfileTemplatesEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listProfileTemplates() result:'); + // begin-list_profile_templates + const params = { + accountId: enterpriseAccountId, + } + try { + const res = await iamIdentityService.listProfileTemplates(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-list_profile_templates + + await updateProfileTemplateEx(); + } + + async function updateProfileTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('updateProfileTemplate() result:'); + // begin-update_profile_template_version + const params = { + accountId: enterpriseAccountId, + templateId: profileTemplateId, + version: profileTemplateVersion, + ifMatch: profileTemplateEtag, + name: "Example-Profile-Template", + description: "IAM enterprise trusted profile template example - updated", + } + try { + const res = await iamIdentityService.updateProfileTemplateVersion(params); + profileTemplateEtag = res.headers.etag; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-update_profile_template_version + + await assignProfileTemplateEx(); + } + + async function assignProfileTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('commitProfileTemplate() result:'); + // begin-commit_profile_template + const commitParams = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + try { + const res = await iamIdentityService.commitProfileTemplate(commitParams); + } catch (err) { + console.warn(err); + } + // end-commit_profile_template + + originalLog('createProfileTemplateAssignment() result:'); + // begin-create_trusted_profile_assignment + const assignParams = { + templateId: profileTemplateId, + templateVersion: profileTemplateVersion, + targetType: "Account", + target: enterpriseSubAccountId, + } + + try { + const assRes = await iamIdentityService.createTrustedProfileAssignment(assignParams); + const { result } = assRes; + profileTemplateAssignmentId = result.id; + profileTemplateAssignmentEtag= assRes.headers.etag; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_trusted_profile_assignment + + await getProfileTemplateAssignmentsEx(); + } + + async function getProfileTemplateAssignmentsEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getProfileTemplateAssignments() result:'); + // begin-get_trusted_profile_assignment + const params = { + assignmentId: profileTemplateAssignmentId, + } + try { + const res = await iamIdentityService.getTrustedProfileAssignment(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_trusted_profile_assignment + + await listProfileTemplateAssignmentsEx(); + } + + async function listProfileTemplateAssignmentsEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listProfileTemplateAssignments() result:'); + // begin-list_trusted_profile_assignments + const params = { + accountId: enterpriseAccountId, + templateId: profileTemplateId, + } + try { + const res = await iamIdentityService.listTrustedProfileAssignments(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-list_trusted_profile_assignments + + await createNewProfileTemplateVersionEx(); + } + + async function createNewProfileTemplateVersionEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('createNewProfileTemplateVersion() result:'); + // begin-create_profile_template_version + const condition = { + claim: "blueGroups", + operator: "EQUALS", + value: "\"cloud-docs-dev\"", + } + const claimRule = { + name: "My Rule", + realm_name: realmName, + type: 'Profile-SAML', + expiration: 43200, + conditions: [condition], + } + const identity = { + identifier: iamId, + accounts: [enterpriseAccountId], + type: "user", + description: "Identity description", + } + const profile = { + rules: [claimRule], + name: "Profile-From-Example-Template", + description: "Trusted profile created from a template - new version", + identities: [identity], + } + const templateParams = { + templateId: profileTemplateId, + name: "Example-Profile-Template", + description: "IAM enterprise trusted profile template example - new version", + accountId: enterpriseAccountId, + profile: profile, + } + + try { + const res = await iamIdentityService.createProfileTemplateVersion(templateParams); + const { result } = res; + profileTemplateVersion = result.version; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_profile_template_version + + await getLatestProfileTemplateVersionEx(); + } + + async function getLatestProfileTemplateVersionEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getLatestProfileTemplateVersion() result:'); + // begin-get_latest_profile_template_version + const params = { + templateId: profileTemplateId, + } + try { + const res = await iamIdentityService.getLatestProfileTemplateVersion(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_latest_profile_template_version + + await listProfileTemplateVersionsEx(); + } + + async function listProfileTemplateVersionsEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listProfileTemplateVersions() result:'); + // begin-list_versions_of_profile_template + const params = { + templateId: profileTemplateId, + } + try { + const res = await iamIdentityService.listVersionsOfProfileTemplate(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_list_versions_of_profile_template + + await updateProfileTemplateAssignmentEx(); + } + + async function updateProfileTemplateAssignmentEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('updateProfileTemplateAssignment() result:'); + + const commitParams = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + + const res = await iamIdentityService.commitProfileTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await waitUntilTrustedProfileAssignmentFinishedEx(profileTemplateAssignmentId); + + // begin-update_trusted_profile_assignment + const assignParams = { + assignmentId: profileTemplateAssignmentId, + templateVersion: profileTemplateVersion, + ifMatch: profileTemplateAssignmentEtag, + } + + try { + const assRes = await iamIdentityService.updateTrustedProfileAssignment(assignParams); + console.log(JSON.stringify(assRes.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-update_trusted_profile_assignment + + await deleteProfileTemplateAssignmentEx(); + } + + async function deleteProfileTemplateAssignmentEx() { + + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('deleteProfileTemplateAssignment() result:'); + + await waitUntilTrustedProfileAssignmentFinishedEx(profileTemplateAssignmentId); + + // begin-delete_trusted_profile_assignment + const params = { + assignmentId: profileTemplateAssignmentId, + } + try { + const res = await iamIdentityService.deleteTrustedProfileAssignment(params); + } catch (err) { + console.warn(err); + } + // end-delete_trusted_profile_assignment + + await deleteProfileTemplateVersionEx(); + } + + async function deleteProfileTemplateVersionEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('deleteProfileTemplateVersion() result:'); + // begin-delete_profile_template_version + const params = { + templateId: profileTemplateId, + version: 1, + } + try { + const res = await iamIdentityService.deleteProfileTemplateVersion(params); + } catch (err) { + console.warn(err); + } + // end-delete_profile_template_version + + await testDeleteProfileTemplateEx(); + } + + async function testDeleteProfileTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('deleteProfileTemplateVersion() result:'); + + await waitUntilTrustedProfileAssignmentFinishedEx(profileTemplateAssignmentId); + + // begin-delete_all_versions_of_profile_template + const params = { + templateId: profileTemplateId, + } + try { + const res = await iamIdentityService.deleteAllVersionsOfProfileTemplate(params); + } catch (err) { + console.warn(err); + } + // end-delete_all_versions_of_profile_template + } + + test('scenarioAccountSettingsTemplateEx()', async () => { + await createAccountSettingsTemplateEx(); + }); + + async function createAccountSettingsTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('createAccountSettingsTemplate() result:'); + + // begin-create_account_settings_template + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "3000", + } + const templateParams = { + name: "Example-Account-Settings-Template", + description: "IAM enterprise account settings template example", + accountId: enterpriseAccountId, + accountSettings: settings, + } + + try { + const res = await iamIdentityService.createAccountSettingsTemplate(templateParams); + accountSettingsTemplateEtag = res.headers.etag; + const { result } = res; + accountSettingsTemplateId = result.id; + accountSettingsTemplateVersion = result.version; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_account_settings_template + + await getAccountSettingsTemplateEx(); + } + + async function getAccountSettingsTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getAccountSettingsTemplate() result:'); + + // begin-get_account_settings_template_version + const params = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + try { + const res = await iamIdentityService.getAccountSettingsTemplateVersion(params); + accountSettingsTemplateEtag = res.headers.etag; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_account_settings_template_version + + await listAccountSettingsTemplatesEx(); + } + + async function listAccountSettingsTemplatesEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listAccountSettingsTemplates() result:'); + + // begin-list_account_settings_templates + const params = { + accountId: enterpriseAccountId, + } + try { + const res = await iamIdentityService.listAccountSettingsTemplates(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-list_account_settings_templates + + await updateAccountSettingsTemplateEx(); + } + + async function updateAccountSettingsTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('updateAccountSettingsTemplate() result:'); + + // begin-update_account_settings_template_version + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "3000", + } + const params = { + accountId: enterpriseAccountId, + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + ifMatch: accountSettingsTemplateEtag, + name: "Example-Account-Settings-Template", + description: "IAM enterprise account settings template example - updated", + accountSettings: settings, + } + try { + const res = await iamIdentityService.updateAccountSettingsTemplateVersion(params); + accountSettingsTemplateEtag = res.headers.etag; + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-update_account_settings_template_version + + await assignAccountSettingsTemplateEx(); + } + + async function assignAccountSettingsTemplateEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('commitAccountSettingsTemplate() result:'); + + // begin-commit_account_settings_template + const commitParams = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + try { + const res = await iamIdentityService.commitAccountSettingsTemplate(commitParams); + } catch (err) { + console.warn(err); + } + // end-commit_account_settings_template + + originalLog('createAccountSettingsAssignment() result:'); + + // begin-create_account_settings_assignment + const assignParams = { + templateId: accountSettingsTemplateId, + templateVersion: accountSettingsTemplateVersion, + targetType: "Account", + target: enterpriseSubAccountId, + } + + try { + const assRes = await iamIdentityService.createAccountSettingsAssignment(assignParams); + const { result } = assRes; + accountSettingsTemplateAssignmentId = result.id; + accountSettingsTemplateAssignmentEtag= assRes.headers.etag; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_account_settings_assignment + + await listAccountSettingsTemplateAssignmentsEx(); + } + + async function listAccountSettingsTemplateAssignmentsEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listAccountSettingsTemplateAssignments() result:'); + + // begin-list_account_settings_assignments + const params = { + accountId: enterpriseAccountId, + templateId: accountSettingsTemplateId, + } + try { + const res = await iamIdentityService.listAccountSettingsAssignments(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-list_account_settings_assignments + + await createNewAccountSettingsTemplateVersionEx(); + } + + async function createNewAccountSettingsTemplateVersionEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('createNewAccountSettingsTemplateVersion() result:'); + + // begin-create_account_settings_template_version + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "2600", + restrict_create_platform_apikey: "RESTRICTED", + restrict_create_service_id: "RESTRICTED", + } + const templateParams = { + templateId: accountSettingsTemplateId, + name: "Example-Account-Settings-Template", + description: "IAM enterprise account settings template example - new version", + accountId: enterpriseAccountId, + accountSettings: settings, + } + + try { + const res = await iamIdentityService.createAccountSettingsTemplateVersion(templateParams); + const { result } = res; + accountSettingsTemplateVersion = result.version; + console.log(JSON.stringify(result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-create_account_settings_template_version + + await getLatestAccountSettingsTemplateVersionEx(); + } + + async function getLatestAccountSettingsTemplateVersionEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('getLatestAccountSettingsTemplateVersion() result:'); + + // begin-get_latest_account_settings_template_version + const params = { + templateId: accountSettingsTemplateId, + } + try { + const res = await iamIdentityService.getLatestAccountSettingsTemplateVersion(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-get_latest_account_settings_template_version + + await listAccountSettingsTemplateVersionsEx(); + } + + async function listAccountSettingsTemplateVersionsEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('listAccountSettingsTemplateVersions() result:'); + + // begin-list_versions_of_account_settings_template + const params = { + templateId: accountSettingsTemplateId, + } + try { + const res = await iamIdentityService.listVersionsOfAccountSettingsTemplate(params); + console.log(JSON.stringify(res.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-list_versions_of_account_settings_template + + await updateAccountSettingsTemplateAssignmentEx(); + } + + async function updateAccountSettingsTemplateAssignmentEx() { + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('updateAccountSettingsTemplateAssignment() result:'); + + const commitParams = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + + const res = await iamIdentityService.commitAccountSettingsTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await waitUntilAccountSettingsAssignmentFinishedEx(accountSettingsTemplateAssignmentId); + + // begin-update_account_settings_assignment + const assignParams = { + assignmentId: accountSettingsTemplateAssignmentId, + templateVersion: accountSettingsTemplateVersion, + ifMatch: accountSettingsTemplateAssignmentEtag, + } + + try { + const assRes = await iamIdentityService.updateAccountSettingsAssignment(assignParams); + console.log(JSON.stringify(assRes.result, null, 2)); + } catch (err) { + console.warn(err); + } + // end-update_account_settings_assignment + + await deleteAccountSettingsTemplateAssignmentEx(); + } + + async function deleteAccountSettingsTemplateAssignmentEx() { + + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('deleteAccountSettingsTemplateAssignment() result:'); + + await waitUntilAccountSettingsAssignmentFinishedEx(accountSettingsTemplateAssignmentId); + + // begin-delete_account_settings_assignment + const params = { + assignmentId: accountSettingsTemplateAssignmentId, + } + try { + const res = await iamIdentityService.deleteAccountSettingsAssignment(params); + } catch (err) { + console.warn(err); + } + // end-delete_account_settings_assignment + + await deleteAccountSettingsTemplateVersionEx(); + } + + async function deleteAccountSettingsTemplateVersionEx() { + + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('deleteAccountSettingsTemplateVersion() result:'); + // begin-delete_account_settings_template_version + const params = { + templateId: accountSettingsTemplateId, + version: 1, + } + try { + const res = await iamIdentityService.deleteAccountSettingsTemplateVersion(params); + } catch (err) { + console.warn(err); + } + // end-delete_account_settings_template_version + + await testDeleteAccountSettingsTemplateEx(); + } + + async function testDeleteAccountSettingsTemplateEx() { + + consoleLogMock.mockImplementation(output => { + originalLog(output); + }); + consoleWarnMock.mockImplementation(output => { + originalWarn(output); + expect(true).toBeFalsy(); + }); + + originalLog('testDeleteAccountSettingsTemplate() result:'); + await waitUntilAccountSettingsAssignmentFinishedEx(accountSettingsTemplateAssignmentId); + + // begin-delete_all_versions_of_account_settings_template + const params = { + templateId: accountSettingsTemplateId, + } + try { + const res = await iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(params); + } catch (err) { + console.warn(err); + } + // end-delete_all_versions_of_account_settings_template + } + + function isFinishedEx(status) { + return ("succeeded" === status.toLowerCase() || "failed" === status.toLowerCase()); + } + + async function waitUntilTrustedProfileAssignmentFinishedEx(assignmentId) { + let finished = false; + const params = { + assignmentId: assignmentId, + } + + for (let i = 0; i < 60; i++) { + try { + const response = await iamIdentityService.getTrustedProfileAssignment(params); + const { result } = response; + finished = isFinishedEx(result.status); + if (finished) { + profileTemplateAssignmentEtag= response.headers.etag; + finished = true; + break; + } + await sleepEx(10000); + } catch (e) { + if (e.status === 404) { + finished = true; + break; + } + } + } + expect(finished).toBe(true); + } + + async function waitUntilAccountSettingsAssignmentFinishedEx(assignmentId) { + let finished = false; + const params = { + assignmentId: assignmentId, + } + + for (let i = 0; i < 60; i++) { + try { + const response = await iamIdentityService.getAccountSettingsAssignment(params); + const { result } = response; + finished = isFinishedEx(result.status); + if (finished) { + accountSettingsTemplateAssignmentEtag= response.headers.etag; + finished = true; + break; + } + await sleepEx(10000); + } catch (e) { + if (e.status === 404) { + finished = true; + break; + } + } + } + expect(finished).toBe(true); + } + + function sleepEx(ms) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); + } + }); diff --git a/iam-identity/v1.ts b/iam-identity/v1.ts index 2b1f4d91..21b90bc7 100644 --- a/iam-identity/v1.ts +++ b/iam-identity/v1.ts @@ -15,7 +15,7 @@ */ /** - * IBM OpenAPI SDK Code Generator Version: 3.72.0-5d70f2bb-20230511-203609 + * IBM OpenAPI SDK Code Generator Version: 3.74.0-89f1dbab-20230630-160213 */ import * as extend from 'extend'; @@ -105,18 +105,18 @@ class IamIdentityV1 extends BaseService { * space developer in order to manage service IDs of the entity. * * @param {Object} [params] - The parameters to send to the service. - * @param {string} [params.accountId] - Account ID of the API keys to query. If a service IAM ID is specified in + * @param {string} [params.accountId] - Account ID of the API keys(s) to query. If a service IAM ID is specified in * iam_id then account_id must match the account of the IAM ID. If a user IAM ID is specified in iam_id then then * account_id must match the account of the Authorization token. - * @param {string} [params.iamId] - IAM ID of the API keys to be queried. The IAM ID may be that of a user or a + * @param {string} [params.iamId] - IAM ID of the API key(s) to be queried. The IAM ID may be that of a user or a * service. For a user IAM ID iam_id must match the Authorization token. * @param {number} [params.pagesize] - Optional size of a single page. Default is 20 items per page. Valid range is 1 * to 100. * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. * Default is start with first page. - * @param {string} [params.scope] - Optional parameter to define the scope of the queried API keys. Can be 'entity' + * @param {string} [params.scope] - Optional parameter to define the scope of the queried API Keys. Can be 'entity' * (default) or 'account'. - * @param {string} [params.type] - Optional parameter to filter the type of the queried API keys. Can be 'user' or + * @param {string} [params.type] - Optional parameter to filter the type of the queried API Keys. Can be 'user' or * 'serviceid'. * @param {string} [params.sort] - Optional sort property, valid values are name, description, created_at and * created_by. If specified, the items are sorted by the value of this property. @@ -197,8 +197,8 @@ class IamIdentityV1 extends BaseService { * @param {string} [params.accountId] - The account ID of the API key. * @param {string} [params.apikey] - You can optionally passthrough the API key value for this API key. If passed, NO * validation of that apiKey value is done, i.e. the value can be non-URL safe. If omitted, the API key management - * will create an URL safe opaque API key value. The value of the API key is checked for uniqueness. Please ensure - * enough variations when passing in this value. + * will create an URL safe opaque API key value. The value of the API key is checked for uniqueness. Ensure enough + * variations when passing in this value. * @param {boolean} [params.storeValue] - Send true or false to set whether the API key value is retrievable in the * future by using the Get details of an API key request. If you create an API key for a user, you must specify * `false` or omit the value. We don't allow storing of API keys for users. @@ -324,7 +324,7 @@ class IamIdentityV1 extends BaseService { * @param {string} params.id - Unique ID of the API key. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {boolean} [params.includeActivity] - Defines if the entity's activity is included in the response. - * Retrieving activity data is an expensive operation, so please only request this when needed. + * Retrieving activity data is an expensive operation, so only request this when needed. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -574,7 +574,7 @@ class IamIdentityV1 extends BaseService { * * Returns a list of service IDs. Users can manage user API keys for themself, or service ID API keys for service IDs * that are bound to an entity they have access to. Note: apikey details are only included in the response when - * creating a Service ID with an api key. + * creating a Service ID with an apikey. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - Account ID of the service ID(s) to query. This parameter is required (unless @@ -723,13 +723,13 @@ class IamIdentityV1 extends BaseService { * * Returns the details of a service ID. Users can manage user API keys for themself, or service ID API keys for * service IDs that are bound to an entity they have access to. Note: apikey details are only included in the response - * when creating a Service ID with an api key. + * when creating a Service ID with an apikey. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {boolean} [params.includeActivity] - Defines if the entity's activity is included in the response. - * Retrieving activity data is an expensive operation, so please only request this when needed. + * Retrieving activity data is an expensive operation, so only request this when needed. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -1119,7 +1119,7 @@ class IamIdentityV1 extends BaseService { * @param {Object} params - The parameters to send to the service. * @param {string} params.profileId - ID of the trusted profile to get. * @param {boolean} [params.includeActivity] - Defines if the entity's activity is included in the response. - * Retrieving activity data is an expensive operation, so please only request this when needed. + * Retrieving activity data is an expensive operation, so only request this when needed. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -1844,7 +1844,7 @@ class IamIdentityV1 extends BaseService { * @param {string} params.ifMatch - Entity tag of the Identities to be updated. Specify the tag that you retrieved * when reading the Profile Identities. This value helps identify parallel usage of this API. Pass * to indicate * updating any available version, which may result in stale updates. - * @param {ProfileIdentity[]} [params.identities] - List of identities that can assume the trusted profile. + * @param {ProfileIdentityRequest[]} [params.identities] - List of identities that can assume the trusted profile. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise>} */ @@ -1909,7 +1909,6 @@ class IamIdentityV1 extends BaseService { * user identifier (IAM id), serviceid or crn. Internally it uses account id of the service id for the identifier * 'serviceid' and for the identifier 'crn' it uses account id contained in the CRN. * @param {string} params.type - Type of the identity. - * @param {string} [params.iamId] - IAM ID of the identity. * @param {string[]} [params.accounts] - Only valid for the type user. Accounts from which a user can assume the * trusted profile. * @param {string} [params.description] - Description of the identity that can assume the trusted profile. This is @@ -1917,11 +1916,11 @@ class IamIdentityV1 extends BaseService { * the description of the service id is used. Description is recommended for the identity type 'crn' E.g. 'Instance * 1234 of IBM Cloud Service project'. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ public setProfileIdentity( params: IamIdentityV1.SetProfileIdentityParams - ): Promise> { + ): Promise> { const _params = { ...params }; const _requiredParams = ['profileId', 'identityType', 'identifier', 'type']; const _validParams = [ @@ -1929,7 +1928,6 @@ class IamIdentityV1 extends BaseService { 'identityType', 'identifier', 'type', - 'iamId', 'accounts', 'description', 'headers', @@ -1942,7 +1940,6 @@ class IamIdentityV1 extends BaseService { const body = { 'identifier': _params.identifier, 'type': _params.type, - 'iam_id': _params.iamId, 'accounts': _params.accounts, 'description': _params.description, }; @@ -1991,11 +1988,11 @@ class IamIdentityV1 extends BaseService { * @param {string} params.identityType - Type of the identity. * @param {string} params.identifierId - Identifier of the identity that can assume the trusted profiles. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ public getProfileIdentity( params: IamIdentityV1.GetProfileIdentityParams - ): Promise> { + ): Promise> { const _params = { ...params }; const _requiredParams = ['profileId', 'identityType', 'identifierId']; const _validParams = ['profileId', 'identityType', 'identifierId', 'headers']; @@ -2150,7 +2147,7 @@ class IamIdentityV1 extends BaseService { /** * Update account configurations. * - * Allows a user to configure settings on their account with regards to MFA, MFA excemption list, session lifetimes, + * Allows a user to configure settings on their account with regards to MFA, MFA excemption list, session lifetimes, * access control for creating new identities, and enforcing IP restrictions on token creation. * * @param {Object} params - The parameters to send to the service. @@ -2158,15 +2155,17 @@ class IamIdentityV1 extends BaseService { * retrieved as entity_tag (ETag header) when reading the account. This value helps identifying parallel usage of this * API. Pass * to indicate to update any version available. This might result in stale updates. * @param {string} params.accountId - The id of the account to update the settings for. - * @param {string} [params.restrictCreateServiceId] - Defines whether or not creating a Service Id is access + * @param {string} [params.restrictCreateServiceId] - Defines whether or not creating a service ID is access * controlled. Valid values: - * * RESTRICTED - to apply access control - * * NOT_RESTRICTED - to remove access control - * * NOT_SET - to unset a previously set value. + * * RESTRICTED - only users assigned the 'Service ID creator' role on the IAM Identity Service can create service + * IDs, including the account owner + * * NOT_RESTRICTED - all members of an account can create service IDs + * * NOT_SET - to 'unset' a previous set value. * @param {string} [params.restrictCreatePlatformApikey] - Defines whether or not creating platform API keys is access * controlled. Valid values: - * * RESTRICTED - to apply access control - * * NOT_RESTRICTED - to remove access control + * * RESTRICTED - only users assigned the 'User API key creator' role on the IAM Identity Service can create API + * keys, including the account owner + * * NOT_RESTRICTED - all members of an account can create platform API keys * * NOT_SET - to 'unset' a previous set value. * @param {string} [params.allowedIpAddresses] - Defines the IP addresses and subnets from which IAM tokens can be * created for the account. @@ -2440,49 +2439,193 @@ class IamIdentityV1 extends BaseService { return this.createRequest(parameters); } /************************* - * activityOperations + * accountSettingsAssignments ************************/ /** - * Trigger activity report for the account. + * List assignments. * - * Trigger activity report for the account by specifying the account ID. It can take a few minutes to generate the - * report for retrieval. + * List account settings assignments. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - Account ID of the Assignments to query. This parameter is required unless + * using a pagetoken. + * @param {string} [params.templateId] - Filter results by Template Id. + * @param {string} [params.templateVersion] - Filter results Template Version. + * @param {string} [params.target] - Filter results by the assignment target. + * @param {string} [params.targetType] - Filter results by the assignment's target type. + * @param {number} [params.limit] - Optional size of a single page. Default is 20 items per page. Valid range is 1 to + * 100. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - If specified, the items are sorted by the value of this property. + * @param {string} [params.order] - Sort order. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listAccountSettingsAssignments( + params?: IamIdentityV1.ListAccountSettingsAssignmentsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = [ + 'accountId', + 'templateId', + 'templateVersion', + 'target', + 'targetType', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'account_id': _params.accountId, + 'template_id': _params.templateId, + 'template_version': _params.templateVersion, + 'target': _params.target, + 'target_type': _params.targetType, + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listAccountSettingsAssignments' + ); + + const parameters = { + options: { + url: '/v1/account_settings_assignments/', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create assignment. + * + * Create an assigment for an account settings template. * * @param {Object} params - The parameters to send to the service. - * @param {string} params.accountId - ID of the account. - * @param {string} [params.type] - Optional report type. The supported value is 'inactive'. List all identities that - * have not authenticated within the time indicated by duration. - * @param {string} [params.duration] - Optional duration of the report. The supported unit of duration is hours. + * @param {string} params.templateId - ID of the template to assign. + * @param {number} params.templateVersion - Version of the template to assign. + * @param {string} params.targetType - Type of target to deploy to. + * @param {string} params.target - Identifier of target to deploy to. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public createReport( - params: IamIdentityV1.CreateReportParams - ): Promise> { + public createAccountSettingsAssignment( + params: IamIdentityV1.CreateAccountSettingsAssignmentParams + ): Promise> { const _params = { ...params }; - const _requiredParams = ['accountId']; - const _validParams = ['accountId', 'type', 'duration', 'headers']; + const _requiredParams = ['templateId', 'templateVersion', 'targetType', 'target']; + const _validParams = ['templateId', 'templateVersion', 'targetType', 'target', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'template_id': _params.templateId, + 'template_version': _params.templateVersion, + 'target_type': _params.targetType, + 'target': _params.target, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createAccountSettingsAssignment' + ); + + const parameters = { + options: { + url: '/v1/account_settings_assignments/', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get assignment. + * + * Get an assigment for an account settings template. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.assignmentId - ID of the Assignment Record. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getAccountSettingsAssignment( + params: IamIdentityV1.GetAccountSettingsAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['assignmentId']; + const _validParams = ['assignmentId', 'includeHistory', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } const query = { - 'type': _params.type, - 'duration': _params.duration, + 'include_history': _params.includeHistory, }; const path = { - 'account_id': _params.accountId, + 'assignment_id': _params.assignmentId, }; - const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createReport'); + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getAccountSettingsAssignment' + ); const parameters = { options: { - url: '/v1/activity/accounts/{account_id}/report', - method: 'POST', + url: '/v1/account_settings_assignments/{assignment_id}', + method: 'GET', qs: query, path, }, @@ -2502,40 +2645,41 @@ class IamIdentityV1 extends BaseService { } /** - * Get activity report for the account. + * Delete assignment. * - * Get activity report for the account by specifying the account ID and the reference that is generated by triggering - * the report. Reports older than a day are deleted when generating a new report. + * Delete an account settings template assignment. This removes any IAM resources created by this assignment in child + * accounts. * * @param {Object} params - The parameters to send to the service. - * @param {string} params.accountId - ID of the account. - * @param {string} params.reference - Reference for the report to be generated, You can use 'latest' to get the latest - * report for the given account. + * @param {string} params.assignmentId - ID of the Assignment Record. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers - * @returns {Promise>} + * @returns {Promise>} */ - public getReport( - params: IamIdentityV1.GetReportParams - ): Promise> { + public deleteAccountSettingsAssignment( + params: IamIdentityV1.DeleteAccountSettingsAssignmentParams + ): Promise> { const _params = { ...params }; - const _requiredParams = ['accountId', 'reference']; - const _validParams = ['accountId', 'reference', 'headers']; + const _requiredParams = ['assignmentId']; + const _validParams = ['assignmentId', 'headers']; const _validationErrors = validateParams(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } const path = { - 'account_id': _params.accountId, - 'reference': _params.reference, + 'assignment_id': _params.assignmentId, }; - const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getReport'); + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteAccountSettingsAssignment' + ); const parameters = { options: { - url: '/v1/activity/accounts/{account_id}/report/{reference}', - method: 'GET', + url: '/v1/account_settings_assignments/{assignment_id}', + method: 'DELETE', path, }, defaultOptions: extend(true, {}, this.baseOptions, { @@ -2552,762 +2696,3124 @@ class IamIdentityV1 extends BaseService { return this.createRequest(parameters); } -} -/************************* - * interfaces - ************************/ + /** + * Update assignment. + * + * Update an account settings assignment. Call this method to retry failed assignments or migrate the settings in + * child accounts to a new version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.assignmentId - ID of the Assignment Record. + * @param {string} params.ifMatch - Version of the assignment to be updated. Specify the version that you retrieved + * when reading the assignment. This value helps identifying parallel usage of this API. Pass * to indicate to update + * any version available. This might result in stale updates. + * @param {number} params.templateVersion - Template version to be applied to the assignment. To retry all failed + * assignemtns, provide the existing version. To migrate to a different version, provide the new version number. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateAccountSettingsAssignment( + params: IamIdentityV1.UpdateAccountSettingsAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['assignmentId', 'ifMatch', 'templateVersion']; + const _validParams = ['assignmentId', 'ifMatch', 'templateVersion', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } -namespace IamIdentityV1 { - /** An operation response. */ - export interface Response { - result: T; - status: number; - statusText: string; - headers: IncomingHttpHeaders; - } + const body = { + 'template_version': _params.templateVersion, + }; - /** The callback for a service request. */ - export type Callback = (error: any, response?: Response) => void; + const path = { + 'assignment_id': _params.assignmentId, + }; - /** The body of a service request that returns no response data. */ - export interface EmptyObject {} + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'updateAccountSettingsAssignment' + ); - /** A standard JS object, defined to avoid the limitations of `Object` and `object` */ - export interface JsonObject { - [key: string]: any; - } + const parameters = { + options: { + url: '/v1/account_settings_assignments/{assignment_id}', + method: 'PATCH', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'If-Match': _params.ifMatch, + }, + _params.headers + ), + }), + }; + return this.createRequest(parameters); + } /************************* - * request interfaces + * accountSettingsTemplate ************************/ - /** Parameters for the `listApiKeys` operation. */ - export interface ListApiKeysParams { - /** Account ID of the API keys to query. If a service IAM ID is specified in iam_id then account_id must match - * the account of the IAM ID. If a user IAM ID is specified in iam_id then then account_id must match the account - * of the Authorization token. - */ - accountId?: string; - /** IAM ID of the API keys to be queried. The IAM ID may be that of a user or a service. For a user IAM ID - * iam_id must match the Authorization token. - */ - iamId?: string; - /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ - pagesize?: number; - /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ - pagetoken?: string; - /** Optional parameter to define the scope of the queried API keys. Can be 'entity' (default) or 'account'. */ - scope?: ListApiKeysConstants.Scope | string; - /** Optional parameter to filter the type of the queried API keys. Can be 'user' or 'serviceid'. */ - type?: ListApiKeysConstants.Type | string; - /** Optional sort property, valid values are name, description, created_at and created_by. If specified, the - * items are sorted by the value of this property. - */ - sort?: string; - /** Optional sort order, valid values are asc and desc. Default: asc. */ - order?: ListApiKeysConstants.Order | string; - /** Defines if the entity history is included in the response. */ - includeHistory?: boolean; - headers?: OutgoingHttpHeaders; - } + /** + * List account settings templates. + * + * List account settings templates in an enterprise account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - Account ID of the account settings templates to query. This parameter is + * required unless using a pagetoken. + * @param {string} [params.limit] - Optional size of a single page. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - Optional sort property. If specified, the returned templated are sorted according + * to this property. + * @param {string} [params.order] - Optional sort order. + * @param {string} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listAccountSettingsTemplates( + params?: IamIdentityV1.ListAccountSettingsTemplatesParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = [ + 'accountId', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } - /** Constants for the `listApiKeys` operation. */ - export namespace ListApiKeysConstants { - /** Optional parameter to define the scope of the queried API keys. Can be 'entity' (default) or 'account'. */ + const query = { + 'account_id': _params.accountId, + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listAccountSettingsTemplates' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create an account settings template. + * + * Create a new account settings template in an enterprise account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {AccountSettingsComponent} [params.accountSettings] - + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createAccountSettingsTemplate( + params?: IamIdentityV1.CreateAccountSettingsTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = ['accountId', 'name', 'description', 'accountSettings', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'account_settings': _params.accountSettings, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createAccountSettingsTemplate' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get latest version of an account settings template. + * + * Get the latest version of a specific account settings template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLatestAccountSettingsTemplateVersion( + params: IamIdentityV1.GetLatestAccountSettingsTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = ['templateId', 'includeHistory', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getLatestAccountSettingsTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete all versions of an account settings template. + * + * Delete all versions of an account settings template in an enterprise account. If any version is assigned to child + * accounts, you must first delete the assignment. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteAllVersionsOfAccountSettingsTemplate( + params: IamIdentityV1.DeleteAllVersionsOfAccountSettingsTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = ['templateId', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteAllVersionsOfAccountSettingsTemplate' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } + + /** + * List account settings template versions. + * + * List the versions of a specific account settings template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} [params.limit] - Optional size of a single page. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - Optional sort property. If specified, the returned templated are sorted according + * to this property. + * @param {string} [params.order] - Optional sort order. + * @param {string} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listVersionsOfAccountSettingsTemplate( + params: IamIdentityV1.ListVersionsOfAccountSettingsTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = [ + 'templateId', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listVersionsOfAccountSettingsTemplate' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create a new version of an account settings template. + * + * Create a new version of an account settings template in an Enterprise Account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {AccountSettingsComponent} [params.accountSettings] - + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createAccountSettingsTemplateVersion( + params: IamIdentityV1.CreateAccountSettingsTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = [ + 'templateId', + 'accountId', + 'name', + 'description', + 'accountSettings', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'account_settings': _params.accountSettings, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createAccountSettingsTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get version of an account settings template. + * + * Get a specific version of an account settings template in an Enterprise Account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} params.version - Version of the account settings template. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getAccountSettingsTemplateVersion( + params: IamIdentityV1.GetAccountSettingsTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'includeHistory', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getAccountSettingsTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions/{version}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update version of an account settings template. + * + * Update a specific version of an account settings template in an Enterprise Account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.ifMatch - Entity tag of the Template to be updated. Specify the tag that you retrieved when + * reading the account settings template. This value helps identifying parallel usage of this API. Pass * to indicate + * to update any version available. This might result in stale updates. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} params.version - Version of the account settings template. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {AccountSettingsComponent} [params.accountSettings] - + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateAccountSettingsTemplateVersion( + params: IamIdentityV1.UpdateAccountSettingsTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['ifMatch', 'templateId', 'version']; + const _validParams = [ + 'ifMatch', + 'templateId', + 'version', + 'accountId', + 'name', + 'description', + 'accountSettings', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'account_settings': _params.accountSettings, + }; + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'updateAccountSettingsTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions/{version}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'If-Match': _params.ifMatch, + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete version of an account settings template. + * + * Delete a specific version of an account settings template in an Enterprise Account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} params.version - Version of the account settings template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteAccountSettingsTemplateVersion( + params: IamIdentityV1.DeleteAccountSettingsTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteAccountSettingsTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions/{version}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Commit a template version. + * + * Commit a specific version of an account settings template in an Enterprise Account. A Template must be committed + * before being assigned, and once committed, can no longer be modified. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the account settings template. + * @param {string} params.version - Version of the account settings template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public commitAccountSettingsTemplate( + params: IamIdentityV1.CommitAccountSettingsTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'commitAccountSettingsTemplate' + ); + + const parameters = { + options: { + url: '/v1/account_settings_templates/{template_id}/versions/{version}/commit', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } + /************************* + * activityOperations + ************************/ + + /** + * Trigger activity report for the account. + * + * Trigger activity report for the account by specifying the account ID. It can take a few minutes to generate the + * report for retrieval. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - ID of the account. + * @param {string} [params.type] - Optional report type. The supported value is 'inactive'. List all identities that + * have not authenticated within the time indicated by duration. + * @param {string} [params.duration] - Optional duration of the report, supported unit of duration is hours. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createReport( + params: IamIdentityV1.CreateReportParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId']; + const _validParams = ['accountId', 'type', 'duration', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'type': _params.type, + 'duration': _params.duration, + }; + + const path = { + 'account_id': _params.accountId, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createReport'); + + const parameters = { + options: { + url: '/v1/activity/accounts/{account_id}/report', + method: 'POST', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get activity report across on account scope. + * + * Get activity report for the account by specifying the account ID and the reference that is generated by triggering + * the report. Reports older than a day are deleted when generating a new report. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.accountId - ID of the account. + * @param {string} params.reference - Reference for the report to be generated, You can use 'latest' to get the latest + * report for the given account. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getReport( + params: IamIdentityV1.GetReportParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['accountId', 'reference']; + const _validParams = ['accountId', 'reference', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'account_id': _params.accountId, + 'reference': _params.reference, + }; + + const sdkHeaders = getSdkHeaders(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getReport'); + + const parameters = { + options: { + url: '/v1/activity/accounts/{account_id}/report/{reference}', + method: 'GET', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + /************************* + * trustedProfileAssignments + ************************/ + + /** + * List assignments. + * + * List trusted profile template assignments. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - Account ID of the Assignments to query. This parameter is required unless + * using a pagetoken. + * @param {string} [params.templateId] - Filter results by Template Id. + * @param {string} [params.templateVersion] - Filter results Template Version. + * @param {string} [params.target] - Filter results by the assignment target. + * @param {string} [params.targetType] - Filter results by the assignment's target type. + * @param {number} [params.limit] - Optional size of a single page. Default is 20 items per page. Valid range is 1 to + * 100. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - If specified, the items are sorted by the value of this property. + * @param {string} [params.order] - Sort order. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listTrustedProfileAssignments( + params?: IamIdentityV1.ListTrustedProfileAssignmentsParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = [ + 'accountId', + 'templateId', + 'templateVersion', + 'target', + 'targetType', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'account_id': _params.accountId, + 'template_id': _params.templateId, + 'template_version': _params.templateVersion, + 'target': _params.target, + 'target_type': _params.targetType, + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listTrustedProfileAssignments' + ); + + const parameters = { + options: { + url: '/v1/profile_assignments/', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create assignment. + * + * Create an assigment for a trusted profile template. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the template to assign. + * @param {number} params.templateVersion - Version of the template to assign. + * @param {string} params.targetType - Type of target to deploy to. + * @param {string} params.target - Identifier of target to deploy to. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createTrustedProfileAssignment( + params: IamIdentityV1.CreateTrustedProfileAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'templateVersion', 'targetType', 'target']; + const _validParams = ['templateId', 'templateVersion', 'targetType', 'target', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'template_id': _params.templateId, + 'template_version': _params.templateVersion, + 'target_type': _params.targetType, + 'target': _params.target, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createTrustedProfileAssignment' + ); + + const parameters = { + options: { + url: '/v1/profile_assignments/', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get assignment. + * + * Get an assigment for a trusted profile template. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.assignmentId - ID of the Assignment Record. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getTrustedProfileAssignment( + params: IamIdentityV1.GetTrustedProfileAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['assignmentId']; + const _validParams = ['assignmentId', 'includeHistory', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'assignment_id': _params.assignmentId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getTrustedProfileAssignment' + ); + + const parameters = { + options: { + url: '/v1/profile_assignments/{assignment_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete assignment. + * + * Delete a trusted profile assignment. This removes any IAM resources created by this assignment in child accounts. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.assignmentId - ID of the Assignment Record. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteTrustedProfileAssignment( + params: IamIdentityV1.DeleteTrustedProfileAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['assignmentId']; + const _validParams = ['assignmentId', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'assignment_id': _params.assignmentId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteTrustedProfileAssignment' + ); + + const parameters = { + options: { + url: '/v1/profile_assignments/{assignment_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update assignment. + * + * Update a trusted profile assignment. Call this method to retry failed assignments or migrate the trusted profile in + * child accounts to a new version. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.assignmentId - ID of the Assignment Record. + * @param {string} params.ifMatch - Version of the Assignment to be updated. Specify the version that you retrieved + * when reading the Assignment. This value helps identifying parallel usage of this API. Pass * to indicate to update + * any version available. This might result in stale updates. + * @param {number} params.templateVersion - Template version to be applied to the assignment. To retry all failed + * assignemtns, provide the existing version. To migrate to a different version, provide the new version number. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateTrustedProfileAssignment( + params: IamIdentityV1.UpdateTrustedProfileAssignmentParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['assignmentId', 'ifMatch', 'templateVersion']; + const _validParams = ['assignmentId', 'ifMatch', 'templateVersion', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'template_version': _params.templateVersion, + }; + + const path = { + 'assignment_id': _params.assignmentId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'updateTrustedProfileAssignment' + ); + + const parameters = { + options: { + url: '/v1/profile_assignments/{assignment_id}', + method: 'PATCH', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'If-Match': _params.ifMatch, + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + /************************* + * trustedProfileTemplate + ************************/ + + /** + * List trusted profile templates. + * + * List the trusted profile templates in an enterprise account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - Account ID of the trusted profile templates to query. This parameter is + * required unless using a pagetoken. + * @param {string} [params.limit] - Optional size of a single page. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - Optional sort property. If specified, the returned templates are sorted according + * to this property. + * @param {string} [params.order] - Optional sort order. + * @param {string} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listProfileTemplates( + params?: IamIdentityV1.ListProfileTemplatesParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = [ + 'accountId', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'account_id': _params.accountId, + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listProfileTemplates' + ); + + const parameters = { + options: { + url: '/v1/profile_templates', + method: 'GET', + qs: query, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create a trusted profile template. + * + * Create a new trusted profile template in an enterprise account. + * + * @param {Object} [params] - The parameters to send to the service. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. Required field when creating a new template. Otherwise this field is optional. If the field is included it + * will change the name value for all existing versions of the template. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {TemplateProfileComponentRequest} [params.profile] - Input body parameters for the TemplateProfileComponent. + * @param {PolicyTemplateReference[]} [params.policyTemplateReferences] - Existing policy templates that you can + * reference to assign access in the trusted profile component. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createProfileTemplate( + params?: IamIdentityV1.CreateProfileTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = []; + const _validParams = [ + 'accountId', + 'name', + 'description', + 'profile', + 'policyTemplateReferences', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'profile': _params.profile, + 'policy_template_references': _params.policyTemplateReferences, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createProfileTemplate' + ); + + const parameters = { + options: { + url: '/v1/profile_templates', + method: 'POST', + body, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get latest version of a trusted profile template. + * + * Get the latest version of a trusted profile template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getLatestProfileTemplateVersion( + params: IamIdentityV1.GetLatestProfileTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = ['templateId', 'includeHistory', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getLatestProfileTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete all versions of a trusted profile template. + * + * Delete all versions of a trusted profile template in an enterprise account. If any version is assigned to child + * accounts, you must first delete the assignment. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteAllVersionsOfProfileTemplate( + params: IamIdentityV1.DeleteAllVersionsOfProfileTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = ['templateId', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteAllVersionsOfProfileTemplate' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } + + /** + * List trusted profile template versions. + * + * List the versions of a trusted profile template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} [params.limit] - Optional size of a single page. + * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. + * Default is start with first page. + * @param {string} [params.sort] - Optional sort property. If specified, the returned templated are sorted according + * to this property. + * @param {string} [params.order] - Optional sort order. + * @param {string} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public listVersionsOfProfileTemplate( + params: IamIdentityV1.ListVersionsOfProfileTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = [ + 'templateId', + 'limit', + 'pagetoken', + 'sort', + 'order', + 'includeHistory', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'limit': _params.limit, + 'pagetoken': _params.pagetoken, + 'sort': _params.sort, + 'order': _params.order, + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'listVersionsOfProfileTemplate' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Create new version of a trusted profile template. + * + * Create a new version of a trusted profile template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. Required field when creating a new template. Otherwise this field is optional. If the field is included it + * will change the name value for all existing versions of the template. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {TemplateProfileComponentRequest} [params.profile] - Input body parameters for the TemplateProfileComponent. + * @param {PolicyTemplateReference[]} [params.policyTemplateReferences] - Existing policy templates that you can + * reference to assign access in the trusted profile component. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public createProfileTemplateVersion( + params: IamIdentityV1.CreateProfileTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId']; + const _validParams = [ + 'templateId', + 'accountId', + 'name', + 'description', + 'profile', + 'policyTemplateReferences', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'profile': _params.profile, + 'policy_template_references': _params.policyTemplateReferences, + }; + + const path = { + 'template_id': _params.templateId, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'createProfileTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions', + method: 'POST', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Get version of trusted profile template. + * + * Get a specific version of a trusted profile template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} params.version - Version of the Profile Template. + * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public getProfileTemplateVersion( + params: IamIdentityV1.GetProfileTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'includeHistory', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const query = { + 'include_history': _params.includeHistory, + }; + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'getProfileTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions/{version}', + method: 'GET', + qs: query, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Update version of trusted profile template. + * + * Update a specific version of a trusted profile template in an enterprise account. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.ifMatch - Entity tag of the Template to be updated. Specify the tag that you retrieved when + * reading the Profile Template. This value helps identifying parallel usage of this API. Pass * to indicate to update + * any version available. This might result in stale updates. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} params.version - Version of the Profile Template. + * @param {string} [params.accountId] - ID of the account where the template resides. + * @param {string} [params.name] - The name of the trusted profile template. This is visible only in the enterprise + * account. Required field when creating a new template. Otherwise this field is optional. If the field is included it + * will change the name value for all existing versions of the template. + * @param {string} [params.description] - The description of the trusted profile template. Describe the template for + * enterprise account users. + * @param {TemplateProfileComponentRequest} [params.profile] - Input body parameters for the TemplateProfileComponent. + * @param {PolicyTemplateReference[]} [params.policyTemplateReferences] - Existing policy templates that you can + * reference to assign access in the trusted profile component. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public updateProfileTemplateVersion( + params: IamIdentityV1.UpdateProfileTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['ifMatch', 'templateId', 'version']; + const _validParams = [ + 'ifMatch', + 'templateId', + 'version', + 'accountId', + 'name', + 'description', + 'profile', + 'policyTemplateReferences', + 'headers', + ]; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const body = { + 'account_id': _params.accountId, + 'name': _params.name, + 'description': _params.description, + 'profile': _params.profile, + 'policy_template_references': _params.policyTemplateReferences, + }; + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'updateProfileTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions/{version}', + method: 'PUT', + body, + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend( + true, + sdkHeaders, + { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'If-Match': _params.ifMatch, + }, + _params.headers + ), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Delete version of trusted profile template. + * + * Delete a specific version of a trusted profile template in an enterprise account. If the version is assigned to + * child accounts, you must first delete the assignment. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} params.version - Version of the Profile Template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public deleteProfileTemplateVersion( + params: IamIdentityV1.DeleteProfileTemplateVersionParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'deleteProfileTemplateVersion' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions/{version}', + method: 'DELETE', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } + + /** + * Commit a template version. + * + * Commit a specific version of a trusted profile template in an enterprise account. You must commit a template before + * you can assign it to child accounts. Once a template is committed, you can no longer modify the template. + * + * @param {Object} params - The parameters to send to the service. + * @param {string} params.templateId - ID of the trusted profile template. + * @param {string} params.version - Version of the Profile Template. + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers + * @returns {Promise>} + */ + public commitProfileTemplate( + params: IamIdentityV1.CommitProfileTemplateParams + ): Promise> { + const _params = { ...params }; + const _requiredParams = ['templateId', 'version']; + const _validParams = ['templateId', 'version', 'headers']; + const _validationErrors = validateParams(_params, _requiredParams, _validParams); + if (_validationErrors) { + return Promise.reject(_validationErrors); + } + + const path = { + 'template_id': _params.templateId, + 'version': _params.version, + }; + + const sdkHeaders = getSdkHeaders( + IamIdentityV1.DEFAULT_SERVICE_NAME, + 'v1', + 'commitProfileTemplate' + ); + + const parameters = { + options: { + url: '/v1/profile_templates/{template_id}/versions/{version}/commit', + method: 'POST', + path, + }, + defaultOptions: extend(true, {}, this.baseOptions, { + headers: extend(true, sdkHeaders, {}, _params.headers), + }), + }; + + return this.createRequest(parameters); + } +} + +/************************* + * interfaces + ************************/ + +namespace IamIdentityV1 { + /** An operation response. */ + export interface Response { + result: T; + status: number; + statusText: string; + headers: IncomingHttpHeaders; + } + + /** The callback for a service request. */ + export type Callback = (error: any, response?: Response) => void; + + /** The body of a service request that returns no response data. */ + export interface EmptyObject {} + + /** A standard JS object, defined to avoid the limitations of `Object` and `object` */ + export interface JsonObject { + [key: string]: any; + } + + /************************* + * request interfaces + ************************/ + + /** Parameters for the `listApiKeys` operation. */ + export interface ListApiKeysParams { + /** Account ID of the API keys(s) to query. If a service IAM ID is specified in iam_id then account_id must + * match the account of the IAM ID. If a user IAM ID is specified in iam_id then then account_id must match the + * account of the Authorization token. + */ + accountId?: string; + /** IAM ID of the API key(s) to be queried. The IAM ID may be that of a user or a service. For a user IAM ID + * iam_id must match the Authorization token. + */ + iamId?: string; + /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ + pagesize?: number; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** Optional parameter to define the scope of the queried API Keys. Can be 'entity' (default) or 'account'. */ + scope?: ListApiKeysConstants.Scope | string; + /** Optional parameter to filter the type of the queried API Keys. Can be 'user' or 'serviceid'. */ + type?: ListApiKeysConstants.Type | string; + /** Optional sort property, valid values are name, description, created_at and created_by. If specified, the + * items are sorted by the value of this property. + */ + sort?: string; + /** Optional sort order, valid values are asc and desc. Default: asc. */ + order?: ListApiKeysConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `listApiKeys` operation. */ + export namespace ListApiKeysConstants { + /** Optional parameter to define the scope of the queried API Keys. Can be 'entity' (default) or 'account'. */ export enum Scope { ENTITY = 'entity', ACCOUNT = 'account', } - /** Optional parameter to filter the type of the queried API keys. Can be 'user' or 'serviceid'. */ + /** Optional parameter to filter the type of the queried API Keys. Can be 'user' or 'serviceid'. */ + export enum Type { + USER = 'user', + SERVICEID = 'serviceid', + } + /** Optional sort order, valid values are asc and desc. Default: asc. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', + } + } + + /** Parameters for the `createApiKey` operation. */ + export interface CreateApiKeyParams { + /** Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value + * can exist. Access is done via the UUID of the API key. + */ + name: string; + /** The iam_id that this API key authenticates. */ + iamId: string; + /** The optional description of the API key. The 'description' property is only available if a description was + * provided during a create of an API key. + */ + description?: string; + /** The account ID of the API key. */ + accountId?: string; + /** You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey + * value is done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe + * opaque API key value. The value of the API key is checked for uniqueness. Ensure enough variations when passing + * in this value. + */ + apikey?: string; + /** Send true or false to set whether the API key value is retrievable in the future by using the Get details of + * an API key request. If you create an API key for a user, you must specify `false` or omit the value. We don't + * allow storing of API keys for users. + */ + storeValue?: boolean; + /** Indicates if the API key is locked for further write operations. False by default. */ + entityLock?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getApiKeysDetails` operation. */ + export interface GetApiKeysDetailsParams { + /** API key value. */ + iamApiKey?: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getApiKey` operation. */ + export interface GetApiKeyParams { + /** Unique ID of the API key. */ + id: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive + * operation, so only request this when needed. + */ + includeActivity?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateApiKey` operation. */ + export interface UpdateApiKeyParams { + /** Unique ID of the API key to be updated. */ + id: string; + /** Version of the API key to be updated. Specify the version that you retrieved when reading the API key. This + * value helps identifying parallel usage of this API. Pass * to indicate to update any version available. This + * might result in stale updates. + */ + ifMatch: string; + /** The name of the API key to update. If specified in the request the parameter must not be empty. The name is + * not checked for uniqueness. Failure to this will result in an Error condition. + */ + name?: string; + /** The description of the API key to update. If specified an empty description will clear the description of + * the API key. If a non empty value is provided the API key will be updated. + */ + description?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteApiKey` operation. */ + export interface DeleteApiKeyParams { + /** Unique ID of the API key. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `lockApiKey` operation. */ + export interface LockApiKeyParams { + /** Unique ID of the API key. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `unlockApiKey` operation. */ + export interface UnlockApiKeyParams { + /** Unique ID of the API key. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listServiceIds` operation. */ + export interface ListServiceIdsParams { + /** Account ID of the service ID(s) to query. This parameter is required (unless using a pagetoken). */ + accountId?: string; + /** Name of the service ID(s) to query. Optional.20 items per page. Valid range is 1 to 100. */ + name?: string; + /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ + pagesize?: number; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** Optional sort property, valid values are name, description, created_at and modified_at. If specified, the + * items are sorted by the value of this property. + */ + sort?: string; + /** Optional sort order, valid values are asc and desc. Default: asc. */ + order?: ListServiceIdsConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `listServiceIds` operation. */ + export namespace ListServiceIdsConstants { + /** Optional sort order, valid values are asc and desc. Default: asc. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', + } + } + + /** Parameters for the `createServiceId` operation. */ + export interface CreateServiceIdParams { + /** ID of the account the service ID belongs to. */ + accountId: string; + /** Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value + * can exist. Access is done via the UUID of the Service Id. + */ + name: string; + /** The optional description of the Service Id. The 'description' property is only available if a description + * was provided during a create of a Service Id. + */ + description?: string; + /** Optional list of CRNs (string array) which point to the services connected to the service ID. */ + uniqueInstanceCrns?: string[]; + /** Parameters for the API key in the Create service Id V1 REST request. */ + apikey?: ApiKeyInsideCreateServiceIdRequest; + /** Indicates if the service ID is locked for further write operations. False by default. */ + entityLock?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getServiceId` operation. */ + export interface GetServiceIdParams { + /** Unique ID of the service ID. */ + id: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive + * operation, so only request this when needed. + */ + includeActivity?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateServiceId` operation. */ + export interface UpdateServiceIdParams { + /** Unique ID of the service ID to be updated. */ + id: string; + /** Version of the service ID to be updated. Specify the version that you retrieved as entity_tag (ETag header) + * when reading the service ID. This value helps identifying parallel usage of this API. Pass * to indicate to + * update any version available. This might result in stale updates. + */ + ifMatch: string; + /** The name of the service ID to update. If specified in the request the parameter must not be empty. The name + * is not checked for uniqueness. Failure to this will result in an Error condition. + */ + name?: string; + /** The description of the service ID to update. If specified an empty description will clear the description of + * the service ID. If an non empty value is provided the service ID will be updated. + */ + description?: string; + /** List of CRNs which point to the services connected to this service ID. If specified an empty list will clear + * all existing unique instance crns of the service ID. + */ + uniqueInstanceCrns?: string[]; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteServiceId` operation. */ + export interface DeleteServiceIdParams { + /** Unique ID of the service ID. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `lockServiceId` operation. */ + export interface LockServiceIdParams { + /** Unique ID of the service ID. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `unlockServiceId` operation. */ + export interface UnlockServiceIdParams { + /** Unique ID of the service ID. */ + id: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createProfile` operation. */ + export interface CreateProfileParams { + /** Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same + * names can not exist in the same account. + */ + name: string; + /** The account ID of the trusted profile. */ + accountId: string; + /** The optional description of the trusted profile. The 'description' property is only available if a + * description was provided during creation of trusted profile. + */ + description?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listProfiles` operation. */ + export interface ListProfilesParams { + /** Account ID to query for trusted profiles. */ + accountId: string; + /** Name of the trusted profile to query. */ + name?: string; + /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ + pagesize?: number; + /** Optional sort property, valid values are name, description, created_at and modified_at. If specified, the + * items are sorted by the value of this property. + */ + sort?: string; + /** Optional sort order, valid values are asc and desc. Default: asc. */ + order?: ListProfilesConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `listProfiles` operation. */ + export namespace ListProfilesConstants { + /** Optional sort order, valid values are asc and desc. Default: asc. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', + } + } + + /** Parameters for the `getProfile` operation. */ + export interface GetProfileParams { + /** ID of the trusted profile to get. */ + profileId: string; + /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive + * operation, so only request this when needed. + */ + includeActivity?: boolean; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateProfile` operation. */ + export interface UpdateProfileParams { + /** ID of the trusted profile to be updated. */ + profileId: string; + /** Version of the trusted profile to be updated. Specify the version that you retrived when reading list of + * trusted profiles. This value helps to identify any parallel usage of trusted profile. Pass * to indicate to + * update any version available. This might result in stale updates. + */ + ifMatch: string; + /** The name of the trusted profile to update. If specified in the request the parameter must not be empty. The + * name is checked for uniqueness. Failure to this will result in an Error condition. + */ + name?: string; + /** The description of the trusted profile to update. If specified an empty description will clear the + * description of the trusted profile. If a non empty value is provided the trusted profile will be updated. + */ + description?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteProfile` operation. */ + export interface DeleteProfileParams { + /** ID of the trusted profile. */ + profileId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createClaimRule` operation. */ + export interface CreateClaimRuleParams { + /** ID of the trusted profile to create a claim rule. */ + profileId: string; + /** Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. */ + type: string; + /** Conditions of this claim rule. */ + conditions: ProfileClaimRuleConditions[]; + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** Name of the claim rule to be created or updated. */ + name?: string; + /** The realm name of the Idp this claim rule applies to. This field is required only if the type is specified + * as 'Profile-SAML'. + */ + realmName?: string; + /** The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid + * values are VSI, IKS_SA, ROKS_SA. + */ + crType?: string; + /** Session expiration in seconds, only required if type is 'Profile-SAML'. */ + expiration?: number; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listClaimRules` operation. */ + export interface ListClaimRulesParams { + /** ID of the trusted profile. */ + profileId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getClaimRule` operation. */ + export interface GetClaimRuleParams { + /** ID of the trusted profile. */ + profileId: string; + /** ID of the claim rule to get. */ + ruleId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateClaimRule` operation. */ + export interface UpdateClaimRuleParams { + /** ID of the trusted profile. */ + profileId: string; + /** ID of the claim rule to update. */ + ruleId: string; + /** Version of the claim rule to be updated. Specify the version that you retrived when reading list of claim + * rules. This value helps to identify any parallel usage of claim rule. Pass * to indicate to update any version + * available. This might result in stale updates. + */ + ifMatch: string; + /** Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. */ + type: string; + /** Conditions of this claim rule. */ + conditions: ProfileClaimRuleConditions[]; + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** Name of the claim rule to be created or updated. */ + name?: string; + /** The realm name of the Idp this claim rule applies to. This field is required only if the type is specified + * as 'Profile-SAML'. + */ + realmName?: string; + /** The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid + * values are VSI, IKS_SA, ROKS_SA. + */ + crType?: string; + /** Session expiration in seconds, only required if type is 'Profile-SAML'. */ + expiration?: number; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteClaimRule` operation. */ + export interface DeleteClaimRuleParams { + /** ID of the trusted profile. */ + profileId: string; + /** ID of the claim rule to delete. */ + ruleId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `createLink` operation. */ + export interface CreateLinkParams { + /** ID of the trusted profile. */ + profileId: string; + /** The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. */ + crType: string; + /** Link details. */ + link: CreateProfileLinkRequestLink; + /** Optional name of the Link. */ + name?: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `listLinks` operation. */ + export interface ListLinksParams { + /** ID of the trusted profile. */ + profileId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getLink` operation. */ + export interface GetLinkParams { + /** ID of the trusted profile. */ + profileId: string; + /** ID of the link. */ + linkId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteLink` operation. */ + export interface DeleteLinkParams { + /** ID of the trusted profile. */ + profileId: string; + /** ID of the link. */ + linkId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getProfileIdentities` operation. */ + export interface GetProfileIdentitiesParams { + /** ID of the trusted profile. */ + profileId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `setProfileIdentities` operation. */ + export interface SetProfileIdentitiesParams { + /** ID of the trusted profile. */ + profileId: string; + /** Entity tag of the Identities to be updated. Specify the tag that you retrieved when reading the Profile + * Identities. This value helps identify parallel usage of this API. Pass * to indicate updating any available + * version, which may result in stale updates. + */ + ifMatch: string; + /** List of identities that can assume the trusted profile. */ + identities?: ProfileIdentityRequest[]; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `setProfileIdentity` operation. */ + export interface SetProfileIdentityParams { + /** ID of the trusted profile. */ + profileId: string; + /** Type of the identity. */ + identityType: SetProfileIdentityConstants.IdentityType | string; + /** Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), + * serviceid or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the + * identifier 'crn' it uses account id contained in the CRN. + */ + identifier: string; + /** Type of the identity. */ + type: SetProfileIdentityConstants.Type | string; + /** Only valid for the type user. Accounts from which a user can assume the trusted profile. */ + accounts?: string[]; + /** Description of the identity that can assume the trusted profile. This is optional field for all the types of + * identities. When this field is not set for the identity type 'serviceid' then the description of the service id + * is used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service + * project'. + */ + description?: string; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `setProfileIdentity` operation. */ + export namespace SetProfileIdentityConstants { + /** Type of the identity. */ + export enum IdentityType { + USER = 'user', + SERVICEID = 'serviceid', + CRN = 'crn', + } + /** Type of the identity. */ export enum Type { USER = 'user', SERVICEID = 'serviceid', - } - /** Optional sort order, valid values are asc and desc. Default: asc. */ - export enum Order { - ASC = 'asc', - DESC = 'desc', + CRN = 'crn', } } - /** Parameters for the `createApiKey` operation. */ - export interface CreateApiKeyParams { - /** Name of the API key. The name is not checked for uniqueness. Therefore multiple names with the same value - * can exist. Access is done via the UUID of the API key. - */ - name: string; - /** The iam_id that this API key authenticates. */ - iamId: string; - /** The optional description of the API key. The 'description' property is only available if a description was - * provided during a create of an API key. - */ - description?: string; - /** The account ID of the API key. */ - accountId?: string; - /** You can optionally passthrough the API key value for this API key. If passed, NO validation of that apiKey - * value is done, i.e. the value can be non-URL safe. If omitted, the API key management will create an URL safe - * opaque API key value. The value of the API key is checked for uniqueness. Please ensure enough variations when - * passing in this value. - */ - apikey?: string; - /** Send true or false to set whether the API key value is retrievable in the future by using the Get details of - * an API key request. If you create an API key for a user, you must specify `false` or omit the value. We don't - * allow storing of API keys for users. - */ - storeValue?: boolean; - /** Indicates if the API key is locked for further write operations. False by default. */ - entityLock?: string; + /** Parameters for the `getProfileIdentity` operation. */ + export interface GetProfileIdentityParams { + /** ID of the trusted profile. */ + profileId: string; + /** Type of the identity. */ + identityType: GetProfileIdentityConstants.IdentityType | string; + /** Identifier of the identity that can assume the trusted profiles. */ + identifierId: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `getApiKeysDetails` operation. */ - export interface GetApiKeysDetailsParams { - /** API key value. */ - iamApiKey?: string; - /** Defines if the entity history is included in the response. */ - includeHistory?: boolean; + /** Constants for the `getProfileIdentity` operation. */ + export namespace GetProfileIdentityConstants { + /** Type of the identity. */ + export enum IdentityType { + USER = 'user', + SERVICEID = 'serviceid', + CRN = 'crn', + } + } + + /** Parameters for the `deleteProfileIdentity` operation. */ + export interface DeleteProfileIdentityParams { + /** ID of the trusted profile. */ + profileId: string; + /** Type of the identity. */ + identityType: DeleteProfileIdentityConstants.IdentityType | string; + /** Identifier of the identity that can assume the trusted profiles. */ + identifierId: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `getApiKey` operation. */ - export interface GetApiKeyParams { - /** Unique ID of the API key. */ - id: string; + /** Constants for the `deleteProfileIdentity` operation. */ + export namespace DeleteProfileIdentityConstants { + /** Type of the identity. */ + export enum IdentityType { + USER = 'user', + SERVICEID = 'serviceid', + CRN = 'crn', + } + } + + /** Parameters for the `getAccountSettings` operation. */ + export interface GetAccountSettingsParams { + /** Unique ID of the account. */ + accountId: string; /** Defines if the entity history is included in the response. */ includeHistory?: boolean; - /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive - * operation, so please only request this when needed. - */ - includeActivity?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `updateApiKey` operation. */ - export interface UpdateApiKeyParams { - /** Unique ID of the API key to be updated. */ - id: string; - /** Version of the API key to be updated. Specify the version that you retrieved when reading the API key. This - * value helps identifying parallel usage of this API. Pass * to indicate to update any version available. This - * might result in stale updates. + /** Parameters for the `updateAccountSettings` operation. */ + export interface UpdateAccountSettingsParams { + /** Version of the account settings to be updated. Specify the version that you retrieved as entity_tag (ETag + * header) when reading the account. This value helps identifying parallel usage of this API. Pass * to indicate to + * update any version available. This might result in stale updates. + */ + ifMatch: string; + /** The id of the account to update the settings for. */ + accountId: string; + /** Defines whether or not creating a service ID is access controlled. Valid values: + * * RESTRICTED - only users assigned the 'Service ID creator' role on the IAM Identity Service can create + * service IDs, including the account owner + * * NOT_RESTRICTED - all members of an account can create service IDs + * * NOT_SET - to 'unset' a previous set value. + */ + restrictCreateServiceId?: UpdateAccountSettingsConstants.RestrictCreateServiceId | string; + /** Defines whether or not creating platform API keys is access controlled. Valid values: + * * RESTRICTED - only users assigned the 'User API key creator' role on the IAM Identity Service can create API + * keys, including the account owner + * * NOT_RESTRICTED - all members of an account can create platform API keys + * * NOT_SET - to 'unset' a previous set value. + */ + restrictCreatePlatformApikey?: + | UpdateAccountSettingsConstants.RestrictCreatePlatformApikey + | string; + /** Defines the IP addresses and subnets from which IAM tokens can be created for the account. */ + allowedIpAddresses?: string; + /** Defines the MFA trait for the account. Valid values: + * * NONE - No MFA trait set + * * NONE_NO_ROPC- No MFA, disable CLI logins with only a password + * * TOTP - For all non-federated IBMId users + * * TOTP4ALL - For all users + * * LEVEL1 - Email-based MFA for all users + * * LEVEL2 - TOTP-based MFA for all users + * * LEVEL3 - U2F MFA for all users. + */ + mfa?: UpdateAccountSettingsConstants.Mfa | string; + /** List of users that are exempted from the MFA requirement of the account. */ + userMfa?: AccountSettingsUserMFA[]; + /** Defines the session expiration in seconds for the account. Valid values: + * * Any whole number between between '900' and '86400' + * * NOT_SET - To unset account setting and use service default. + */ + sessionExpirationInSeconds?: string; + /** Defines the period of time in seconds in which a session will be invalidated due to inactivity. Valid + * values: + * * Any whole number between '900' and '7200' + * * NOT_SET - To unset account setting and use service default. + */ + sessionInvalidationInSeconds?: string; + /** Defines the max allowed sessions per identity required by the account. Value values: + * * Any whole number greater than 0 + * * NOT_SET - To unset account setting and use service default. */ - ifMatch: string; - /** The name of the API key to update. If specified in the request the parameter must not be empty. The name is - * not checked for uniqueness. Failure to this will result in an Error condition. + maxSessionsPerIdentity?: string; + /** Defines the access token expiration in seconds. Valid values: + * * Any whole number between '900' and '3600' + * * NOT_SET - To unset account setting and use service default. */ - name?: string; - /** The description of the API key to update. If specified an empty description will clear the description of - * the API key. If a non empty value is provided the API key will be updated. + systemAccessTokenExpirationInSeconds?: string; + /** Defines the refresh token expiration in seconds. Valid values: + * * Any whole number between '900' and '259200' + * * NOT_SET - To unset account setting and use service default. */ - description?: string; + systemRefreshTokenExpirationInSeconds?: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteApiKey` operation. */ - export interface DeleteApiKeyParams { - /** Unique ID of the API key. */ - id: string; + /** Constants for the `updateAccountSettings` operation. */ + export namespace UpdateAccountSettingsConstants { + /** Defines whether or not creating a service ID is access controlled. Valid values: * RESTRICTED - only users assigned the 'Service ID creator' role on the IAM Identity Service can create service IDs, including the account owner * NOT_RESTRICTED - all members of an account can create service IDs * NOT_SET - to 'unset' a previous set value. */ + export enum RestrictCreateServiceId { + RESTRICTED = 'RESTRICTED', + NOT_RESTRICTED = 'NOT_RESTRICTED', + NOT_SET = 'NOT_SET', + } + /** Defines whether or not creating platform API keys is access controlled. Valid values: * RESTRICTED - only users assigned the 'User API key creator' role on the IAM Identity Service can create API keys, including the account owner * NOT_RESTRICTED - all members of an account can create platform API keys * NOT_SET - to 'unset' a previous set value. */ + export enum RestrictCreatePlatformApikey { + RESTRICTED = 'RESTRICTED', + NOT_RESTRICTED = 'NOT_RESTRICTED', + NOT_SET = 'NOT_SET', + } + /** Defines the MFA trait for the account. Valid values: * NONE - No MFA trait set * NONE_NO_ROPC- No MFA, disable CLI logins with only a password * TOTP - For all non-federated IBMId users * TOTP4ALL - For all users * LEVEL1 - Email-based MFA for all users * LEVEL2 - TOTP-based MFA for all users * LEVEL3 - U2F MFA for all users. */ + export enum Mfa { + NONE = 'NONE', + NONE_NO_ROPC = 'NONE_NO_ROPC', + TOTP = 'TOTP', + TOTP4ALL = 'TOTP4ALL', + LEVEL1 = 'LEVEL1', + LEVEL2 = 'LEVEL2', + LEVEL3 = 'LEVEL3', + } + } + + /** Parameters for the `getMfaStatus` operation. */ + export interface GetMfaStatusParams { + /** ID of the account. */ + accountId: string; + /** iam_id of the user. This user must be the member of the account. */ + iamId: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `lockApiKey` operation. */ - export interface LockApiKeyParams { - /** Unique ID of the API key. */ - id: string; + /** Parameters for the `createMfaReport` operation. */ + export interface CreateMfaReportParams { + /** ID of the account. */ + accountId: string; + /** Optional report type. The supported value is 'mfa_status'. List MFA enrollment status for all the + * identities. + */ + type?: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `unlockApiKey` operation. */ - export interface UnlockApiKeyParams { - /** Unique ID of the API key. */ - id: string; + /** Parameters for the `getMfaReport` operation. */ + export interface GetMfaReportParams { + /** ID of the account. */ + accountId: string; + /** Reference for the report to be generated, You can use 'latest' to get the latest report for the given + * account. + */ + reference: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `listServiceIds` operation. */ - export interface ListServiceIdsParams { - /** Account ID of the service ID(s) to query. This parameter is required (unless using a pagetoken). */ + /** Parameters for the `listAccountSettingsAssignments` operation. */ + export interface ListAccountSettingsAssignmentsParams { + /** Account ID of the Assignments to query. This parameter is required unless using a pagetoken. */ accountId?: string; - /** Name of the service ID(s) to query. Optional.20 items per page. Valid range is 1 to 100. */ - name?: string; + /** Filter results by Template Id. */ + templateId?: string; + /** Filter results Template Version. */ + templateVersion?: string; + /** Filter results by the assignment target. */ + target?: string; + /** Filter results by the assignment's target type. */ + targetType?: ListAccountSettingsAssignmentsConstants.TargetType | string; /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ - pagesize?: number; + limit?: number; /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ pagetoken?: string; - /** Optional sort property, valid values are name, description, created_at and modified_at. If specified, the - * items are sorted by the value of this property. - */ - sort?: string; - /** Optional sort order, valid values are asc and desc. Default: asc. */ - order?: ListServiceIdsConstants.Order | string; + /** If specified, the items are sorted by the value of this property. */ + sort?: ListAccountSettingsAssignmentsConstants.Sort | string; + /** Sort order. */ + order?: ListAccountSettingsAssignmentsConstants.Order | string; /** Defines if the entity history is included in the response. */ includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Constants for the `listServiceIds` operation. */ - export namespace ListServiceIdsConstants { - /** Optional sort order, valid values are asc and desc. Default: asc. */ + /** Constants for the `listAccountSettingsAssignments` operation. */ + export namespace ListAccountSettingsAssignmentsConstants { + /** Filter results by the assignment's target type. */ + export enum TargetType { + ACCOUNT = 'Account', + ACCOUNTGROUP = 'AccountGroup', + } + /** If specified, the items are sorted by the value of this property. */ + export enum Sort { + TEMPLATE_ID = 'template_id', + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + } + /** Sort order. */ export enum Order { ASC = 'asc', DESC = 'desc', } } - /** Parameters for the `createServiceId` operation. */ - export interface CreateServiceIdParams { - /** ID of the account the service ID belongs to. */ - accountId: string; - /** Name of the Service Id. The name is not checked for uniqueness. Therefore multiple names with the same value - * can exist. Access is done via the UUID of the Service Id. - */ - name: string; - /** The optional description of the Service Id. The 'description' property is only available if a description - * was provided during a create of a Service Id. - */ - description?: string; - /** Optional list of CRNs (string array) which point to the services connected to the service ID. */ - uniqueInstanceCrns?: string[]; - /** Parameters for the API key in the Create service Id V1 REST request. */ - apikey?: ApiKeyInsideCreateServiceIdRequest; - /** Indicates if the service ID is locked for further write operations. False by default. */ - entityLock?: string; + /** Parameters for the `createAccountSettingsAssignment` operation. */ + export interface CreateAccountSettingsAssignmentParams { + /** ID of the template to assign. */ + templateId: string; + /** Version of the template to assign. */ + templateVersion: number; + /** Type of target to deploy to. */ + targetType: CreateAccountSettingsAssignmentConstants.TargetType | string; + /** Identifier of target to deploy to. */ + target: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `getServiceId` operation. */ - export interface GetServiceIdParams { - /** Unique ID of the service ID. */ - id: string; + /** Constants for the `createAccountSettingsAssignment` operation. */ + export namespace CreateAccountSettingsAssignmentConstants { + /** Type of target to deploy to. */ + export enum TargetType { + ACCOUNT = 'Account', + ACCOUNTGROUP = 'AccountGroup', + } + } + + /** Parameters for the `getAccountSettingsAssignment` operation. */ + export interface GetAccountSettingsAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; /** Defines if the entity history is included in the response. */ includeHistory?: boolean; - /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive - * operation, so please only request this when needed. - */ - includeActivity?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `updateServiceId` operation. */ - export interface UpdateServiceIdParams { - /** Unique ID of the service ID to be updated. */ - id: string; - /** Version of the service ID to be updated. Specify the version that you retrieved as entity_tag (ETag header) - * when reading the service ID. This value helps identifying parallel usage of this API. Pass * to indicate to - * update any version available. This might result in stale updates. + /** Parameters for the `deleteAccountSettingsAssignment` operation. */ + export interface DeleteAccountSettingsAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `updateAccountSettingsAssignment` operation. */ + export interface UpdateAccountSettingsAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; + /** Version of the assignment to be updated. Specify the version that you retrieved when reading the assignment. + * This value helps identifying parallel usage of this API. Pass * to indicate to update any version available. + * This might result in stale updates. */ ifMatch: string; - /** The name of the service ID to update. If specified in the request the parameter must not be empty. The name - * is not checked for uniqueness. Failure to this will result in an Error condition. - */ - name?: string; - /** The description of the service ID to update. If specified an empty description will clear the description of - * the service ID. If an non empty value is provided the service ID will be updated. - */ - description?: string; - /** List of CRNs which point to the services connected to this service ID. If specified an empty list will clear - * all existing unique instance crns of the service ID. + /** Template version to be applied to the assignment. To retry all failed assignemtns, provide the existing + * version. To migrate to a different version, provide the new version number. */ - uniqueInstanceCrns?: string[]; + templateVersion: number; headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteServiceId` operation. */ - export interface DeleteServiceIdParams { - /** Unique ID of the service ID. */ - id: string; + /** Parameters for the `listAccountSettingsTemplates` operation. */ + export interface ListAccountSettingsTemplatesParams { + /** Account ID of the account settings templates to query. This parameter is required unless using a pagetoken. */ + accountId?: string; + /** Optional size of a single page. */ + limit?: string; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + sort?: ListAccountSettingsTemplatesConstants.Sort | string; + /** Optional sort order. */ + order?: ListAccountSettingsTemplatesConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `lockServiceId` operation. */ - export interface LockServiceIdParams { - /** Unique ID of the service ID. */ - id: string; + /** Constants for the `listAccountSettingsTemplates` operation. */ + export namespace ListAccountSettingsTemplatesConstants { + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + export enum Sort { + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + NAME = 'name', + } + /** Optional sort order. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', + } + } + + /** Parameters for the `createAccountSettingsTemplate` operation. */ + export interface CreateAccountSettingsTemplateParams { + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. */ + name?: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + accountSettings?: AccountSettingsComponent; headers?: OutgoingHttpHeaders; } - /** Parameters for the `unlockServiceId` operation. */ - export interface UnlockServiceIdParams { - /** Unique ID of the service ID. */ - id: string; + /** Parameters for the `getLatestAccountSettingsTemplateVersion` operation. */ + export interface GetLatestAccountSettingsTemplateVersionParams { + /** ID of the account settings template. */ + templateId: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `createProfile` operation. */ - export interface CreateProfileParams { - /** Name of the trusted profile. The name is checked for uniqueness. Therefore trusted profiles with the same - * names can not exist in the same account. - */ - name: string; - /** The account ID of the trusted profile. */ - accountId: string; - /** The optional description of the trusted profile. The 'description' property is only available if a - * description was provided during creation of trusted profile. - */ - description?: string; + /** Parameters for the `deleteAllVersionsOfAccountSettingsTemplate` operation. */ + export interface DeleteAllVersionsOfAccountSettingsTemplateParams { + /** ID of the account settings template. */ + templateId: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `listProfiles` operation. */ - export interface ListProfilesParams { - /** Account ID to query for trusted profiles. */ - accountId: string; - /** Name of the trusted profile to query. */ - name?: string; - /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ - pagesize?: number; - /** Optional sort property, valid values are name, description, created_at and modified_at. If specified, the - * items are sorted by the value of this property. - */ - sort?: string; - /** Optional sort order, valid values are asc and desc. Default: asc. */ - order?: ListProfilesConstants.Order | string; - /** Defines if the entity history is included in the response. */ - includeHistory?: boolean; + /** Parameters for the `listVersionsOfAccountSettingsTemplate` operation. */ + export interface ListVersionsOfAccountSettingsTemplateParams { + /** ID of the account settings template. */ + templateId: string; + /** Optional size of a single page. */ + limit?: string; /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ pagetoken?: string; + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + sort?: ListVersionsOfAccountSettingsTemplateConstants.Sort | string; + /** Optional sort order. */ + order?: ListVersionsOfAccountSettingsTemplateConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: string; headers?: OutgoingHttpHeaders; } - /** Constants for the `listProfiles` operation. */ - export namespace ListProfilesConstants { - /** Optional sort order, valid values are asc and desc. Default: asc. */ + /** Constants for the `listVersionsOfAccountSettingsTemplate` operation. */ + export namespace ListVersionsOfAccountSettingsTemplateConstants { + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + export enum Sort { + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + NAME = 'name', + } + /** Optional sort order. */ export enum Order { ASC = 'asc', DESC = 'desc', } } - /** Parameters for the `getProfile` operation. */ - export interface GetProfileParams { - /** ID of the trusted profile to get. */ - profileId: string; - /** Defines if the entity's activity is included in the response. Retrieving activity data is an expensive - * operation, so please only request this when needed. - */ - includeActivity?: boolean; - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `updateProfile` operation. */ - export interface UpdateProfileParams { - /** ID of the trusted profile to be updated. */ - profileId: string; - /** Version of the trusted profile to be updated. Specify the version that you retrived when reading list of - * trusted profiles. This value helps to identify any parallel usage of trusted profile. Pass * to indicate to - * update any version available. This might result in stale updates. - */ - ifMatch: string; - /** The name of the trusted profile to update. If specified in the request the parameter must not be empty. The - * name is checked for uniqueness. Failure to this will result in an Error condition. - */ + /** Parameters for the `createAccountSettingsTemplateVersion` operation. */ + export interface CreateAccountSettingsTemplateVersionParams { + /** ID of the account settings template. */ + templateId: string; + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. */ name?: string; - /** The description of the trusted profile to update. If specified an empty description will clear the - * description of the trusted profile. If a non empty value is provided the trusted profile will be updated. - */ + /** The description of the trusted profile template. Describe the template for enterprise account users. */ description?: string; + accountSettings?: AccountSettingsComponent; headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteProfile` operation. */ - export interface DeleteProfileParams { - /** ID of the trusted profile. */ - profileId: string; + /** Parameters for the `getAccountSettingsTemplateVersion` operation. */ + export interface GetAccountSettingsTemplateVersionParams { + /** ID of the account settings template. */ + templateId: string; + /** Version of the account settings template. */ + version: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `createClaimRule` operation. */ - export interface CreateClaimRuleParams { - /** ID of the trusted profile to create a claim rule. */ - profileId: string; - /** Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. */ - type: string; - /** Conditions of this claim rule. */ - conditions: ProfileClaimRuleConditions[]; - /** Context with key properties for problem determination. */ - context?: ResponseContext; - /** Name of the claim rule to be created or updated. */ - name?: string; - /** The realm name of the Idp this claim rule applies to. This field is required only if the type is specified - * as 'Profile-SAML'. - */ - realmName?: string; - /** The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid - * values are VSI, IKS_SA, ROKS_SA. + /** Parameters for the `updateAccountSettingsTemplateVersion` operation. */ + export interface UpdateAccountSettingsTemplateVersionParams { + /** Entity tag of the Template to be updated. Specify the tag that you retrieved when reading the account + * settings template. This value helps identifying parallel usage of this API. Pass * to indicate to update any + * version available. This might result in stale updates. */ - crType?: string; - /** Session expiration in seconds, only required if type is 'Profile-SAML'. */ - expiration?: number; + ifMatch: string; + /** ID of the account settings template. */ + templateId: string; + /** Version of the account settings template. */ + version: string; + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. */ + name?: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + accountSettings?: AccountSettingsComponent; headers?: OutgoingHttpHeaders; } - /** Parameters for the `listClaimRules` operation. */ - export interface ListClaimRulesParams { - /** ID of the trusted profile. */ - profileId: string; + /** Parameters for the `deleteAccountSettingsTemplateVersion` operation. */ + export interface DeleteAccountSettingsTemplateVersionParams { + /** ID of the account settings template. */ + templateId: string; + /** Version of the account settings template. */ + version: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `getClaimRule` operation. */ - export interface GetClaimRuleParams { - /** ID of the trusted profile. */ - profileId: string; - /** ID of the claim rule to get. */ - ruleId: string; + /** Parameters for the `commitAccountSettingsTemplate` operation. */ + export interface CommitAccountSettingsTemplateParams { + /** ID of the account settings template. */ + templateId: string; + /** Version of the account settings template. */ + version: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `updateClaimRule` operation. */ - export interface UpdateClaimRuleParams { - /** ID of the trusted profile. */ - profileId: string; - /** ID of the claim rule to update. */ - ruleId: string; - /** Version of the claim rule to be updated. Specify the version that you retrived when reading list of claim - * rules. This value helps to identify any parallel usage of claim rule. Pass * to indicate to update any version - * available. This might result in stale updates. - */ - ifMatch: string; - /** Type of the claim rule, either 'Profile-SAML' or 'Profile-CR'. */ - type: string; - /** Conditions of this claim rule. */ - conditions: ProfileClaimRuleConditions[]; - /** Context with key properties for problem determination. */ - context?: ResponseContext; - /** Name of the claim rule to be created or updated. */ - name?: string; - /** The realm name of the Idp this claim rule applies to. This field is required only if the type is specified - * as 'Profile-SAML'. - */ - realmName?: string; - /** The compute resource type the rule applies to, required only if type is specified as 'Profile-CR'. Valid - * values are VSI, IKS_SA, ROKS_SA. + /** Parameters for the `createReport` operation. */ + export interface CreateReportParams { + /** ID of the account. */ + accountId: string; + /** Optional report type. The supported value is 'inactive'. List all identities that have not authenticated + * within the time indicated by duration. */ - crType?: string; - /** Session expiration in seconds, only required if type is 'Profile-SAML'. */ - expiration?: number; + type?: string; + /** Optional duration of the report, supported unit of duration is hours. */ + duration?: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteClaimRule` operation. */ - export interface DeleteClaimRuleParams { - /** ID of the trusted profile. */ - profileId: string; - /** ID of the claim rule to delete. */ - ruleId: string; + /** Parameters for the `getReport` operation. */ + export interface GetReportParams { + /** ID of the account. */ + accountId: string; + /** Reference for the report to be generated, You can use 'latest' to get the latest report for the given + * account. + */ + reference: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `createLink` operation. */ - export interface CreateLinkParams { - /** ID of the trusted profile. */ - profileId: string; - /** The compute resource type. Valid values are VSI, IKS_SA, ROKS_SA. */ - crType: string; - /** Link details. */ - link: CreateProfileLinkRequestLink; - /** Optional name of the Link. */ - name?: string; + /** Parameters for the `listTrustedProfileAssignments` operation. */ + export interface ListTrustedProfileAssignmentsParams { + /** Account ID of the Assignments to query. This parameter is required unless using a pagetoken. */ + accountId?: string; + /** Filter results by Template Id. */ + templateId?: string; + /** Filter results Template Version. */ + templateVersion?: string; + /** Filter results by the assignment target. */ + target?: string; + /** Filter results by the assignment's target type. */ + targetType?: ListTrustedProfileAssignmentsConstants.TargetType | string; + /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ + limit?: number; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** If specified, the items are sorted by the value of this property. */ + sort?: ListTrustedProfileAssignmentsConstants.Sort | string; + /** Sort order. */ + order?: ListTrustedProfileAssignmentsConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `listLinks` operation. */ - export interface ListLinksParams { - /** ID of the trusted profile. */ - profileId: string; - headers?: OutgoingHttpHeaders; + /** Constants for the `listTrustedProfileAssignments` operation. */ + export namespace ListTrustedProfileAssignmentsConstants { + /** Filter results by the assignment's target type. */ + export enum TargetType { + ACCOUNT = 'Account', + ACCOUNTGROUP = 'AccountGroup', + } + /** If specified, the items are sorted by the value of this property. */ + export enum Sort { + TEMPLATE_ID = 'template_id', + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + } + /** Sort order. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', + } } - /** Parameters for the `getLink` operation. */ - export interface GetLinkParams { - /** ID of the trusted profile. */ - profileId: string; - /** ID of the link. */ - linkId: string; + /** Parameters for the `createTrustedProfileAssignment` operation. */ + export interface CreateTrustedProfileAssignmentParams { + /** ID of the template to assign. */ + templateId: string; + /** Version of the template to assign. */ + templateVersion: number; + /** Type of target to deploy to. */ + targetType: CreateTrustedProfileAssignmentConstants.TargetType | string; + /** Identifier of target to deploy to. */ + target: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteLink` operation. */ - export interface DeleteLinkParams { - /** ID of the trusted profile. */ - profileId: string; - /** ID of the link. */ - linkId: string; + /** Constants for the `createTrustedProfileAssignment` operation. */ + export namespace CreateTrustedProfileAssignmentConstants { + /** Type of target to deploy to. */ + export enum TargetType { + ACCOUNT = 'Account', + ACCOUNTGROUP = 'AccountGroup', + } + } + + /** Parameters for the `getTrustedProfileAssignment` operation. */ + export interface GetTrustedProfileAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `getProfileIdentities` operation. */ - export interface GetProfileIdentitiesParams { - /** ID of the trusted profile. */ - profileId: string; + /** Parameters for the `deleteTrustedProfileAssignment` operation. */ + export interface DeleteTrustedProfileAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; headers?: OutgoingHttpHeaders; } - /** Parameters for the `setProfileIdentities` operation. */ - export interface SetProfileIdentitiesParams { - /** ID of the trusted profile. */ - profileId: string; - /** Entity tag of the Identities to be updated. Specify the tag that you retrieved when reading the Profile - * Identities. This value helps identify parallel usage of this API. Pass * to indicate updating any available - * version, which may result in stale updates. + /** Parameters for the `updateTrustedProfileAssignment` operation. */ + export interface UpdateTrustedProfileAssignmentParams { + /** ID of the Assignment Record. */ + assignmentId: string; + /** Version of the Assignment to be updated. Specify the version that you retrieved when reading the Assignment. + * This value helps identifying parallel usage of this API. Pass * to indicate to update any version available. + * This might result in stale updates. */ ifMatch: string; - /** List of identities that can assume the trusted profile. */ - identities?: ProfileIdentity[]; + /** Template version to be applied to the assignment. To retry all failed assignemtns, provide the existing + * version. To migrate to a different version, provide the new version number. + */ + templateVersion: number; headers?: OutgoingHttpHeaders; } - /** Parameters for the `setProfileIdentity` operation. */ - export interface SetProfileIdentityParams { - /** ID of the trusted profile. */ - profileId: string; - /** Type of the identity. */ - identityType: SetProfileIdentityConstants.IdentityType | string; - /** Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), - * serviceid or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the - * identifier 'crn' it uses account id contained in the CRN. - */ - identifier: string; - /** Type of the identity. */ - type: SetProfileIdentityConstants.Type | string; - /** IAM ID of the identity. */ - iamId?: string; - /** Only valid for the type user. Accounts from which a user can assume the trusted profile. */ - accounts?: string[]; - /** Description of the identity that can assume the trusted profile. This is optional field for all the types of - * identities. When this field is not set for the identity type 'serviceid' then the description of the service id - * is used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service - * project'. - */ - description?: string; + /** Parameters for the `listProfileTemplates` operation. */ + export interface ListProfileTemplatesParams { + /** Account ID of the trusted profile templates to query. This parameter is required unless using a pagetoken. */ + accountId?: string; + /** Optional size of a single page. */ + limit?: string; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** Optional sort property. If specified, the returned templates are sorted according to this property. */ + sort?: ListProfileTemplatesConstants.Sort | string; + /** Optional sort order. */ + order?: ListProfileTemplatesConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: string; headers?: OutgoingHttpHeaders; } - /** Constants for the `setProfileIdentity` operation. */ - export namespace SetProfileIdentityConstants { - /** Type of the identity. */ - export enum IdentityType { - USER = 'user', - SERVICEID = 'serviceid', - CRN = 'crn', + /** Constants for the `listProfileTemplates` operation. */ + export namespace ListProfileTemplatesConstants { + /** Optional sort property. If specified, the returned templates are sorted according to this property. */ + export enum Sort { + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + NAME = 'name', } - /** Type of the identity. */ - export enum Type { - USER = 'user', - SERVICEID = 'serviceid', - CRN = 'crn', + /** Optional sort order. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', } } - /** Parameters for the `getProfileIdentity` operation. */ - export interface GetProfileIdentityParams { - /** ID of the trusted profile. */ - profileId: string; - /** Type of the identity. */ - identityType: GetProfileIdentityConstants.IdentityType | string; - /** Identifier of the identity that can assume the trusted profiles. */ - identifierId: string; + /** Parameters for the `createProfileTemplate` operation. */ + export interface CreateProfileTemplateParams { + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. Required field + * when creating a new template. Otherwise this field is optional. If the field is included it will change the name + * value for all existing versions of the template. + */ + name?: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + /** Input body parameters for the TemplateProfileComponent. */ + profile?: TemplateProfileComponentRequest; + /** Existing policy templates that you can reference to assign access in the trusted profile component. */ + policyTemplateReferences?: PolicyTemplateReference[]; headers?: OutgoingHttpHeaders; } - /** Constants for the `getProfileIdentity` operation. */ - export namespace GetProfileIdentityConstants { - /** Type of the identity. */ - export enum IdentityType { - USER = 'user', - SERVICEID = 'serviceid', - CRN = 'crn', - } + /** Parameters for the `getLatestProfileTemplateVersion` operation. */ + export interface GetLatestProfileTemplateVersionParams { + /** ID of the trusted profile template. */ + templateId: string; + /** Defines if the entity history is included in the response. */ + includeHistory?: boolean; + headers?: OutgoingHttpHeaders; } - /** Parameters for the `deleteProfileIdentity` operation. */ - export interface DeleteProfileIdentityParams { - /** ID of the trusted profile. */ - profileId: string; - /** Type of the identity. */ - identityType: DeleteProfileIdentityConstants.IdentityType | string; - /** Identifier of the identity that can assume the trusted profiles. */ - identifierId: string; + /** Parameters for the `deleteAllVersionsOfProfileTemplate` operation. */ + export interface DeleteAllVersionsOfProfileTemplateParams { + /** ID of the trusted profile template. */ + templateId: string; headers?: OutgoingHttpHeaders; } - /** Constants for the `deleteProfileIdentity` operation. */ - export namespace DeleteProfileIdentityConstants { - /** Type of the identity. */ - export enum IdentityType { - USER = 'user', - SERVICEID = 'serviceid', - CRN = 'crn', + /** Parameters for the `listVersionsOfProfileTemplate` operation. */ + export interface ListVersionsOfProfileTemplateParams { + /** ID of the trusted profile template. */ + templateId: string; + /** Optional size of a single page. */ + limit?: string; + /** Optional Prev or Next page token returned from a previous query execution. Default is start with first page. */ + pagetoken?: string; + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + sort?: ListVersionsOfProfileTemplateConstants.Sort | string; + /** Optional sort order. */ + order?: ListVersionsOfProfileTemplateConstants.Order | string; + /** Defines if the entity history is included in the response. */ + includeHistory?: string; + headers?: OutgoingHttpHeaders; + } + + /** Constants for the `listVersionsOfProfileTemplate` operation. */ + export namespace ListVersionsOfProfileTemplateConstants { + /** Optional sort property. If specified, the returned templated are sorted according to this property. */ + export enum Sort { + CREATED_AT = 'created_at', + LAST_MODIFIED_AT = 'last_modified_at', + NAME = 'name', + } + /** Optional sort order. */ + export enum Order { + ASC = 'asc', + DESC = 'desc', } } - /** Parameters for the `getAccountSettings` operation. */ - export interface GetAccountSettingsParams { - /** Unique ID of the account. */ - accountId: string; + /** Parameters for the `createProfileTemplateVersion` operation. */ + export interface CreateProfileTemplateVersionParams { + /** ID of the trusted profile template. */ + templateId: string; + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. Required field + * when creating a new template. Otherwise this field is optional. If the field is included it will change the name + * value for all existing versions of the template. + */ + name?: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + /** Input body parameters for the TemplateProfileComponent. */ + profile?: TemplateProfileComponentRequest; + /** Existing policy templates that you can reference to assign access in the trusted profile component. */ + policyTemplateReferences?: PolicyTemplateReference[]; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `getProfileTemplateVersion` operation. */ + export interface GetProfileTemplateVersionParams { + /** ID of the trusted profile template. */ + templateId: string; + /** Version of the Profile Template. */ + version: string; /** Defines if the entity history is included in the response. */ includeHistory?: boolean; headers?: OutgoingHttpHeaders; } - /** Parameters for the `updateAccountSettings` operation. */ - export interface UpdateAccountSettingsParams { - /** Version of the account settings to be updated. Specify the version that you retrieved as entity_tag (ETag - * header) when reading the account. This value helps identifying parallel usage of this API. Pass * to indicate to - * update any version available. This might result in stale updates. + /** Parameters for the `updateProfileTemplateVersion` operation. */ + export interface UpdateProfileTemplateVersionParams { + /** Entity tag of the Template to be updated. Specify the tag that you retrieved when reading the Profile + * Template. This value helps identifying parallel usage of this API. Pass * to indicate to update any version + * available. This might result in stale updates. */ ifMatch: string; - /** The id of the account to update the settings for. */ - accountId: string; - /** Defines whether or not creating a Service Id is access controlled. Valid values: - * * RESTRICTED - to apply access control - * * NOT_RESTRICTED - to remove access control - * * NOT_SET - to unset a previously set value. + /** ID of the trusted profile template. */ + templateId: string; + /** Version of the Profile Template. */ + version: string; + /** ID of the account where the template resides. */ + accountId?: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. Required field + * when creating a new template. Otherwise this field is optional. If the field is included it will change the name + * value for all existing versions of the template. + */ + name?: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + /** Input body parameters for the TemplateProfileComponent. */ + profile?: TemplateProfileComponentRequest; + /** Existing policy templates that you can reference to assign access in the trusted profile component. */ + policyTemplateReferences?: PolicyTemplateReference[]; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `deleteProfileTemplateVersion` operation. */ + export interface DeleteProfileTemplateVersionParams { + /** ID of the trusted profile template. */ + templateId: string; + /** Version of the Profile Template. */ + version: string; + headers?: OutgoingHttpHeaders; + } + + /** Parameters for the `commitProfileTemplate` operation. */ + export interface CommitProfileTemplateParams { + /** ID of the trusted profile template. */ + templateId: string; + /** Version of the Profile Template. */ + version: string; + headers?: OutgoingHttpHeaders; + } + + /************************* + * model interfaces + ************************/ + + /** AccountBasedMfaEnrollment. */ + export interface AccountBasedMfaEnrollment { + security_questions: MfaEnrollmentTypeStatus; + totp: MfaEnrollmentTypeStatus; + verisign: MfaEnrollmentTypeStatus; + /** The enrollment complies to the effective requirement. */ + complies: boolean; + } + + /** AccountSettingsComponent. */ + export interface AccountSettingsComponent { + /** Defines whether or not creating a service ID is access controlled. Valid values: + * * RESTRICTED - only users assigned the 'Service ID creator' role on the IAM Identity Service can create + * service IDs, including the account owner + * * NOT_RESTRICTED - all members of an account can create service IDs + * * NOT_SET - to 'unset' a previous set value. */ - restrictCreateServiceId?: UpdateAccountSettingsConstants.RestrictCreateServiceId | string; + restrict_create_service_id?: string; /** Defines whether or not creating platform API keys is access controlled. Valid values: * * RESTRICTED - to apply access control * * NOT_RESTRICTED - to remove access control * * NOT_SET - to 'unset' a previous set value. */ - restrictCreatePlatformApikey?: - | UpdateAccountSettingsConstants.RestrictCreatePlatformApikey - | string; + restrict_create_platform_apikey?: string; /** Defines the IP addresses and subnets from which IAM tokens can be created for the account. */ - allowedIpAddresses?: string; + allowed_ip_addresses?: string; /** Defines the MFA trait for the account. Valid values: * * NONE - No MFA trait set - * * NONE_NO_ROPC- No MFA, disable CLI logins with only a password * * TOTP - For all non-federated IBMId users * * TOTP4ALL - For all users * * LEVEL1 - Email-based MFA for all users * * LEVEL2 - TOTP-based MFA for all users * * LEVEL3 - U2F MFA for all users. */ - mfa?: UpdateAccountSettingsConstants.Mfa | string; + mfa?: string; /** List of users that are exempted from the MFA requirement of the account. */ - userMfa?: AccountSettingsUserMFA[]; + user_mfa?: AccountSettingsUserMFA[]; /** Defines the session expiration in seconds for the account. Valid values: * * Any whole number between between '900' and '86400' * * NOT_SET - To unset account setting and use service default. */ - sessionExpirationInSeconds?: string; + session_expiration_in_seconds?: string; /** Defines the period of time in seconds in which a session will be invalidated due to inactivity. Valid * values: * * Any whole number between '900' and '7200' * * NOT_SET - To unset account setting and use service default. */ - sessionInvalidationInSeconds?: string; - /** Defines the max allowed sessions per identity required by the account. Value values: + session_invalidation_in_seconds?: string; + /** Defines the max allowed sessions per identity required by the account. Valid values: * * Any whole number greater than 0 * * NOT_SET - To unset account setting and use service default. */ - maxSessionsPerIdentity?: string; + max_sessions_per_identity?: string; /** Defines the access token expiration in seconds. Valid values: * * Any whole number between '900' and '3600' * * NOT_SET - To unset account setting and use service default. */ - systemAccessTokenExpirationInSeconds?: string; + system_access_token_expiration_in_seconds?: string; /** Defines the refresh token expiration in seconds. Valid values: * * Any whole number between '900' and '259200' * * NOT_SET - To unset account setting and use service default. */ - systemRefreshTokenExpirationInSeconds?: string; - headers?: OutgoingHttpHeaders; - } - - /** Constants for the `updateAccountSettings` operation. */ - export namespace UpdateAccountSettingsConstants { - /** Defines whether or not creating a Service Id is access controlled. Valid values: * RESTRICTED - to apply access control * NOT_RESTRICTED - to remove access control * NOT_SET - to unset a previously set value. */ - export enum RestrictCreateServiceId { - RESTRICTED = 'RESTRICTED', - NOT_RESTRICTED = 'NOT_RESTRICTED', - NOT_SET = 'NOT_SET', - } - /** Defines whether or not creating platform API keys is access controlled. Valid values: * RESTRICTED - to apply access control * NOT_RESTRICTED - to remove access control * NOT_SET - to 'unset' a previous set value. */ - export enum RestrictCreatePlatformApikey { - RESTRICTED = 'RESTRICTED', - NOT_RESTRICTED = 'NOT_RESTRICTED', - NOT_SET = 'NOT_SET', - } - /** Defines the MFA trait for the account. Valid values: * NONE - No MFA trait set * NONE_NO_ROPC- No MFA, disable CLI logins with only a password * TOTP - For all non-federated IBMId users * TOTP4ALL - For all users * LEVEL1 - Email-based MFA for all users * LEVEL2 - TOTP-based MFA for all users * LEVEL3 - U2F MFA for all users. */ - export enum Mfa { - NONE = 'NONE', - NONE_NO_ROPC = 'NONE_NO_ROPC', - TOTP = 'TOTP', - TOTP4ALL = 'TOTP4ALL', - LEVEL1 = 'LEVEL1', - LEVEL2 = 'LEVEL2', - LEVEL3 = 'LEVEL3', - } - } - - /** Parameters for the `getMfaStatus` operation. */ - export interface GetMfaStatusParams { - /** ID of the account. */ - accountId: string; - /** iam_id of the user. This user must be the member of the account. */ - iamId: string; - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `createMfaReport` operation. */ - export interface CreateMfaReportParams { - /** ID of the account. */ - accountId: string; - /** Optional report type. The supported value is 'mfa_status'. List MFA enrollment status for all the - * identities. - */ - type?: string; - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `getMfaReport` operation. */ - export interface GetMfaReportParams { - /** ID of the account. */ - accountId: string; - /** Reference for the report to be generated, You can use 'latest' to get the latest report for the given - * account. - */ - reference: string; - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `createReport` operation. */ - export interface CreateReportParams { - /** ID of the account. */ - accountId: string; - /** Optional report type. The supported value is 'inactive'. List all identities that have not authenticated - * within the time indicated by duration. - */ - type?: string; - /** Optional duration of the report. The supported unit of duration is hours. */ - duration?: string; - headers?: OutgoingHttpHeaders; - } - - /** Parameters for the `getReport` operation. */ - export interface GetReportParams { - /** ID of the account. */ - accountId: string; - /** Reference for the report to be generated, You can use 'latest' to get the latest report for the given - * account. - */ - reference: string; - headers?: OutgoingHttpHeaders; - } - - /************************* - * model interfaces - ************************/ - - /** AccountBasedMfaEnrollment. */ - export interface AccountBasedMfaEnrollment { - security_questions: MfaEnrollmentTypeStatus; - totp: MfaEnrollmentTypeStatus; - verisign: MfaEnrollmentTypeStatus; - /** The enrollment complies to the effective requirement. */ - complies: boolean; + system_refresh_token_expiration_in_seconds?: string; } /** Response body format for Account Settings REST requests. */ @@ -3316,9 +5822,10 @@ namespace IamIdentityV1 { context?: ResponseContext; /** Unique ID of the account. */ account_id: string; - /** Defines whether or not creating a Service Id is access controlled. Valid values: - * * RESTRICTED - to apply access control - * * NOT_RESTRICTED - to remove access control + /** Defines whether or not creating a service ID is access controlled. Valid values: + * * RESTRICTED - only users assigned the 'Service ID creator' role on the IAM Identity Service can create + * service IDs, including the account owner + * * NOT_RESTRICTED - all members of an account can create service IDs * * NOT_SET - to 'unset' a previous set value. */ restrict_create_service_id: string; @@ -3374,6 +5881,60 @@ namespace IamIdentityV1 { system_refresh_token_expiration_in_seconds: string; } + /** AccountSettingsTemplateList. */ + export interface AccountSettingsTemplateList { + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** The offset of the current page. */ + offset?: number; + /** Optional size of a single page. */ + limit?: number; + /** Link to the first page. */ + first?: string; + /** Link to the previous available page. If 'previous' property is not part of the response no previous page is + * available. + */ + previous?: string; + /** Link to the next available page. If 'next' property is not part of the response no next page is available. */ + next?: string; + /** List of account settings templates based on the query paramters and the page size. The + * account_settings_templates array is always part of the response but might be empty depending on the query + * parameter values provided. + */ + account_settings_templates: AccountSettingsTemplateResponse[]; + } + + /** Response body format for account settings template REST requests. */ + export interface AccountSettingsTemplateResponse { + /** ID of the the template. */ + id: string; + /** Version of the the template. */ + version: number; + /** ID of the account where the template resides. */ + account_id: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. */ + name: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + /** Committed flag determines if the template is ready for assignment. */ + committed: boolean; + account_settings: AccountSettingsComponent; + /** History of the Template. */ + history?: EnityHistoryRecord[]; + /** Entity tag for this templateId-version combination. */ + entity_tag: string; + /** Cloud resource name. */ + crn: string; + /** Template Created At. */ + created_at?: string; + /** IAMid of the creator. */ + created_by_id?: string; + /** Template last modified at. */ + last_modified_at?: string; + /** IAMid of the identity that made the latest modification. */ + last_modified_by_id?: string; + } + /** AccountSettingsUserMFA. */ export interface AccountSettingsUserMFA { /** The iam_id of the user. */ @@ -3560,6 +6121,33 @@ namespace IamIdentityV1 { last_authn?: string; } + /** Error information. */ + export interface Error { + /** Error code of the REST Exception. */ + code: string; + /** Error message code of the REST Exception. */ + message_code: string; + /** Error message of the REST Exception. Error messages are derived base on the input locale of the REST request + * and the available Message catalogs. Dynamic fallback to 'us-english' is happening if no message catalog is + * available for the provided input locale. + */ + message: string; + /** Error details of the REST Exception. */ + details?: string; + } + + /** Response body parameters in case of error situations. */ + export interface ExceptionResponse { + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** Error message code of the REST Exception. */ + status_code: string; + /** List of errors that occured. */ + errors: Error[]; + /** Unique ID of the requst. */ + trace?: string; + } + /** IdBasedMfaEnrollment. */ export interface IdBasedMfaEnrollment { /** Defines the MFA trait for the account. Valid values: @@ -3612,6 +6200,14 @@ namespace IamIdentityV1 { account_based_mfa?: AccountBasedMfaEnrollment; } + /** Metadata for external access policy. */ + export interface PolicyTemplateReference { + /** ID of Access Policy Template. */ + id: string; + /** Version of Access Policy Template. */ + version: string; + } + /** ProfileClaimRule. */ export interface ProfileClaimRule { /** the unique identifier of the claim rule. */ @@ -3638,9 +6234,7 @@ namespace IamIdentityV1 { /** ProfileClaimRuleConditions. */ export interface ProfileClaimRuleConditions { - /** The claim to evaluate against. [Learn - * more](/docs/account?topic=account-iam-condition-properties&interface=ui#cr-attribute-names). - */ + /** The claim to evaluate against. */ claim: string; /** The operation to perform on the claim. valid values are EQUALS, NOT_EQUALS, EQUALS_IGNORE_CASE, * NOT_EQUALS_IGNORE_CASE, CONTAINS, IN. @@ -3663,13 +6257,32 @@ namespace IamIdentityV1 { /** Entity tag of the profile identities response. */ entity_tag?: string; /** List of identities. */ - identities?: ProfileIdentity[]; + identities?: ProfileIdentityResponse[]; + } + + /** ProfileIdentityRequest. */ + export interface ProfileIdentityRequest { + /** Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), + * serviceid or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the + * identifier 'crn' it uses account id contained in the CRN. + */ + identifier: string; + /** Type of the identity. */ + type: string; + /** Only valid for the type user. Accounts from which a user can assume the trusted profile. */ + accounts?: string[]; + /** Description of the identity that can assume the trusted profile. This is optional field for all the types of + * identities. When this field is not set for the identity type 'serviceid' then the description of the service id + * is used. Description is recommended for the identity type 'crn' E.g. 'Instance 1234 of IBM Cloud Service + * project'. + */ + description?: string; } - /** ProfileIdentity. */ - export interface ProfileIdentity { + /** ProfileIdentityResponse. */ + export interface ProfileIdentityResponse { /** IAM ID of the identity. */ - iam_id?: string; + iam_id: string; /** Identifier of the identity that can assume the trusted profiles. This can be a user identifier (IAM id), * serviceid or crn. Internally it uses account id of the service id for the identifier 'serviceid' and for the * identifier 'crn' it uses account id contained in the CRN. @@ -3853,6 +6466,133 @@ namespace IamIdentityV1 { serviceids: ServiceId[]; } + /** List Response body format for Template Assignments Records. */ + export interface TemplateAssignmentListResponse { + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** The offset of the current page. */ + offset?: number; + /** Optional size of a single page. Default is 20 items per page. Valid range is 1 to 100. */ + limit?: number; + /** Link to the first page. */ + first?: string; + /** Link to the previous available page. If 'previous' property is not part of the response no previous page is + * available. + */ + previous?: string; + /** Link to the next available page. If 'next' property is not part of the response no next page is available. */ + next?: string; + /** List of Assignments based on the query paramters and the page size. The assignments array is always part of + * the response but might be empty depending on the query parameter values provided. + */ + assignments: TemplateAssignmentResponse[]; + } + + /** Body parameters for created resource. */ + export interface TemplateAssignmentResource { + /** Id of the created resource. */ + id?: string; + } + + /** Body parameters for assignment error. */ + export interface TemplateAssignmentResourceError { + /** Name of the error. */ + name?: string; + /** Internal error code. */ + errorCode?: string; + /** Error message detailing the nature of the error. */ + message?: string; + /** Internal status code for the error. */ + statusCode?: string; + } + + /** Response body format for Template Assignment Record. */ + export interface TemplateAssignmentResponse { + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** Assignment record Id. */ + id: string; + /** Enterprise account Id. */ + account_id: string; + /** Template Id. */ + template_id: string; + /** Template version. */ + template_version: number; + /** Assignment target type. */ + target_type: string; + /** Assignment target. */ + target: string; + /** Assignment status. */ + status: string; + /** Status breakdown per target account of IAM resources created or errors encountered in attempting to create + * those IAM resources. IAM resources are only included in the response providing the assignment is not in + * progress. IAM resources are also only included when getting a single assignment, and excluded by list APIs. + */ + resources?: TemplateAssignmentResponseResource[]; + /** Assignment history. */ + history?: EnityHistoryRecord[]; + /** Href. */ + href?: string; + /** Assignment created at. */ + created_at: string; + /** IAMid of the identity that created the assignment. */ + created_by_id: string; + /** Assignment modified at. */ + last_modified_at: string; + /** IAMid of the identity that last modified the assignment. */ + last_modified_by_id: string; + /** Entity tag for this assignment record. */ + entity_tag: string; + } + + /** Overview of resources assignment per target account. */ + export interface TemplateAssignmentResponseResource { + /** Target account where the IAM resource is created. */ + target: string; + profile?: TemplateAssignmentResponseResourceDetail; + account_settings?: TemplateAssignmentResponseResourceDetail; + /** Policy resource(s) included only for trusted profile assignments with policy references. */ + policy_template_refs?: TemplateAssignmentResponseResourceDetail[]; + } + + /** TemplateAssignmentResponseResourceDetail. */ + export interface TemplateAssignmentResponseResourceDetail { + /** Policy Template Id, only returned for a profile assignment with policy references. */ + id?: string; + /** Policy version, only returned for a profile assignment with policy references. */ + version?: string; + /** Body parameters for created resource. */ + resource_created?: TemplateAssignmentResource; + /** Body parameters for assignment error. */ + error_message?: TemplateAssignmentResourceError; + /** Status for the target account's assignment. */ + status: string; + } + + /** Input body parameters for the TemplateProfileComponent. */ + export interface TemplateProfileComponentRequest { + /** Name of the Profile. */ + name: string; + /** Description of the Profile. */ + description?: string; + /** Rules for the Profile. */ + rules?: TrustedProfileTemplateClaimRule[]; + /** Identities for the Profile. */ + identities?: ProfileIdentityRequest[]; + } + + /** Input body parameters for the TemplateProfileComponent. */ + export interface TemplateProfileComponentResponse { + /** Name of the Profile. */ + name: string; + /** Description of the Profile. */ + description?: string; + /** Rules for the Profile. */ + rules?: TrustedProfileTemplateClaimRule[]; + /** Identities for the Profile. */ + identities?: ProfileIdentityResponse[]; + } + /** Response body format for trusted profile V1 REST requests. */ export interface TrustedProfile { /** Context with key properties for problem determination. */ @@ -3883,6 +6623,16 @@ namespace IamIdentityV1 { iam_id: string; /** ID of the account that this trusted profile belong to. */ account_id: string; + /** ID of the IAM template that was used to create an enterprise-managed trusted profile in your account. When + * returned, this indicates that the trusted profile is created from and managed by a template in the root + * enterprise account. + */ + template_id?: string; + /** ID of the assignment that was used to create an enterprise-managed trusted profile in your account. When + * returned, this indicates that the trusted profile is created from and managed by a template in the root + * enterprise account. + */ + assignment_id?: string; /** IMS acount ID of the trusted profile. */ ims_account_id?: number; /** IMS user ID of the trusted profile. */ @@ -3892,6 +6642,78 @@ namespace IamIdentityV1 { activity?: Activity; } + /** TrustedProfileTemplateClaimRule. */ + export interface TrustedProfileTemplateClaimRule { + /** Name of the claim rule to be created or updated. */ + name?: string; + /** Type of the claim rule. */ + type: string; + /** The realm name of the Idp this claim rule applies to. This field is required only if the type is specified + * as 'Profile-SAML'. + */ + realm_name?: string; + /** Session expiration in seconds, only required if type is 'Profile-SAML'. */ + expiration?: number; + /** Conditions of this claim rule. */ + conditions: ProfileClaimRuleConditions[]; + } + + /** TrustedProfileTemplateList. */ + export interface TrustedProfileTemplateList { + /** Context with key properties for problem determination. */ + context?: ResponseContext; + /** The offset of the current page. */ + offset?: number; + /** Optional size of a single page. */ + limit?: number; + /** Link to the first page. */ + first?: string; + /** Link to the previous available page. If 'previous' property is not part of the response no previous page is + * available. + */ + previous?: string; + /** Link to the next available page. If 'next' property is not part of the response no next page is available. */ + next?: string; + /** List of Profile Templates based on the query paramters and the page size. The profile_templates array is + * always part of the response but might be empty depending on the query parameter values provided. + */ + profile_templates: TrustedProfileTemplateResponse[]; + } + + /** Response body format for Trusted Profile Template REST requests. */ + export interface TrustedProfileTemplateResponse { + /** ID of the the template. */ + id: string; + /** Version of the the template. */ + version: number; + /** ID of the account where the template resides. */ + account_id: string; + /** The name of the trusted profile template. This is visible only in the enterprise account. */ + name: string; + /** The description of the trusted profile template. Describe the template for enterprise account users. */ + description?: string; + /** Committed flag determines if the template is ready for assignment. */ + committed?: boolean; + /** Input body parameters for the TemplateProfileComponent. */ + profile?: TemplateProfileComponentResponse; + /** Existing policy templates that you can reference to assign access in the trusted profile component. */ + policy_template_references?: PolicyTemplateReference[]; + /** History of the trusted profile template. */ + history?: EnityHistoryRecord[]; + /** Entity tag for this templateId-version combination. */ + entity_tag?: string; + /** Cloud resource name. */ + crn?: string; + /** Timestamp of when the template was created. */ + created_at?: string; + /** IAMid of the creator. */ + created_by_id?: string; + /** Timestamp of when the template was last modified. */ + last_modified_at?: string; + /** IAMid of the identity that made the latest modification. */ + last_modified_by_id?: string; + } + /** Response body format for the List trusted profiles V1 REST request. */ export interface TrustedProfilesList { /** Context with key properties for problem determination. */ diff --git a/test/integration/iam-identity.v1.test.js b/test/integration/iam-identity.v1.test.js index 8478fcf1..382009b0 100644 --- a/test/integration/iam-identity.v1.test.js +++ b/test/integration/iam-identity.v1.test.js @@ -21,7 +21,7 @@ const IamIdentityV1 = require('../../dist/iam-identity/v1'); const authHelper = require('../resources/auth-helper.js'); // testcase timeout value (200s). -const timeout = 30000; +const timeout = 300000; // Location of our config file. const configFile = 'iam_identity.env'; @@ -34,14 +34,19 @@ const profileName1 = 'Node-SDK-IT-Profile1'; const profileName2 = 'Node-SDK-IT-Profile2'; const newDescription = 'This is an updated description'; const claimRuleType = 'Profile-SAML'; -const realmName = 'https://w3id.sso.ibm.com/auth/sps/samlidp2/saml20'; +const realmName = 'https://sdk.test.realm/1234'; const invalidAccountId = 'invalid'; +const profileTemplateName = 'Node-SDK-IT-ProfileTemplate'; +const profileTemplateProfileName = 'Node-SDK-IT-Profile-FromTemplate'; +const accountSettingsTemplateName = 'Node-SDK-IT-AccountSettingsTemplate'; let iamIdentityService; let accountId; let iamId; let iamIdMember; let iamApikey; +let enterpriseAccountId; +let enterpriseSubAccountId; let apikeyId1; let apikeyEtag1; @@ -67,6 +72,21 @@ let accountSettingsEtag; let reportReference; let reportReferenceMfa; +let profileTemplateId; +let profileTemplateVersion; +let profileTemplateEtag; +let profileTemplateAssignmentId; +let profileTemplateAssignmentEtag; +let profileTemplateScenarioComplete = false; + +let accountSettingsTemplateId; +let accountSettingsTemplateVersion; +let accountSettingsTemplateEtag; +let accountSettingsTemplateAssignmentId; +let accountSettingsTemplateAssignmentEtag; +let accountSettingsTemplateScenarioComplete = false; + + describe('IamIdentityV1_integration', () => { jest.setTimeout(timeout); @@ -82,8 +102,14 @@ describe('IamIdentityV1_integration', () => { iamId = config.iamId; iamIdMember = config.iamIdMember; iamApikey = config.apikey; + enterpriseAccountId = config.enterpriseAccountId; + enterpriseSubAccountId = config.enterpriseSubaccountId expect(accountId).not.toBeNull(); expect(accountId).toBeDefined(); + expect(enterpriseAccountId).not.toBeNull(); + expect(enterpriseAccountId).toBeDefined(); + expect(enterpriseSubAccountId).not.toBeNull(); + expect(enterpriseSubAccountId).toBeDefined(); expect(iamId).not.toBeNull(); expect(iamId).toBeDefined(); expect(iamIdMember).not.toBeNull(); @@ -1492,7 +1518,7 @@ describe('IamIdentityV1_integration', () => { expect(response.report_end_time).not.toBeNull(); break; } - await sleep(1); + await sleep(1000); } }); test('getReportNotFound()', async () => { @@ -1543,7 +1569,7 @@ describe('IamIdentityV1_integration', () => { expect(response.report_duration).not.toBeNull(); break; } - await sleep(1); + await sleep(1000); } }); test('getMfaReportNotFound()', async () => { @@ -1565,6 +1591,527 @@ describe('IamIdentityV1_integration', () => { expect(response).not.toBeNull(); expect(response.iam_id).not.toBeNull(); }); + + test('scenarioProfileTemplate()', async () => { + await createProfileTemplate(); + expect(profileTemplateScenarioComplete).toBe(true); + }); + + async function createProfileTemplate() { + const condition = { + claim: "blueGroups", + operator: "EQUALS", + value: "\"cloud-docs-dev\"", + } + const claimRule = { + name: "My Rule", + realm_name: realmName, + type: claimRuleType, + expiration: 43200, + conditions: [condition], + } + const profile = { + rules: [claimRule], + name: profileTemplateProfileName, + description: "node SDK test Profile created from Profile Template #1", + } + const templateParams = { + name: profileTemplateName, + description: "node SDK test Profile Template ", + accountId: enterpriseAccountId, + profile, + } + + const res = await iamIdentityService.createProfileTemplate(templateParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(201); + expect(res.headers.etag).not.toBeNull(); + profileTemplateEtag = res.headers.etag; + expect(profileTemplateEtag).not.toBeNull(); + const { result } = res; + expect(result).not.toBeNull(); + profileTemplateId = result.id; + expect(profileTemplateId).not.toBeNull(); + profileTemplateVersion = result.version; + expect(profileTemplateVersion).not.toBeNull(); + + await getProfileTemplate(); + } + + async function getProfileTemplate() { + const params = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + const res = await iamIdentityService.getProfileTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + profileTemplateEtag = res.headers.etag; + expect(profileTemplateEtag).not.toBeNull(); + + await listProfileTemplates(); + } + + async function listProfileTemplates() { + const params = { + accountId: enterpriseAccountId, + } + const res = await iamIdentityService.listProfileTemplates(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + + await updateProfileTemplate(); + } + + async function updateProfileTemplate() { + const params = { + accountId: enterpriseAccountId, + templateId: profileTemplateId, + version: profileTemplateVersion, + ifMatch: profileTemplateEtag, + name: profileTemplateName, + description: "node SDK test Profile Template - updated", + } + const res = await iamIdentityService.updateProfileTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + profileTemplateEtag = res.headers.etag; + expect(profileTemplateEtag).not.toBeNull(); + const { result } = res; + expect(result).not.toBeNull(); + + await assignProfileTemplate(); + } + + async function assignProfileTemplate() { + const commitParams = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + const res = await iamIdentityService.commitProfileTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + const assignParams = { + templateId: profileTemplateId, + templateVersion: profileTemplateVersion, + targetType: "Account", + target: enterpriseSubAccountId, + } + + const assRes = await iamIdentityService.createTrustedProfileAssignment(assignParams); + expect(assRes).not.toBeNull(); + expect(assRes.status).toEqual(202); + const { result } = assRes; + profileTemplateAssignmentId = result.id; + expect(profileTemplateAssignmentId).not.toBeNull(); + expect(assRes.headers).not.toBeNull(); + profileTemplateAssignmentEtag= assRes.headers.etag; + expect(profileTemplateAssignmentEtag).not.toBeNull(); + + await listProfileTemplateAssignments(); + } + + async function listProfileTemplateAssignments() { + const params = { + accountId: enterpriseAccountId, + templateId: profileTemplateId, + } + const res = await iamIdentityService.listTrustedProfileAssignments(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + expect(result.assignments).not.toBeNull(); + + await createNewProfileTemplateVersion(); + } + + async function createNewProfileTemplateVersion() { + const condition = { + claim: "blueGroups", + operator: "EQUALS", + value: "\"cloud-docs-dev\"", + } + const claimRule = { + name: "My Rule", + realm_name: realmName, + type: claimRuleType, + expiration: 43200, + conditions: [condition], + } + const identity = { + identifier: iamId, + accounts: [enterpriseAccountId], + type: "user", + description: "Identity description", + } + const profile = { + rules: [claimRule], + name: profileTemplateProfileName, + description: "node SDK test Profile created from Profile Template - new version", + identities: [identity], + } + const templateParams = { + templateId: profileTemplateId, + name: profileTemplateName, + description: "node SDK test Profile Template - new version", + accountId: enterpriseAccountId, + profile, + } + + const res = await iamIdentityService.createProfileTemplateVersion(templateParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(201); + const { result } = res; + expect(result).not.toBeNull(); + profileTemplateVersion = result.version; + expect(profileTemplateVersion).not.toBeNull(); + + await getLatestProfileTemplateVersion(); + } + + async function getLatestProfileTemplateVersion() { + const params = { + templateId: profileTemplateId, + } + const res = await iamIdentityService.getLatestProfileTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + + await listProfileTemplateVersions(); + } + + async function listProfileTemplateVersions() { + const params = { + templateId: profileTemplateId, + } + const res = await iamIdentityService.listVersionsOfProfileTemplate(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + expect(result.profile_templates).not.toBeNull(); + + await updateProfileTemplateAssignment(); + } + + async function updateProfileTemplateAssignment() { + const commitParams = { + templateId: profileTemplateId, + version: profileTemplateVersion, + } + + const res = await iamIdentityService.commitProfileTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await waitUntilTrustedProfileAssignmentFinished(profileTemplateAssignmentId); + + const assignParams = { + assignmentId: profileTemplateAssignmentId, + templateVersion: profileTemplateVersion, + ifMatch: profileTemplateAssignmentEtag, + } + + const assRes = await iamIdentityService.updateTrustedProfileAssignment(assignParams); + expect(assRes).not.toBeNull(); + expect(assRes.status).toEqual(202); + + await deleteProfileTemplateAssignment(); + } + + async function deleteProfileTemplateAssignment() { + + await waitUntilTrustedProfileAssignmentFinished(profileTemplateAssignmentId); + + const params = { + assignmentId: profileTemplateAssignmentId, + } + const res = await iamIdentityService.deleteTrustedProfileAssignment(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(202); + + await deleteProfileTemplateVersion(); + } + + async function deleteProfileTemplateVersion() { + + const params = { + templateId: profileTemplateId, + version: 1, + } + const res = await iamIdentityService.deleteProfileTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await testDeleteProfileTemplate(); + } + + async function testDeleteProfileTemplate() { + + await waitUntilTrustedProfileAssignmentFinished(profileTemplateAssignmentId); + + const params = { + templateId: profileTemplateId, + } + const res = await iamIdentityService.deleteAllVersionsOfProfileTemplate(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + profileTemplateScenarioComplete = true; + } + + test('scenarioAccountSettingsTemplate()', async () => { + await createAccountSettingsTemplate(); + expect(accountSettingsTemplateScenarioComplete).toBe(true); + }); + + async function createAccountSettingsTemplate() { + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "3000", + } + const templateParams = { + name: accountSettingsTemplateName, + description: "node SDK test Account Settings Template", + accountId: enterpriseAccountId, + accountSettings: settings, + } + + const res = await iamIdentityService.createAccountSettingsTemplate(templateParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(201); + expect(res.headers.etag).not.toBeNull(); + accountSettingsTemplateEtag = res.headers.etag; + expect(accountSettingsTemplateEtag).not.toBeNull(); + const { result } = res; + expect(result).not.toBeNull(); + accountSettingsTemplateId = result.id; + expect(accountSettingsTemplateId).not.toBeNull(); + accountSettingsTemplateVersion = result.version; + expect(accountSettingsTemplateVersion).not.toBeNull(); + + await getAccountSettingsTemplate(); + } + + async function getAccountSettingsTemplate() { + const params = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + const res = await iamIdentityService.getAccountSettingsTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + accountSettingsTemplateEtag = res.headers.etag; + expect(accountSettingsTemplateEtag).not.toBeNull(); + + await listAccountSettingsTemplates(); + } + + async function listAccountSettingsTemplates() { + const params = { + accountId: enterpriseAccountId, + } + const res = await iamIdentityService.listAccountSettingsTemplates(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + + await updateAccountSettingsTemplate(); + } + + async function updateAccountSettingsTemplate() { + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "3000", + } + const params = { + accountId: enterpriseAccountId, + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + ifMatch: accountSettingsTemplateEtag, + name: accountSettingsTemplateName, + description: "node SDK test Account Settings Template - updated", + accountSettings: settings, + } + const res = await iamIdentityService.updateAccountSettingsTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + accountSettingsTemplateEtag = res.headers.etag; + expect(accountSettingsTemplateEtag).not.toBeNull(); + const { result } = res; + expect(result).not.toBeNull(); + + await assignAccountSettingsTemplate(); + } + + async function assignAccountSettingsTemplate() { + const commitParams = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + const res = await iamIdentityService.commitAccountSettingsTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + const assignParams = { + templateId: accountSettingsTemplateId, + templateVersion: accountSettingsTemplateVersion, + targetType: "Account", + target: enterpriseSubAccountId, + } + + const assRes = await iamIdentityService.createAccountSettingsAssignment(assignParams); + expect(assRes).not.toBeNull(); + expect(assRes.status).toEqual(202); + const { result } = assRes; + accountSettingsTemplateAssignmentId = result.id; + expect(accountSettingsTemplateAssignmentId).not.toBeNull(); + expect(assRes.headers).not.toBeNull(); + accountSettingsTemplateAssignmentEtag= assRes.headers.etag; + expect(accountSettingsTemplateAssignmentEtag).not.toBeNull(); + + await listAccountSettingsTemplateAssignments(); + } + + async function listAccountSettingsTemplateAssignments() { + const params = { + accountId: enterpriseAccountId, + templateId: accountSettingsTemplateId, + } + const res = await iamIdentityService.listAccountSettingsAssignments(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + expect(result.assignments).not.toBeNull(); + + await createNewAccountSettingsTemplateVersion(); + } + + async function createNewAccountSettingsTemplateVersion() { + const settings = { + mfa: "LEVEL1", + system_access_token_expiration_in_seconds: "2600", + restrict_create_platform_apikey: "RESTRICTED", + restrict_create_service_id: "RESTRICTED", + } + const templateParams = { + templateId: accountSettingsTemplateId, + name: accountSettingsTemplateName, + description: "node SDK test Account Settings Template - new version", + accountId: enterpriseAccountId, + accountSettings: settings, + } + + const res = await iamIdentityService.createAccountSettingsTemplateVersion(templateParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(201); + const { result } = res; + expect(result).not.toBeNull(); + accountSettingsTemplateVersion = result.version; + expect(accountSettingsTemplateVersion).not.toBeNull(); + + await getLatestAccountSettingsTemplateVersion(); + } + + async function getLatestAccountSettingsTemplateVersion() { + const params = { + templateId: accountSettingsTemplateId, + } + const res = await iamIdentityService.getLatestAccountSettingsTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + + await listAccountSettingsTemplateVersions(); + } + + async function listAccountSettingsTemplateVersions() { + const params = { + templateId: accountSettingsTemplateId, + } + const res = await iamIdentityService.listVersionsOfAccountSettingsTemplate(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(200); + const { result } = res; + expect(result).not.toBeNull(); + expect(result.profile_templates).not.toBeNull(); + + await updateAccountSettingsTemplateAssignment(); + } + + async function updateAccountSettingsTemplateAssignment() { + const commitParams = { + templateId: accountSettingsTemplateId, + version: accountSettingsTemplateVersion, + } + + const res = await iamIdentityService.commitAccountSettingsTemplate(commitParams); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await waitUntilAccountSettingsAssignmentFinished(accountSettingsTemplateAssignmentId); + + const assignParams = { + assignmentId: accountSettingsTemplateAssignmentId, + templateVersion: accountSettingsTemplateVersion, + ifMatch: accountSettingsTemplateAssignmentEtag, + } + + const assRes = await iamIdentityService.updateAccountSettingsAssignment(assignParams); + expect(assRes).not.toBeNull(); + expect(assRes.status).toEqual(202); + + await deleteAccountSettingsTemplateAssignment(); + } + + async function deleteAccountSettingsTemplateAssignment() { + + await waitUntilAccountSettingsAssignmentFinished(accountSettingsTemplateAssignmentId); + + const params = { + assignmentId: accountSettingsTemplateAssignmentId, + } + const res = await iamIdentityService.deleteAccountSettingsAssignment(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(202); + + await deleteAccountSettingsTemplateVersion(); + } + + async function deleteAccountSettingsTemplateVersion() { + + const params = { + templateId: accountSettingsTemplateId, + version: 1, + } + const res = await iamIdentityService.deleteAccountSettingsTemplateVersion(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + await testDeleteAccountSettingsTemplate(); + } + + async function testDeleteAccountSettingsTemplate() { + + await waitUntilAccountSettingsAssignmentFinished(accountSettingsTemplateAssignmentId); + + const params = { + templateId: accountSettingsTemplateId, + } + const res = await iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(params); + expect(res).not.toBeNull(); + expect(res.status).toEqual(204); + + accountSettingsTemplateScenarioComplete = true; + } + function getPageTokenFromURL(urlstring) { let pageToken = null; if (urlstring) { @@ -1576,6 +2123,64 @@ describe('IamIdentityV1_integration', () => { return pageToken; } + function isFinished(status) { + return (status.toLowerCase() === "succeeded" || status.toLowerCase() === "failed"); + } + + async function waitUntilTrustedProfileAssignmentFinished(assignmentId) { + let finished = false; + const params = { + assignmentId, + } + + for (let i = 0; i < 60; i++) { + try { + const response = await iamIdentityService.getTrustedProfileAssignment(params); + const { result } = response; + finished = isFinished(result.status); + if (finished) { + profileTemplateAssignmentEtag= response.headers.etag; + finished = true; + break; + } + await sleep(10000); + } catch (e) { + if (e.status === 404) { + finished = true; + break; + } + } + } + expect(finished).toBe(true); + } + + async function waitUntilAccountSettingsAssignmentFinished(assignmentId) { + let finished = false; + const params = { + assignmentId, + } + + for (let i = 0; i < 60; i++) { + try { + const response = await iamIdentityService.getAccountSettingsAssignment(params); + const { result } = response; + finished = isFinished(result.status); + if (finished) { + accountSettingsTemplateAssignmentEtag= response.headers.etag; + finished = true; + break; + } + await sleep(10000); + } catch (e) { + if (e.status === 404) { + finished = true; + break; + } + } + } + expect(finished).toBe(true); + } + async function getApiKeyById(apikeyId) { let result = null; try { @@ -1728,6 +2333,91 @@ describe('IamIdentityV1_integration', () => { expect(response.status).toEqual(204); } } + + // list profile templates + const profileTemplateParams = { + accountId: enterpriseAccountId, + }; + const profileTemplatesResponse = await iamIdentityService.listProfileTemplates(profileTemplateParams); + + const profilesTemplatesResult = profileTemplatesResponse.result; + if (profilesTemplatesResult.profile_templates) { + for (const elem of profilesTemplatesResult.profile_templates) { + if (elem.name === profileTemplateName) { + console.log('Cleaning profile template: ', elem.id); + // list profile template assignments + const assignmentParams = { + accountId: enterpriseAccountId, + templateId: elem.id, + } + const assResponse = await iamIdentityService.listTrustedProfileAssignments(assignmentParams); + expect(assResponse).not.toBeNull(); + expect(assResponse.status).toEqual(200); + const assignmentsResult = assResponse.result; + for (const assElem of assignmentsResult.assignments) { + if (!isFinished(assElem.status)) { + await waitUntilTrustedProfileAssignmentFinished(assElem.id); + } + const delAssParams = { + assignmentId: assElem.id, + } + const assDelResponse = await iamIdentityService.deleteTrustedProfileAssignment(delAssParams); + expect(assDelResponse).not.toBeNull(); + expect(assDelResponse.status).toEqual(202); + await waitUntilTrustedProfileAssignmentFinished(assElem.id); + } + const deleteParams = { + templateId: elem.id, + }; + const response = await iamIdentityService.deleteAllVersionsOfProfileTemplate(deleteParams); + expect(response).not.toBeNull(); + expect(response.status).toEqual(204); + } + } + } + + // list account settings templates + const accountSettingsTemplateParams = { + accountId: enterpriseAccountId, + }; + const accountSettingsTemplatesResponse = await iamIdentityService.listAccountSettingsTemplates(accountSettingsTemplateParams); + + const accountSettingsTemplatesResult = accountSettingsTemplatesResponse.result; + if (accountSettingsTemplatesResult.account_settings_templates) { + for (const elem of accountSettingsTemplatesResult.account_settings_templates) { + if (elem.name === accountSettingsTemplateName) { + console.log('Cleaning account settings template: ', elem.id); + // list account settings template assignments + const assignmentParams = { + accountId: enterpriseAccountId, + templateId: elem.id, + } + const assResponse = await iamIdentityService.listAccountSettingsAssignments(assignmentParams); + expect(assResponse).not.toBeNull(); + expect(assResponse.status).toEqual(200); + const assignmentsResult = assResponse.result; + for (const assElem of assignmentsResult.assignments) { + if (!isFinished(assElem.status)) { + await waitUntilAccountSettingsAssignmentFinished(assElem.id); + } + const delAssParams = { + assignmentId: assElem.id, + } + const assDelResponse = await iamIdentityService.deleteAccountSettingsAssignment(delAssParams); + expect(assDelResponse).not.toBeNull(); + expect(assDelResponse.status).toEqual(202); + await waitUntilAccountSettingsAssignmentFinished(assElem.id); + } + const deleteParams = { + templateId: elem.id, + }; + const response = await iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(deleteParams); + expect(response).not.toBeNull(); + expect(response.status).toEqual(204); + } + } + } + console.log('Finished cleaning resources!'); } catch (err) { console.log(err); diff --git a/test/unit/iam-identity.v1.test.js b/test/unit/iam-identity.v1.test.js index cd5f961e..b70ba6ee 100644 --- a/test/unit/iam-identity.v1.test.js +++ b/test/unit/iam-identity.v1.test.js @@ -32,7 +32,7 @@ const { const iamIdentityServiceOptions = { authenticator: new NoAuthAuthenticator(), - url: 'https://iam.test.cloud.ibm.com', + url: 'https://iam.cloud.ibm.com', }; const iamIdentityService = new IamIdentityV1(iamIdentityServiceOptions); @@ -2896,9 +2896,8 @@ describe('IamIdentityV1', () => { describe('positive tests', () => { // Request models needed by this operation. - // ProfileIdentity - const profileIdentityModel = { - iam_id: 'testString', + // ProfileIdentityRequest + const profileIdentityRequestModel = { identifier: 'testString', type: 'user', accounts: ['testString'], @@ -2909,7 +2908,7 @@ describe('IamIdentityV1', () => { // Construct the params object for operation setProfileIdentities const profileId = 'testString'; const ifMatch = 'testString'; - const identities = [profileIdentityModel]; + const identities = [profileIdentityRequestModel]; const setProfileIdentitiesParams = { profileId, ifMatch, @@ -3003,7 +3002,6 @@ describe('IamIdentityV1', () => { const identityType = 'user'; const identifier = 'testString'; const type = 'user'; - const iamId = 'testString'; const accounts = ['testString']; const description = 'testString'; const setProfileIdentityParams = { @@ -3011,7 +3009,6 @@ describe('IamIdentityV1', () => { identityType, identifier, type, - iamId, accounts, description, }; @@ -3032,7 +3029,6 @@ describe('IamIdentityV1', () => { checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); expect(mockRequestOptions.body.identifier).toEqual(identifier); expect(mockRequestOptions.body.type).toEqual(type); - expect(mockRequestOptions.body.iam_id).toEqual(iamId); expect(mockRequestOptions.body.accounts).toEqual(accounts); expect(mockRequestOptions.body.description).toEqual(description); expect(mockRequestOptions.path['profile-id']).toEqual(profileId); @@ -3770,67 +3766,167 @@ describe('IamIdentityV1', () => { }); }); - describe('createReport', () => { + describe('listAccountSettingsAssignments', () => { describe('positive tests', () => { - function __createReportTest() { - // Construct the params object for operation createReport + function __listAccountSettingsAssignmentsTest() { + // Construct the params object for operation listAccountSettingsAssignments const accountId = 'testString'; - const type = 'inactive'; - const duration = '720'; - const createReportParams = { + const templateId = 'testString'; + const templateVersion = 'testString'; + const target = 'testString'; + const targetType = 'Account'; + const limit = 20; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = false; + const listAccountSettingsAssignmentsParams = { accountId, - type, - duration, + templateId, + templateVersion, + target, + targetType, + limit, + pagetoken, + sort, + order, + includeHistory, }; - const createReportResult = iamIdentityService.createReport(createReportParams); + const listAccountSettingsAssignmentsResult = iamIdentityService.listAccountSettingsAssignments(listAccountSettingsAssignmentsParams); // all methods should return a Promise - expectToBePromise(createReportResult); + expectToBePromise(listAccountSettingsAssignmentsResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/v1/activity/accounts/{account_id}/report', 'POST'); + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_assignments/', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.qs.type).toEqual(type); - expect(mockRequestOptions.qs.duration).toEqual(duration); - expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.template_id).toEqual(templateId); + expect(mockRequestOptions.qs.template_version).toEqual(templateVersion); + expect(mockRequestOptions.qs.target).toEqual(target); + expect(mockRequestOptions.qs.target_type).toEqual(targetType); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __createReportTest(); + __listAccountSettingsAssignmentsTest(); // enable retries and test again createRequestMock.mockClear(); iamIdentityService.enableRetries(); - __createReportTest(); + __listAccountSettingsAssignmentsTest(); // disable retries and test again createRequestMock.mockClear(); iamIdentityService.disableRetries(); - __createReportTest(); + __listAccountSettingsAssignmentsTest(); }); test('should prioritize user-given headers', () => { // parameters - const accountId = 'testString'; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const createReportParams = { - accountId, + const listAccountSettingsAssignmentsParams = { headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - iamIdentityService.createReport(createReportParams); + iamIdentityService.listAccountSettingsAssignments(listAccountSettingsAssignmentsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.listAccountSettingsAssignments({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('createAccountSettingsAssignment', () => { + describe('positive tests', () => { + function __createAccountSettingsAssignmentTest() { + // Construct the params object for operation createAccountSettingsAssignment + const templateId = 'testString'; + const templateVersion = 1; + const targetType = 'Account'; + const target = 'testString'; + const createAccountSettingsAssignmentParams = { + templateId, + templateVersion, + targetType, + target, + }; + + const createAccountSettingsAssignmentResult = iamIdentityService.createAccountSettingsAssignment(createAccountSettingsAssignmentParams); + + // all methods should return a Promise + expectToBePromise(createAccountSettingsAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_assignments/', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.template_id).toEqual(templateId); + expect(mockRequestOptions.body.template_version).toEqual(templateVersion); + expect(mockRequestOptions.body.target_type).toEqual(targetType); + expect(mockRequestOptions.body.target).toEqual(target); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createAccountSettingsAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createAccountSettingsAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createAccountSettingsAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const templateVersion = 1; + const targetType = 'Account'; + const target = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createAccountSettingsAssignmentParams = { + templateId, + templateVersion, + targetType, + target, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createAccountSettingsAssignment(createAccountSettingsAssignmentParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); }); @@ -3839,7 +3935,7 @@ describe('IamIdentityV1', () => { test('should enforce required parameters', async () => { let err; try { - await iamIdentityService.createReport({}); + await iamIdentityService.createAccountSettingsAssignment({}); } catch (e) { err = e; } @@ -3850,7 +3946,7 @@ describe('IamIdentityV1', () => { test('should reject promise when required params are not given', async () => { let err; try { - await iamIdentityService.createReport(); + await iamIdentityService.createAccountSettingsAssignment(); } catch (e) { err = e; } @@ -3860,66 +3956,64 @@ describe('IamIdentityV1', () => { }); }); - describe('getReport', () => { + describe('getAccountSettingsAssignment', () => { describe('positive tests', () => { - function __getReportTest() { - // Construct the params object for operation getReport - const accountId = 'testString'; - const reference = 'testString'; - const getReportParams = { - accountId, - reference, + function __getAccountSettingsAssignmentTest() { + // Construct the params object for operation getAccountSettingsAssignment + const assignmentId = 'testString'; + const includeHistory = false; + const getAccountSettingsAssignmentParams = { + assignmentId, + includeHistory, }; - const getReportResult = iamIdentityService.getReport(getReportParams); + const getAccountSettingsAssignmentResult = iamIdentityService.getAccountSettingsAssignment(getAccountSettingsAssignmentParams); // all methods should return a Promise - expectToBePromise(getReportResult); + expectToBePromise(getAccountSettingsAssignmentResult); // assert that create request was called expect(createRequestMock).toHaveBeenCalledTimes(1); const mockRequestOptions = getOptions(createRequestMock); - checkUrlAndMethod(mockRequestOptions, '/v1/activity/accounts/{account_id}/report/{reference}', 'GET'); + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_assignments/{assignment_id}', 'GET'); const expectedAccept = 'application/json'; const expectedContentType = undefined; checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); - expect(mockRequestOptions.path.account_id).toEqual(accountId); - expect(mockRequestOptions.path.reference).toEqual(reference); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); } test('should pass the right params to createRequest with enable and disable retries', () => { // baseline test - __getReportTest(); + __getAccountSettingsAssignmentTest(); // enable retries and test again createRequestMock.mockClear(); iamIdentityService.enableRetries(); - __getReportTest(); + __getAccountSettingsAssignmentTest(); // disable retries and test again createRequestMock.mockClear(); iamIdentityService.disableRetries(); - __getReportTest(); + __getAccountSettingsAssignmentTest(); }); test('should prioritize user-given headers', () => { // parameters - const accountId = 'testString'; - const reference = 'testString'; + const assignmentId = 'testString'; const userAccept = 'fake/accept'; const userContentType = 'fake/contentType'; - const getReportParams = { - accountId, - reference, + const getAccountSettingsAssignmentParams = { + assignmentId, headers: { Accept: userAccept, 'Content-Type': userContentType, }, }; - iamIdentityService.getReport(getReportParams); + iamIdentityService.getAccountSettingsAssignment(getAccountSettingsAssignmentParams); checkMediaHeaders(createRequestMock, userAccept, userContentType); }); }); @@ -3928,7 +4022,7 @@ describe('IamIdentityV1', () => { test('should enforce required parameters', async () => { let err; try { - await iamIdentityService.getReport({}); + await iamIdentityService.getAccountSettingsAssignment({}); } catch (e) { err = e; } @@ -3939,7 +4033,2802 @@ describe('IamIdentityV1', () => { test('should reject promise when required params are not given', async () => { let err; try { - await iamIdentityService.getReport(); + await iamIdentityService.getAccountSettingsAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteAccountSettingsAssignment', () => { + describe('positive tests', () => { + function __deleteAccountSettingsAssignmentTest() { + // Construct the params object for operation deleteAccountSettingsAssignment + const assignmentId = 'testString'; + const deleteAccountSettingsAssignmentParams = { + assignmentId, + }; + + const deleteAccountSettingsAssignmentResult = iamIdentityService.deleteAccountSettingsAssignment(deleteAccountSettingsAssignmentParams); + + // all methods should return a Promise + expectToBePromise(deleteAccountSettingsAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_assignments/{assignment_id}', 'DELETE'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteAccountSettingsAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteAccountSettingsAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteAccountSettingsAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const assignmentId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteAccountSettingsAssignmentParams = { + assignmentId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteAccountSettingsAssignment(deleteAccountSettingsAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteAccountSettingsAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteAccountSettingsAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateAccountSettingsAssignment', () => { + describe('positive tests', () => { + function __updateAccountSettingsAssignmentTest() { + // Construct the params object for operation updateAccountSettingsAssignment + const assignmentId = 'testString'; + const ifMatch = 'testString'; + const templateVersion = 1; + const updateAccountSettingsAssignmentParams = { + assignmentId, + ifMatch, + templateVersion, + }; + + const updateAccountSettingsAssignmentResult = iamIdentityService.updateAccountSettingsAssignment(updateAccountSettingsAssignmentParams); + + // all methods should return a Promise + expectToBePromise(updateAccountSettingsAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_assignments/{assignment_id}', 'PATCH'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body.template_version).toEqual(templateVersion); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateAccountSettingsAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateAccountSettingsAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateAccountSettingsAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const assignmentId = 'testString'; + const ifMatch = 'testString'; + const templateVersion = 1; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateAccountSettingsAssignmentParams = { + assignmentId, + ifMatch, + templateVersion, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateAccountSettingsAssignment(updateAccountSettingsAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateAccountSettingsAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateAccountSettingsAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listAccountSettingsTemplates', () => { + describe('positive tests', () => { + function __listAccountSettingsTemplatesTest() { + // Construct the params object for operation listAccountSettingsTemplates + const accountId = 'testString'; + const limit = '20'; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = 'false'; + const listAccountSettingsTemplatesParams = { + accountId, + limit, + pagetoken, + sort, + order, + includeHistory, + }; + + const listAccountSettingsTemplatesResult = iamIdentityService.listAccountSettingsTemplates(listAccountSettingsTemplatesParams); + + // all methods should return a Promise + expectToBePromise(listAccountSettingsTemplatesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listAccountSettingsTemplatesTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listAccountSettingsTemplatesTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listAccountSettingsTemplatesTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listAccountSettingsTemplatesParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listAccountSettingsTemplates(listAccountSettingsTemplatesParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.listAccountSettingsTemplates({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('createAccountSettingsTemplate', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // AccountSettingsUserMFA + const accountSettingsUserMfaModel = { + iam_id: 'testString', + mfa: 'NONE', + }; + + // AccountSettingsComponent + const accountSettingsComponentModel = { + restrict_create_service_id: 'NOT_SET', + restrict_create_platform_apikey: 'NOT_SET', + allowed_ip_addresses: 'testString', + mfa: 'NONE', + user_mfa: [accountSettingsUserMfaModel], + session_expiration_in_seconds: '86400', + session_invalidation_in_seconds: '7200', + max_sessions_per_identity: 'testString', + system_access_token_expiration_in_seconds: '3600', + system_refresh_token_expiration_in_seconds: '259200', + }; + + function __createAccountSettingsTemplateTest() { + // Construct the params object for operation createAccountSettingsTemplate + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const accountSettings = accountSettingsComponentModel; + const createAccountSettingsTemplateParams = { + accountId, + name, + description, + accountSettings, + }; + + const createAccountSettingsTemplateResult = iamIdentityService.createAccountSettingsTemplate(createAccountSettingsTemplateParams); + + // all methods should return a Promise + expectToBePromise(createAccountSettingsTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.account_settings).toEqual(accountSettings); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createAccountSettingsTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createAccountSettingsTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createAccountSettingsTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createAccountSettingsTemplateParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createAccountSettingsTemplate(createAccountSettingsTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.createAccountSettingsTemplate({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('getLatestAccountSettingsTemplateVersion', () => { + describe('positive tests', () => { + function __getLatestAccountSettingsTemplateVersionTest() { + // Construct the params object for operation getLatestAccountSettingsTemplateVersion + const templateId = 'testString'; + const includeHistory = false; + const getLatestAccountSettingsTemplateVersionParams = { + templateId, + includeHistory, + }; + + const getLatestAccountSettingsTemplateVersionResult = iamIdentityService.getLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(getLatestAccountSettingsTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getLatestAccountSettingsTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getLatestAccountSettingsTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getLatestAccountSettingsTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getLatestAccountSettingsTemplateVersionParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getLatestAccountSettingsTemplateVersion(getLatestAccountSettingsTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getLatestAccountSettingsTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getLatestAccountSettingsTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteAllVersionsOfAccountSettingsTemplate', () => { + describe('positive tests', () => { + function __deleteAllVersionsOfAccountSettingsTemplateTest() { + // Construct the params object for operation deleteAllVersionsOfAccountSettingsTemplate + const templateId = 'testString'; + const deleteAllVersionsOfAccountSettingsTemplateParams = { + templateId, + }; + + const deleteAllVersionsOfAccountSettingsTemplateResult = iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateParams); + + // all methods should return a Promise + expectToBePromise(deleteAllVersionsOfAccountSettingsTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteAllVersionsOfAccountSettingsTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteAllVersionsOfAccountSettingsTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteAllVersionsOfAccountSettingsTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteAllVersionsOfAccountSettingsTemplateParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(deleteAllVersionsOfAccountSettingsTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteAllVersionsOfAccountSettingsTemplate(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listVersionsOfAccountSettingsTemplate', () => { + describe('positive tests', () => { + function __listVersionsOfAccountSettingsTemplateTest() { + // Construct the params object for operation listVersionsOfAccountSettingsTemplate + const templateId = 'testString'; + const limit = '20'; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = 'false'; + const listVersionsOfAccountSettingsTemplateParams = { + templateId, + limit, + pagetoken, + sort, + order, + includeHistory, + }; + + const listVersionsOfAccountSettingsTemplateResult = iamIdentityService.listVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateParams); + + // all methods should return a Promise + expectToBePromise(listVersionsOfAccountSettingsTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listVersionsOfAccountSettingsTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listVersionsOfAccountSettingsTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listVersionsOfAccountSettingsTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listVersionsOfAccountSettingsTemplateParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listVersionsOfAccountSettingsTemplate(listVersionsOfAccountSettingsTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.listVersionsOfAccountSettingsTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.listVersionsOfAccountSettingsTemplate(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('createAccountSettingsTemplateVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // AccountSettingsUserMFA + const accountSettingsUserMfaModel = { + iam_id: 'testString', + mfa: 'NONE', + }; + + // AccountSettingsComponent + const accountSettingsComponentModel = { + restrict_create_service_id: 'NOT_SET', + restrict_create_platform_apikey: 'NOT_SET', + allowed_ip_addresses: 'testString', + mfa: 'NONE', + user_mfa: [accountSettingsUserMfaModel], + session_expiration_in_seconds: '86400', + session_invalidation_in_seconds: '7200', + max_sessions_per_identity: 'testString', + system_access_token_expiration_in_seconds: '3600', + system_refresh_token_expiration_in_seconds: '259200', + }; + + function __createAccountSettingsTemplateVersionTest() { + // Construct the params object for operation createAccountSettingsTemplateVersion + const templateId = 'testString'; + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const accountSettings = accountSettingsComponentModel; + const createAccountSettingsTemplateVersionParams = { + templateId, + accountId, + name, + description, + accountSettings, + }; + + const createAccountSettingsTemplateVersionResult = iamIdentityService.createAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(createAccountSettingsTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.account_settings).toEqual(accountSettings); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createAccountSettingsTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createAccountSettingsTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createAccountSettingsTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createAccountSettingsTemplateVersionParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createAccountSettingsTemplateVersion(createAccountSettingsTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.createAccountSettingsTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.createAccountSettingsTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getAccountSettingsTemplateVersion', () => { + describe('positive tests', () => { + function __getAccountSettingsTemplateVersionTest() { + // Construct the params object for operation getAccountSettingsTemplateVersion + const templateId = 'testString'; + const version = 'testString'; + const includeHistory = false; + const getAccountSettingsTemplateVersionParams = { + templateId, + version, + includeHistory, + }; + + const getAccountSettingsTemplateVersionResult = iamIdentityService.getAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(getAccountSettingsTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions/{version}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getAccountSettingsTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getAccountSettingsTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getAccountSettingsTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getAccountSettingsTemplateVersionParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getAccountSettingsTemplateVersion(getAccountSettingsTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getAccountSettingsTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getAccountSettingsTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateAccountSettingsTemplateVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // AccountSettingsUserMFA + const accountSettingsUserMfaModel = { + iam_id: 'testString', + mfa: 'NONE', + }; + + // AccountSettingsComponent + const accountSettingsComponentModel = { + restrict_create_service_id: 'NOT_SET', + restrict_create_platform_apikey: 'NOT_SET', + allowed_ip_addresses: 'testString', + mfa: 'NONE', + user_mfa: [accountSettingsUserMfaModel], + session_expiration_in_seconds: '86400', + session_invalidation_in_seconds: '7200', + max_sessions_per_identity: 'testString', + system_access_token_expiration_in_seconds: '3600', + system_refresh_token_expiration_in_seconds: '259200', + }; + + function __updateAccountSettingsTemplateVersionTest() { + // Construct the params object for operation updateAccountSettingsTemplateVersion + const ifMatch = 'testString'; + const templateId = 'testString'; + const version = 'testString'; + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const accountSettings = accountSettingsComponentModel; + const updateAccountSettingsTemplateVersionParams = { + ifMatch, + templateId, + version, + accountId, + name, + description, + accountSettings, + }; + + const updateAccountSettingsTemplateVersionResult = iamIdentityService.updateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(updateAccountSettingsTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions/{version}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.account_settings).toEqual(accountSettings); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateAccountSettingsTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateAccountSettingsTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateAccountSettingsTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const ifMatch = 'testString'; + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateAccountSettingsTemplateVersionParams = { + ifMatch, + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateAccountSettingsTemplateVersion(updateAccountSettingsTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateAccountSettingsTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateAccountSettingsTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteAccountSettingsTemplateVersion', () => { + describe('positive tests', () => { + function __deleteAccountSettingsTemplateVersionTest() { + // Construct the params object for operation deleteAccountSettingsTemplateVersion + const templateId = 'testString'; + const version = 'testString'; + const deleteAccountSettingsTemplateVersionParams = { + templateId, + version, + }; + + const deleteAccountSettingsTemplateVersionResult = iamIdentityService.deleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(deleteAccountSettingsTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions/{version}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteAccountSettingsTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteAccountSettingsTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteAccountSettingsTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteAccountSettingsTemplateVersionParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteAccountSettingsTemplateVersion(deleteAccountSettingsTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteAccountSettingsTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteAccountSettingsTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('commitAccountSettingsTemplate', () => { + describe('positive tests', () => { + function __commitAccountSettingsTemplateTest() { + // Construct the params object for operation commitAccountSettingsTemplate + const templateId = 'testString'; + const version = 'testString'; + const commitAccountSettingsTemplateParams = { + templateId, + version, + }; + + const commitAccountSettingsTemplateResult = iamIdentityService.commitAccountSettingsTemplate(commitAccountSettingsTemplateParams); + + // all methods should return a Promise + expectToBePromise(commitAccountSettingsTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/account_settings_templates/{template_id}/versions/{version}/commit', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __commitAccountSettingsTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __commitAccountSettingsTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __commitAccountSettingsTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const commitAccountSettingsTemplateParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.commitAccountSettingsTemplate(commitAccountSettingsTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.commitAccountSettingsTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.commitAccountSettingsTemplate(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('createReport', () => { + describe('positive tests', () => { + function __createReportTest() { + // Construct the params object for operation createReport + const accountId = 'testString'; + const type = 'inactive'; + const duration = '720'; + const createReportParams = { + accountId, + type, + duration, + }; + + const createReportResult = iamIdentityService.createReport(createReportParams); + + // all methods should return a Promise + expectToBePromise(createReportResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/activity/accounts/{account_id}/report', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.type).toEqual(type); + expect(mockRequestOptions.qs.duration).toEqual(duration); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createReportTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createReportTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createReportTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createReportParams = { + accountId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createReport(createReportParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.createReport({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.createReport(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getReport', () => { + describe('positive tests', () => { + function __getReportTest() { + // Construct the params object for operation getReport + const accountId = 'testString'; + const reference = 'testString'; + const getReportParams = { + accountId, + reference, + }; + + const getReportResult = iamIdentityService.getReport(getReportParams); + + // all methods should return a Promise + expectToBePromise(getReportResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/activity/accounts/{account_id}/report/{reference}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.account_id).toEqual(accountId); + expect(mockRequestOptions.path.reference).toEqual(reference); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getReportTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getReportTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getReportTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const accountId = 'testString'; + const reference = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getReportParams = { + accountId, + reference, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getReport(getReportParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getReport({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getReport(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listTrustedProfileAssignments', () => { + describe('positive tests', () => { + function __listTrustedProfileAssignmentsTest() { + // Construct the params object for operation listTrustedProfileAssignments + const accountId = 'testString'; + const templateId = 'testString'; + const templateVersion = 'testString'; + const target = 'testString'; + const targetType = 'Account'; + const limit = 20; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = false; + const listTrustedProfileAssignmentsParams = { + accountId, + templateId, + templateVersion, + target, + targetType, + limit, + pagetoken, + sort, + order, + includeHistory, + }; + + const listTrustedProfileAssignmentsResult = iamIdentityService.listTrustedProfileAssignments(listTrustedProfileAssignmentsParams); + + // all methods should return a Promise + expectToBePromise(listTrustedProfileAssignmentsResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_assignments/', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.template_id).toEqual(templateId); + expect(mockRequestOptions.qs.template_version).toEqual(templateVersion); + expect(mockRequestOptions.qs.target).toEqual(target); + expect(mockRequestOptions.qs.target_type).toEqual(targetType); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listTrustedProfileAssignmentsTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listTrustedProfileAssignmentsTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listTrustedProfileAssignmentsTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listTrustedProfileAssignmentsParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listTrustedProfileAssignments(listTrustedProfileAssignmentsParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.listTrustedProfileAssignments({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('createTrustedProfileAssignment', () => { + describe('positive tests', () => { + function __createTrustedProfileAssignmentTest() { + // Construct the params object for operation createTrustedProfileAssignment + const templateId = 'testString'; + const templateVersion = 1; + const targetType = 'Account'; + const target = 'testString'; + const createTrustedProfileAssignmentParams = { + templateId, + templateVersion, + targetType, + target, + }; + + const createTrustedProfileAssignmentResult = iamIdentityService.createTrustedProfileAssignment(createTrustedProfileAssignmentParams); + + // all methods should return a Promise + expectToBePromise(createTrustedProfileAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_assignments/', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.template_id).toEqual(templateId); + expect(mockRequestOptions.body.template_version).toEqual(templateVersion); + expect(mockRequestOptions.body.target_type).toEqual(targetType); + expect(mockRequestOptions.body.target).toEqual(target); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createTrustedProfileAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createTrustedProfileAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createTrustedProfileAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const templateVersion = 1; + const targetType = 'Account'; + const target = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createTrustedProfileAssignmentParams = { + templateId, + templateVersion, + targetType, + target, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createTrustedProfileAssignment(createTrustedProfileAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.createTrustedProfileAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.createTrustedProfileAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getTrustedProfileAssignment', () => { + describe('positive tests', () => { + function __getTrustedProfileAssignmentTest() { + // Construct the params object for operation getTrustedProfileAssignment + const assignmentId = 'testString'; + const includeHistory = false; + const getTrustedProfileAssignmentParams = { + assignmentId, + includeHistory, + }; + + const getTrustedProfileAssignmentResult = iamIdentityService.getTrustedProfileAssignment(getTrustedProfileAssignmentParams); + + // all methods should return a Promise + expectToBePromise(getTrustedProfileAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_assignments/{assignment_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getTrustedProfileAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getTrustedProfileAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getTrustedProfileAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const assignmentId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getTrustedProfileAssignmentParams = { + assignmentId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getTrustedProfileAssignment(getTrustedProfileAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getTrustedProfileAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getTrustedProfileAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteTrustedProfileAssignment', () => { + describe('positive tests', () => { + function __deleteTrustedProfileAssignmentTest() { + // Construct the params object for operation deleteTrustedProfileAssignment + const assignmentId = 'testString'; + const deleteTrustedProfileAssignmentParams = { + assignmentId, + }; + + const deleteTrustedProfileAssignmentResult = iamIdentityService.deleteTrustedProfileAssignment(deleteTrustedProfileAssignmentParams); + + // all methods should return a Promise + expectToBePromise(deleteTrustedProfileAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_assignments/{assignment_id}', 'DELETE'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteTrustedProfileAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteTrustedProfileAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteTrustedProfileAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const assignmentId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteTrustedProfileAssignmentParams = { + assignmentId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteTrustedProfileAssignment(deleteTrustedProfileAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteTrustedProfileAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteTrustedProfileAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateTrustedProfileAssignment', () => { + describe('positive tests', () => { + function __updateTrustedProfileAssignmentTest() { + // Construct the params object for operation updateTrustedProfileAssignment + const assignmentId = 'testString'; + const ifMatch = 'testString'; + const templateVersion = 1; + const updateTrustedProfileAssignmentParams = { + assignmentId, + ifMatch, + templateVersion, + }; + + const updateTrustedProfileAssignmentResult = iamIdentityService.updateTrustedProfileAssignment(updateTrustedProfileAssignmentParams); + + // all methods should return a Promise + expectToBePromise(updateTrustedProfileAssignmentResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_assignments/{assignment_id}', 'PATCH'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body.template_version).toEqual(templateVersion); + expect(mockRequestOptions.path.assignment_id).toEqual(assignmentId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateTrustedProfileAssignmentTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateTrustedProfileAssignmentTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateTrustedProfileAssignmentTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const assignmentId = 'testString'; + const ifMatch = 'testString'; + const templateVersion = 1; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateTrustedProfileAssignmentParams = { + assignmentId, + ifMatch, + templateVersion, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateTrustedProfileAssignment(updateTrustedProfileAssignmentParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateTrustedProfileAssignment({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateTrustedProfileAssignment(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listProfileTemplates', () => { + describe('positive tests', () => { + function __listProfileTemplatesTest() { + // Construct the params object for operation listProfileTemplates + const accountId = 'testString'; + const limit = '20'; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = 'false'; + const listProfileTemplatesParams = { + accountId, + limit, + pagetoken, + sort, + order, + includeHistory, + }; + + const listProfileTemplatesResult = iamIdentityService.listProfileTemplates(listProfileTemplatesParams); + + // all methods should return a Promise + expectToBePromise(listProfileTemplatesResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.account_id).toEqual(accountId); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listProfileTemplatesTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listProfileTemplatesTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listProfileTemplatesTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listProfileTemplatesParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listProfileTemplates(listProfileTemplatesParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.listProfileTemplates({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('createProfileTemplate', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // ProfileClaimRuleConditions + const profileClaimRuleConditionsModel = { + claim: 'testString', + operator: 'testString', + value: 'testString', + }; + + // TrustedProfileTemplateClaimRule + const trustedProfileTemplateClaimRuleModel = { + name: 'testString', + type: 'Profile-SAML', + realm_name: 'testString', + expiration: 38, + conditions: [profileClaimRuleConditionsModel], + }; + + // ProfileIdentityRequest + const profileIdentityRequestModel = { + identifier: 'testString', + type: 'user', + accounts: ['testString'], + description: 'testString', + }; + + // TemplateProfileComponentRequest + const templateProfileComponentRequestModel = { + name: 'testString', + description: 'testString', + rules: [trustedProfileTemplateClaimRuleModel], + identities: [profileIdentityRequestModel], + }; + + // PolicyTemplateReference + const policyTemplateReferenceModel = { + id: 'testString', + version: 'testString', + }; + + function __createProfileTemplateTest() { + // Construct the params object for operation createProfileTemplate + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const profile = templateProfileComponentRequestModel; + const policyTemplateReferences = [policyTemplateReferenceModel]; + const createProfileTemplateParams = { + accountId, + name, + description, + profile, + policyTemplateReferences, + }; + + const createProfileTemplateResult = iamIdentityService.createProfileTemplate(createProfileTemplateParams); + + // all methods should return a Promise + expectToBePromise(createProfileTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.profile).toEqual(profile); + expect(mockRequestOptions.body.policy_template_references).toEqual(policyTemplateReferences); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createProfileTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createProfileTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createProfileTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createProfileTemplateParams = { + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createProfileTemplate(createProfileTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + + test('should not have any problems when no parameters are passed in', () => { + // invoke the method with no parameters + iamIdentityService.createProfileTemplate({}); + checkForSuccessfulExecution(createRequestMock); + }); + }); + }); + + describe('getLatestProfileTemplateVersion', () => { + describe('positive tests', () => { + function __getLatestProfileTemplateVersionTest() { + // Construct the params object for operation getLatestProfileTemplateVersion + const templateId = 'testString'; + const includeHistory = false; + const getLatestProfileTemplateVersionParams = { + templateId, + includeHistory, + }; + + const getLatestProfileTemplateVersionResult = iamIdentityService.getLatestProfileTemplateVersion(getLatestProfileTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(getLatestProfileTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getLatestProfileTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getLatestProfileTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getLatestProfileTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getLatestProfileTemplateVersionParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getLatestProfileTemplateVersion(getLatestProfileTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getLatestProfileTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getLatestProfileTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteAllVersionsOfProfileTemplate', () => { + describe('positive tests', () => { + function __deleteAllVersionsOfProfileTemplateTest() { + // Construct the params object for operation deleteAllVersionsOfProfileTemplate + const templateId = 'testString'; + const deleteAllVersionsOfProfileTemplateParams = { + templateId, + }; + + const deleteAllVersionsOfProfileTemplateResult = iamIdentityService.deleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateParams); + + // all methods should return a Promise + expectToBePromise(deleteAllVersionsOfProfileTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteAllVersionsOfProfileTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteAllVersionsOfProfileTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteAllVersionsOfProfileTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteAllVersionsOfProfileTemplateParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteAllVersionsOfProfileTemplate(deleteAllVersionsOfProfileTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteAllVersionsOfProfileTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteAllVersionsOfProfileTemplate(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('listVersionsOfProfileTemplate', () => { + describe('positive tests', () => { + function __listVersionsOfProfileTemplateTest() { + // Construct the params object for operation listVersionsOfProfileTemplate + const templateId = 'testString'; + const limit = '20'; + const pagetoken = 'testString'; + const sort = 'created_at'; + const order = 'asc'; + const includeHistory = 'false'; + const listVersionsOfProfileTemplateParams = { + templateId, + limit, + pagetoken, + sort, + order, + includeHistory, + }; + + const listVersionsOfProfileTemplateResult = iamIdentityService.listVersionsOfProfileTemplate(listVersionsOfProfileTemplateParams); + + // all methods should return a Promise + expectToBePromise(listVersionsOfProfileTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.limit).toEqual(limit); + expect(mockRequestOptions.qs.pagetoken).toEqual(pagetoken); + expect(mockRequestOptions.qs.sort).toEqual(sort); + expect(mockRequestOptions.qs.order).toEqual(order); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __listVersionsOfProfileTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __listVersionsOfProfileTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __listVersionsOfProfileTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const listVersionsOfProfileTemplateParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.listVersionsOfProfileTemplate(listVersionsOfProfileTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.listVersionsOfProfileTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.listVersionsOfProfileTemplate(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('createProfileTemplateVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // ProfileClaimRuleConditions + const profileClaimRuleConditionsModel = { + claim: 'testString', + operator: 'testString', + value: 'testString', + }; + + // TrustedProfileTemplateClaimRule + const trustedProfileTemplateClaimRuleModel = { + name: 'testString', + type: 'Profile-SAML', + realm_name: 'testString', + expiration: 38, + conditions: [profileClaimRuleConditionsModel], + }; + + // ProfileIdentityRequest + const profileIdentityRequestModel = { + identifier: 'testString', + type: 'user', + accounts: ['testString'], + description: 'testString', + }; + + // TemplateProfileComponentRequest + const templateProfileComponentRequestModel = { + name: 'testString', + description: 'testString', + rules: [trustedProfileTemplateClaimRuleModel], + identities: [profileIdentityRequestModel], + }; + + // PolicyTemplateReference + const policyTemplateReferenceModel = { + id: 'testString', + version: 'testString', + }; + + function __createProfileTemplateVersionTest() { + // Construct the params object for operation createProfileTemplateVersion + const templateId = 'testString'; + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const profile = templateProfileComponentRequestModel; + const policyTemplateReferences = [policyTemplateReferenceModel]; + const createProfileTemplateVersionParams = { + templateId, + accountId, + name, + description, + profile, + policyTemplateReferences, + }; + + const createProfileTemplateVersionResult = iamIdentityService.createProfileTemplateVersion(createProfileTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(createProfileTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions', 'POST'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.profile).toEqual(profile); + expect(mockRequestOptions.body.policy_template_references).toEqual(policyTemplateReferences); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __createProfileTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __createProfileTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __createProfileTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const createProfileTemplateVersionParams = { + templateId, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.createProfileTemplateVersion(createProfileTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.createProfileTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.createProfileTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('getProfileTemplateVersion', () => { + describe('positive tests', () => { + function __getProfileTemplateVersionTest() { + // Construct the params object for operation getProfileTemplateVersion + const templateId = 'testString'; + const version = 'testString'; + const includeHistory = false; + const getProfileTemplateVersionParams = { + templateId, + version, + includeHistory, + }; + + const getProfileTemplateVersionResult = iamIdentityService.getProfileTemplateVersion(getProfileTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(getProfileTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions/{version}', 'GET'); + const expectedAccept = 'application/json'; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.qs.include_history).toEqual(includeHistory); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __getProfileTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __getProfileTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __getProfileTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const getProfileTemplateVersionParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.getProfileTemplateVersion(getProfileTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.getProfileTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.getProfileTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('updateProfileTemplateVersion', () => { + describe('positive tests', () => { + // Request models needed by this operation. + + // ProfileClaimRuleConditions + const profileClaimRuleConditionsModel = { + claim: 'testString', + operator: 'testString', + value: 'testString', + }; + + // TrustedProfileTemplateClaimRule + const trustedProfileTemplateClaimRuleModel = { + name: 'testString', + type: 'Profile-SAML', + realm_name: 'testString', + expiration: 38, + conditions: [profileClaimRuleConditionsModel], + }; + + // ProfileIdentityRequest + const profileIdentityRequestModel = { + identifier: 'testString', + type: 'user', + accounts: ['testString'], + description: 'testString', + }; + + // TemplateProfileComponentRequest + const templateProfileComponentRequestModel = { + name: 'testString', + description: 'testString', + rules: [trustedProfileTemplateClaimRuleModel], + identities: [profileIdentityRequestModel], + }; + + // PolicyTemplateReference + const policyTemplateReferenceModel = { + id: 'testString', + version: 'testString', + }; + + function __updateProfileTemplateVersionTest() { + // Construct the params object for operation updateProfileTemplateVersion + const ifMatch = 'testString'; + const templateId = 'testString'; + const version = 'testString'; + const accountId = 'testString'; + const name = 'testString'; + const description = 'testString'; + const profile = templateProfileComponentRequestModel; + const policyTemplateReferences = [policyTemplateReferenceModel]; + const updateProfileTemplateVersionParams = { + ifMatch, + templateId, + version, + accountId, + name, + description, + profile, + policyTemplateReferences, + }; + + const updateProfileTemplateVersionResult = iamIdentityService.updateProfileTemplateVersion(updateProfileTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(updateProfileTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions/{version}', 'PUT'); + const expectedAccept = 'application/json'; + const expectedContentType = 'application/json'; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + checkUserHeader(createRequestMock, 'If-Match', ifMatch); + expect(mockRequestOptions.body.account_id).toEqual(accountId); + expect(mockRequestOptions.body.name).toEqual(name); + expect(mockRequestOptions.body.description).toEqual(description); + expect(mockRequestOptions.body.profile).toEqual(profile); + expect(mockRequestOptions.body.policy_template_references).toEqual(policyTemplateReferences); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __updateProfileTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __updateProfileTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __updateProfileTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const ifMatch = 'testString'; + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const updateProfileTemplateVersionParams = { + ifMatch, + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.updateProfileTemplateVersion(updateProfileTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.updateProfileTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.updateProfileTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('deleteProfileTemplateVersion', () => { + describe('positive tests', () => { + function __deleteProfileTemplateVersionTest() { + // Construct the params object for operation deleteProfileTemplateVersion + const templateId = 'testString'; + const version = 'testString'; + const deleteProfileTemplateVersionParams = { + templateId, + version, + }; + + const deleteProfileTemplateVersionResult = iamIdentityService.deleteProfileTemplateVersion(deleteProfileTemplateVersionParams); + + // all methods should return a Promise + expectToBePromise(deleteProfileTemplateVersionResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions/{version}', 'DELETE'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __deleteProfileTemplateVersionTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __deleteProfileTemplateVersionTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __deleteProfileTemplateVersionTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const deleteProfileTemplateVersionParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.deleteProfileTemplateVersion(deleteProfileTemplateVersionParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.deleteProfileTemplateVersion({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.deleteProfileTemplateVersion(); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + }); + }); + + describe('commitProfileTemplate', () => { + describe('positive tests', () => { + function __commitProfileTemplateTest() { + // Construct the params object for operation commitProfileTemplate + const templateId = 'testString'; + const version = 'testString'; + const commitProfileTemplateParams = { + templateId, + version, + }; + + const commitProfileTemplateResult = iamIdentityService.commitProfileTemplate(commitProfileTemplateParams); + + // all methods should return a Promise + expectToBePromise(commitProfileTemplateResult); + + // assert that create request was called + expect(createRequestMock).toHaveBeenCalledTimes(1); + + const mockRequestOptions = getOptions(createRequestMock); + + checkUrlAndMethod(mockRequestOptions, '/v1/profile_templates/{template_id}/versions/{version}/commit', 'POST'); + const expectedAccept = undefined; + const expectedContentType = undefined; + checkMediaHeaders(createRequestMock, expectedAccept, expectedContentType); + expect(mockRequestOptions.path.template_id).toEqual(templateId); + expect(mockRequestOptions.path.version).toEqual(version); + } + + test('should pass the right params to createRequest with enable and disable retries', () => { + // baseline test + __commitProfileTemplateTest(); + + // enable retries and test again + createRequestMock.mockClear(); + iamIdentityService.enableRetries(); + __commitProfileTemplateTest(); + + // disable retries and test again + createRequestMock.mockClear(); + iamIdentityService.disableRetries(); + __commitProfileTemplateTest(); + }); + + test('should prioritize user-given headers', () => { + // parameters + const templateId = 'testString'; + const version = 'testString'; + const userAccept = 'fake/accept'; + const userContentType = 'fake/contentType'; + const commitProfileTemplateParams = { + templateId, + version, + headers: { + Accept: userAccept, + 'Content-Type': userContentType, + }, + }; + + iamIdentityService.commitProfileTemplate(commitProfileTemplateParams); + checkMediaHeaders(createRequestMock, userAccept, userContentType); + }); + }); + + describe('negative tests', () => { + test('should enforce required parameters', async () => { + let err; + try { + await iamIdentityService.commitProfileTemplate({}); + } catch (e) { + err = e; + } + + expect(err.message).toMatch(/Missing required parameters/); + }); + + test('should reject promise when required params are not given', async () => { + let err; + try { + await iamIdentityService.commitProfileTemplate(); } catch (e) { err = e; }