Skip to content

Commit 6f7b19e

Browse files
feat(IAM Identity): add Identity Preference API (#284)
* feat(IAM Identity): adding Identity Preference API Signed-off-by: poorani <[email protected]>
1 parent e946192 commit 6f7b19e

File tree

5 files changed

+1065
-58
lines changed

5 files changed

+1065
-58
lines changed

.secrets.baseline

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-01-10T19:15:56Z",
6+
"generated_at": "2025-02-04T20:38:35Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -88,15 +88,15 @@
8888
"hashed_secret": "a2190c299b60e882d9fb33736d5e6ab6ffe42708",
8989
"is_secret": false,
9090
"is_verified": false,
91-
"line_number": 1252,
91+
"line_number": 1256,
9292
"type": "Secret Keyword",
9393
"verified_result": null
9494
},
9595
{
9696
"hashed_secret": "cf4d2385b84329a52ca542285b93d9c4618420df",
9797
"is_secret": false,
9898
"is_verified": false,
99-
"line_number": 2111,
99+
"line_number": 2115,
100100
"type": "Secret Keyword",
101101
"verified_result": null
102102
}
@@ -106,31 +106,39 @@
106106
"hashed_secret": "aa4ad361672f4c98fd64bf0db80127dd79be59d0",
107107
"is_secret": false,
108108
"is_verified": false,
109-
"line_number": 317,
109+
"line_number": 293,
110110
"type": "Secret Keyword",
111111
"verified_result": null
112112
},
113113
{
114114
"hashed_secret": "0a49d517da94f14c36ac92806c1d15cf95fbca67",
115115
"is_secret": false,
116116
"is_verified": false,
117-
"line_number": 803,
117+
"line_number": 781,
118118
"type": "Secret Keyword",
119119
"verified_result": null
120120
},
121121
{
122122
"hashed_secret": "835e124f126ae02c1c18b3c992a28dde441f5e04",
123123
"is_secret": false,
124124
"is_verified": false,
125-
"line_number": 2342,
125+
"line_number": 2282,
126+
"type": "Secret Keyword",
127+
"verified_result": null
128+
},
129+
{
130+
"hashed_secret": "21e665c80283a061b48bb3a642333d5541051b13",
131+
"is_secret": false,
132+
"is_verified": false,
133+
"line_number": 6406,
126134
"type": "Secret Keyword",
127135
"verified_result": null
128136
},
129137
{
130138
"hashed_secret": "e058a1c493ad749bd67d368340e9056ed1c2f3ed",
131139
"is_secret": false,
132140
"is_verified": false,
133-
"line_number": 6593,
141+
"line_number": 6625,
134142
"type": "Secret Keyword",
135143
"verified_result": null
136144
}
@@ -150,15 +158,15 @@
150158
"hashed_secret": "a2190c299b60e882d9fb33736d5e6ab6ffe42708",
151159
"is_secret": false,
152160
"is_verified": false,
153-
"line_number": 1478,
161+
"line_number": 1485,
154162
"type": "Secret Keyword",
155163
"verified_result": null
156164
},
157165
{
158166
"hashed_secret": "cf4d2385b84329a52ca542285b93d9c4618420df",
159167
"is_secret": false,
160168
"is_verified": false,
161-
"line_number": 2081,
169+
"line_number": 2208,
162170
"type": "Secret Keyword",
163171
"verified_result": null
164172
}

examples/iam-identity.v1.test.js

Lines changed: 133 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { expectToBePromise } = require('ibm-cloud-sdk-core/lib/sdk-test-helpers')
3737
// IAM_IDENTITY_IAM_ID_MEMBER=<IAM ID of a user belonging to the account but different to the one above>
3838
// IAM_IDENTITY_ENTERPISE_ACCOUNT_ID=<AccountID of the enterprise account>
3939
// IAM_IDENTITY_ENTERPISE_SUBACCOUNT_ID=<AccountID of an account in the enterprise>
40-
//
40+
// IAM_IDENTITY_IAM_ID_FOR_PREFERENCES=IAM id of the profile to set preferences
4141
// These configuration properties can be exported as environment variables, or stored
4242
// in a configuration file and then:
4343
// export IBM_CREDENTIALS_FILE=<name of configuration file>
@@ -67,13 +67,17 @@ describe('IamIdentityV1', () => {
6767
const apikeyName = 'Example-ApiKey';
6868
const serviceIdName = 'Example-ServiceId';
6969
const realmName = 'https://sdk.test.realm/1234';
70+
const service = 'console'
71+
const valueString = '/billing'
72+
const preferenceID1 = 'landing_page'
7073

7174
let accountId = config.accountId;
7275
let iamId = config.iamId;
7376
let iamIdMember = config.iamIdMember;
7477
let iamApikey = config.apikey;
7578
let enterpriseAccountId = config.enterpriseAccountId;
7679
let enterpriseSubAccountId = config.enterpriseSubaccountId;
80+
let iamIDForPreferences = config.iamIDForPreferences;
7781

7882
let apikeyId = null;
7983
let apikeyEtag = null;
@@ -1280,7 +1284,7 @@ test('createApiKey request example', async () => {
12801284

12811285

12821286
originalLog('getEffectiveAccountSettings() result:');
1283-
// begin-getEffectiveAccountSettings
1287+
// begin-get_effective_account_settings
12841288

12851289
const params = {
12861290
accountId: accountId,
@@ -1293,7 +1297,7 @@ test('createApiKey request example', async () => {
12931297
console.warn(err)
12941298
}
12951299

1296-
// end-getEffectiveAccountSettings
1300+
// end-get_effective_account_settings
12971301
});
12981302
test('createReport request example', async () => {
12991303

@@ -2302,6 +2306,132 @@ test('createApiKey request example', async () => {
23022306
}
23032307
// end-delete_all_versions_of_account_settings_template
23042308
}
2309+
test('updatePreferenceOnScopeAccount request example', async () => {
2310+
2311+
consoleLogMock.mockImplementation(output => {
2312+
originalLog(output);
2313+
});
2314+
consoleWarnMock.mockImplementation(output => {
2315+
originalWarn(output);
2316+
// when the test fails we need to print out the error message and stop execution right after it
2317+
expect(true).toBeFalsy();
2318+
});
2319+
2320+
expect(iamIDForPreferences).not.toBeNull();
2321+
2322+
originalLog('updatePreferenceOnScopeAccount() result:');
2323+
// begin-update_preference_on_scope_account
2324+
2325+
const params = {
2326+
accountId: accountId,
2327+
iamId: iamIDForPreferences,
2328+
service: service,
2329+
preferenceID: preferenceID1,
2330+
valueString: valueString,
2331+
};
2332+
2333+
try {
2334+
const res = await iamIdentityService.updatePreferenceOnScopeAccount(params);
2335+
console.log(JSON.stringify(res.result, null, 2));
2336+
} catch (err) {
2337+
console.warn(err);
2338+
}
2339+
2340+
// end-update_preference_on_scope_account
2341+
});
2342+
test('getPreferencesOnScopeAccount request example', async () => {
2343+
2344+
consoleLogMock.mockImplementation(output => {
2345+
originalLog(output);
2346+
});
2347+
consoleWarnMock.mockImplementation(output => {
2348+
originalWarn(output);
2349+
// when the test fails we need to print out the error message and stop execution right after it
2350+
expect(true).toBeFalsy();
2351+
});
2352+
2353+
expect(iamIDForPreferences).not.toBeNull();
2354+
2355+
originalLog('getPreferencesOnScopeAccount() result:');
2356+
// begin-get_preferences_on_scope_account
2357+
2358+
const params = {
2359+
accountId: accountId,
2360+
iamId: iamIDForPreferences,
2361+
service: service,
2362+
preferenceID: preferenceID1,
2363+
};
2364+
2365+
try {
2366+
const res = await iamIdentityService.getPreferencesOnScopeAccount(params);
2367+
console.log(JSON.stringify(res.result, null, 2));
2368+
} catch (err) {
2369+
console.warn(err);
2370+
}
2371+
2372+
// end-get_preferences_on_scope_account
2373+
});
2374+
test('getAllPreferencesOnScopeAccount request example', async () => {
2375+
2376+
consoleLogMock.mockImplementation(output => {
2377+
originalLog(output);
2378+
});
2379+
consoleWarnMock.mockImplementation(output => {
2380+
originalWarn(output);
2381+
// when the test fails we need to print out the error message and stop execution right after it
2382+
expect(true).toBeFalsy();
2383+
});
2384+
2385+
expect(iamIDForPreferences).not.toBeNull();
2386+
2387+
originalLog('getAllPreferencesOnScopeAccount() result:');
2388+
// begin-get_all_preferences_on_scope_account
2389+
2390+
const params = {
2391+
accountId: accountId,
2392+
iamId: iamIDForPreferences,
2393+
};
2394+
2395+
try {
2396+
const res = await iamIdentityService.getAllPreferencesOnScopeAccount(params);
2397+
console.log(JSON.stringify(res.result, null, 2));
2398+
} catch (err) {
2399+
console.warn(err);
2400+
}
2401+
2402+
// end-get_all_preferences_on_scope_account
2403+
});
2404+
test('deletePreferencesOnScopeAccount request example', async () => {
2405+
2406+
consoleLogMock.mockImplementation(output => {
2407+
originalLog(output);
2408+
});
2409+
consoleWarnMock.mockImplementation(output => {
2410+
originalWarn(output);
2411+
// when the test fails we need to print out the error message and stop execution right after it
2412+
expect(true).toBeFalsy();
2413+
});
2414+
2415+
expect(iamIDForPreferences).not.toBeNull();
2416+
2417+
originalLog('deletePreferencesOnScopeAccount() result:');
2418+
// begin-delete_preferences_on_scope_account
2419+
2420+
const params = {
2421+
accountId: accountId,
2422+
iamId: iamIDForPreferences,
2423+
service: service,
2424+
preferenceID: preferenceID1,
2425+
};
2426+
2427+
try {
2428+
await iamIdentityService.deletePreferencesOnScopeAccount(params);
2429+
} catch (err) {
2430+
console.warn(err);
2431+
}
2432+
2433+
// end-delete_preferences_on_scope_account
2434+
});
23052435

23062436
function isFinishedEx(status) {
23072437
return ("succeeded" === status.toLowerCase() || "failed" === status.toLowerCase());

0 commit comments

Comments
 (0)