Skip to content

Commit 0994fe3

Browse files
authored
feat(IAM Policy Management): add access management account settings API (#295)
Signed-off-by: Kelum Senanayake <[email protected]>
1 parent 0727df3 commit 0994fe3

File tree

4 files changed

+1940
-283
lines changed

4 files changed

+1940
-283
lines changed

examples/iam-policy-management.v1.test.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ describe('IamPolicyManagementV1', () => {
6565
let exampleAssignmentPolicyId;
6666
let exampleTargetAccountId;
6767
let exampleAssignmentETag;
68+
let exampleAccountSettingsETag;
6869
const exampleCustomRoleDipslayName = 'IAM Groups read access';
6970
const exampleUserId = 'IBMid-user1';
7071
const exampleServiceName = 'iam-groups';
@@ -1342,4 +1343,75 @@ describe('IamPolicyManagementV1', () => {
13421343

13431344
// end-delete_policy_template
13441345
});
1346+
test('getSettings request example', async () => {
1347+
consoleLogMock.mockImplementation((output) => {
1348+
originalLog(output);
1349+
});
1350+
consoleWarnMock.mockImplementation((output) => {
1351+
// if an error occurs, display the message and then fail the test
1352+
originalWarn(output);
1353+
expect(true).toBeFalsy();
1354+
});
1355+
1356+
// begin-get_access_management_account_settings
1357+
1358+
const getSettingsParams = {
1359+
accountId: exampleAccountId,
1360+
acceptLanguage: 'default',
1361+
};
1362+
1363+
try {
1364+
const res = await iamPolicyManagementService.getSettings(getSettingsParams);
1365+
exampleAccountSettingsETag = res.headers.etag;
1366+
console.log(JSON.stringify(res.result, null, 2));
1367+
} catch (err) {
1368+
console.warn(err)
1369+
}
1370+
// end-get_access_management_account_settings
1371+
});
1372+
test('updateSettings request example', async () => {
1373+
expect(exampleAccountSettingsETag).not.toBeNull();
1374+
consoleLogMock.mockImplementation((output) => {
1375+
originalLog(output);
1376+
});
1377+
consoleWarnMock.mockImplementation((output) => {
1378+
// if an error occurs, display the message and then fail the test
1379+
originalWarn(output);
1380+
expect(true).toBeFalsy();
1381+
});
1382+
1383+
// begin-update_access_management_account_settings
1384+
1385+
// IdentityTypesBase
1386+
const identityTypesBaseModel = {
1387+
state: 'monitor',
1388+
external_allowed_accounts: [],
1389+
};
1390+
1391+
// IdentityTypesPatch
1392+
const identityTypesPatchModel = {
1393+
user: identityTypesBaseModel,
1394+
service_id: identityTypesBaseModel,
1395+
service: identityTypesBaseModel,
1396+
};
1397+
1398+
// ExternalAccountIdentityInteractionPatch
1399+
const externalAccountIdentityInteraction = {
1400+
identity_types: identityTypesPatchModel,
1401+
};
1402+
const updateSettingsParams = {
1403+
accountId: exampleAccountId,
1404+
acceptLanguage: 'default',
1405+
ifMatch: exampleAccountSettingsETag,
1406+
externalAccountIdentityInteraction,
1407+
};
1408+
1409+
try {
1410+
const res = await iamPolicyManagementService.updateSettings(updateSettingsParams);
1411+
console.log(JSON.stringify(res.result, null, 2));
1412+
} catch (err) {
1413+
console.warn(err)
1414+
}
1415+
// end-update_access_management_account_settings
1416+
});
13451417
});

0 commit comments

Comments
 (0)