@@ -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