Skip to content

Commit f8a0a6e

Browse files
authored
feat(IAM Identity): add new account settings (#285)
Signed-off-by: Daniel Byrne <[email protected]>
1 parent 0668fd3 commit f8a0a6e

File tree

38 files changed

+1707
-632
lines changed

38 files changed

+1707
-632
lines changed

modules/examples/src/main/java/com/ibm/cloud/platform_services/iam_identity/v1/IamIdentityExamples.java

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020, 2023.
2+
* (C) Copyright IBM Corp. 2020, 2025.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -51,22 +51,22 @@ public class IamIdentityExamples {
5151
protected IamIdentityExamples() {
5252
}
5353

54-
private static String apiKeyName = "Example-ApiKey";
55-
private static String serviceIdName = "Example-ServiceId";
56-
private static String profileName = "Example-Profile";
54+
private static long now = System.currentTimeMillis() / 1000;
55+
private static String apiKeyName = "JavaSDK-Example-ApiKey-" + now;
56+
private static String serviceIdName = "JavaSDK-Example-ServiceId-" + now;
57+
private static String profileName = "JavaSDK-Example-Profile-" + now;
5758
private static String claimRuleType = "Profile-SAML";
5859
private static String realmName = "https://my.test.realm/1234/saml20";
59-
private static String profileTemplateName = "Example-Profile-Template";
60-
private static String profileTemplateProfileName = "Profile-From-Example-Template";
61-
private static String accountSettingsTemplateName = "Example-Account-Settings-Template";
60+
private static String profileTemplateName = "JavaSDK-Example-Profile-Template-" + now;
61+
private static String profileTemplateProfileName = "Profile-From-JavaSDK-Example-Template-" + now;
62+
private static String accountSettingsTemplateName = "JavaSDK-Example-Account-Settings-Template-" + now;
6263
private static String service = "console";
6364
private static String valueString = "/billing";
6465
private static String preferenceId1 = "landing_page";
6566

6667
//values to be read from the env file
6768
private static String accountId;
6869
private static String iamId;
69-
private static String iamIdMember;
7070
private static String iamApiKey;
7171
private static String enterpriseAccountId;
7272
private static String enterpriseSubAccountId;
@@ -111,10 +111,8 @@ public static void main(String[] args) throws Exception {
111111
accountId = config.get("ACCOUNT_ID");
112112
iamApiKey = config.get("APIKEY");
113113
iamId = config.get("IAM_ID");
114-
iamIdMember = config.get("IAM_ID_MEMBER");
115114
enterpriseAccountId = config.get("ENTERPRISE_ACCOUNT_ID");
116115
enterpriseSubAccountId = config.get("ENTERPRISE_SUBACCOUNT_ID");
117-
trustedProfileForPreferences = "iam-" + config.get("PROFILEID1");
118116

119117
try {
120118
System.out.println("createApiKey() result:");
@@ -592,6 +590,7 @@ public static void main(String[] args) throws Exception {
592590
Response<TrustedProfile> response = identityservice.createProfile(createProfileOptions).execute();
593591
TrustedProfile profile = response.getResult();
594592
profileId = profile.getId();
593+
trustedProfileForPreferences = profile.getIamId();
595594

596595
System.out.println(profile);
597596

@@ -1011,7 +1010,7 @@ public static void main(String[] args) throws Exception {
10111010
SetProfileIdentityOptions setProfileIdentityOptions = new SetProfileIdentityOptions.Builder()
10121011
.profileId(profileId)
10131012
.identityType(type)
1014-
.identifier(iamIdMember)
1013+
.identifier(iamId)
10151014
.type("user")
10161015
.accounts(accounts)
10171016
.description(description)
@@ -1035,7 +1034,7 @@ public static void main(String[] args) throws Exception {
10351034
GetProfileIdentityOptions getProfileIdentityOptions = new GetProfileIdentityOptions.Builder()
10361035
.profileId(profileId)
10371036
.identityType("user")
1038-
.identifierId(iamIdMember)
1037+
.identifierId(iamId)
10391038
.build();
10401039
Response<ProfileIdentityResponse> response = identityservice.getProfileIdentity(getProfileIdentityOptions).execute();
10411040

@@ -1056,7 +1055,7 @@ public static void main(String[] args) throws Exception {
10561055
DeleteProfileIdentityOptions deleteProfileIdentityOptions = new DeleteProfileIdentityOptions.Builder()
10571056
.profileId(profileId)
10581057
.identityType("user")
1059-
.identifierId(iamIdMember)
1058+
.identifierId(iamId)
10601059
.build();
10611060
Response<Void> response = identityservice.deleteProfileIdentity(deleteProfileIdentityOptions).execute();
10621061

@@ -1070,27 +1069,6 @@ public static void main(String[] args) throws Exception {
10701069
e.getMessage(), e.getDebuggingInfo()), e);
10711070
}
10721071

1073-
1074-
try {
1075-
System.out.println("deleteProfile() result:");
1076-
1077-
// begin-delete_profile
1078-
1079-
DeleteProfileOptions deleteProfileOptions = new DeleteProfileOptions.Builder()
1080-
.profileId(profileId)
1081-
.build();
1082-
1083-
Response<Void> response = identityservice.deleteProfile(deleteProfileOptions).execute();
1084-
1085-
// end-delete_profile
1086-
1087-
System.out.printf("deleteProfile() response status code: %d%n", response.getStatusCode());
1088-
1089-
} catch (ServiceResponseException e) {
1090-
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
1091-
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
1092-
}
1093-
10941072
try {
10951073
System.out.println("getAccountSettings() result:");
10961074

@@ -1119,21 +1097,31 @@ public static void main(String[] args) throws Exception {
11191097

11201098
// begin-updateAccountSettings
11211099

1122-
AccountSettingsUserMFA userMFA = new AccountSettingsUserMFA.Builder()
1123-
.iamId(iamIdMember)
1100+
UserMfa userMFA = new UserMfa.Builder()
1101+
.iamId(iamId)
11241102
.mfa("NONE")
11251103
.build();
11261104

1127-
List<AccountSettingsUserMFA> userMFAExpList = new ArrayList<>();
1105+
List<UserMfa> userMFAExpList = new ArrayList<>();
11281106
userMFAExpList.add(userMFA);
11291107

1108+
AccountSettingsUserDomainRestriction domain = new AccountSettingsUserDomainRestriction.Builder("IBMid")
1109+
.addInvitationEmailAllowPatterns("*.*@company.com")
1110+
.restrictInvitation(Boolean.FALSE)
1111+
.build();
1112+
1113+
List<AccountSettingsUserDomainRestriction> userDomainRestrictions = new ArrayList<>();
1114+
userDomainRestrictions.add(domain);
1115+
11301116
UpdateAccountSettingsOptions updateAccountSettingsOptions = new UpdateAccountSettingsOptions.Builder()
11311117
.ifMatch(accountSettingsEtag)
11321118
.accountId(accountId)
11331119
.sessionExpirationInSeconds("86400")
11341120
.sessionInvalidationInSeconds("7200")
11351121
.restrictCreatePlatformApikey("NOT_RESTRICTED")
11361122
.restrictCreateServiceId("NOT_RESTRICTED")
1123+
.restrictUserListVisibility("NOT_RESTRICTED")
1124+
.restrictUserDomains(userDomainRestrictions)
11371125
.mfa("NONE")
11381126
.userMfa(userMFAExpList)
11391127
.systemAccessTokenExpirationInSeconds("3600")
@@ -1626,13 +1614,13 @@ public static void main(String[] args) throws Exception {
16261614
Response<TemplateAssignmentResponse> updateResponse = identityservice.updateTrustedProfileAssignment(updateOptions).execute();
16271615
TemplateAssignmentResponse updateResult = updateResponse.getResult();
16281616

1629-
// Grab the Etag value from the response for use in the update operation.
1630-
profileTemplateAssignmentEtag = updateResponse.getHeaders().values("Etag").get(0);
1631-
16321617
System.out.println(updateResult);
16331618

16341619
// end-update_trusted_profile_assignment
16351620

1621+
// Grab the Etag value from the response for use in the update operation.
1622+
profileTemplateAssignmentEtag = updateResponse.getHeaders().values("Etag").get(0);
1623+
16361624
} catch (ServiceResponseException e) {
16371625
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
16381626
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
@@ -2180,6 +2168,26 @@ public static void main(String[] args) throws Exception {
21802168
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
21812169
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
21822170
}
2171+
2172+
try {
2173+
System.out.println("deleteProfile() result:");
2174+
2175+
// begin-delete_profile
2176+
2177+
DeleteProfileOptions deleteProfileOptions = new DeleteProfileOptions.Builder()
2178+
.profileId(profileId)
2179+
.build();
2180+
2181+
Response<Void> response = identityservice.deleteProfile(deleteProfileOptions).execute();
2182+
2183+
// end-delete_profile
2184+
2185+
System.out.printf("deleteProfile() response status code: %d%n", response.getStatusCode());
2186+
2187+
} catch (ServiceResponseException e) {
2188+
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
2189+
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
2190+
}
21832191
}
21842192

21852193
private static void sleep(int numSecs) {

modules/iam-identity/src/main/java/com/ibm/cloud/platform_services/iam_identity/v1/IamIdentity.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313

1414
/*
15-
* IBM OpenAPI SDK Code Generator Version: 3.106.0-09823488-20250707-071701
15+
* IBM OpenAPI SDK Code Generator Version: 3.107.1-41b0fbd0-20250825-080732
1616
*/
1717

1818
package com.ibm.cloud.platform_services.iam_identity.v1;
@@ -601,7 +601,6 @@ public ServiceCall<Void> deleteServiceIdGroup(DeleteServiceIdGroupOptions delete
601601
return createServiceCall(builder.build(), responseConverter);
602602
}
603603

604-
605604
/**
606605
* Get API keys for a given service or user IAM ID and account ID.
607606
*
@@ -1646,6 +1645,9 @@ public ServiceCall<AccountSettingsResponse> getAccountSettings(GetAccountSetting
16461645
if (getAccountSettingsOptions.includeHistory() != null) {
16471646
builder.query("include_history", String.valueOf(getAccountSettingsOptions.includeHistory()));
16481647
}
1648+
if (getAccountSettingsOptions.resolveUserMfa() != null) {
1649+
builder.query("resolve_user_mfa", String.valueOf(getAccountSettingsOptions.resolveUserMfa()));
1650+
}
16491651
ResponseConverter<AccountSettingsResponse> responseConverter =
16501652
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<AccountSettingsResponse>() { }.getType());
16511653
return createServiceCall(builder.build(), responseConverter);
@@ -1679,15 +1681,18 @@ public ServiceCall<AccountSettingsResponse> updateAccountSettings(UpdateAccountS
16791681
if (updateAccountSettingsOptions.restrictCreatePlatformApikey() != null) {
16801682
contentJson.addProperty("restrict_create_platform_apikey", updateAccountSettingsOptions.restrictCreatePlatformApikey());
16811683
}
1684+
if (updateAccountSettingsOptions.restrictUserListVisibility() != null) {
1685+
contentJson.addProperty("restrict_user_list_visibility", updateAccountSettingsOptions.restrictUserListVisibility());
1686+
}
1687+
if (updateAccountSettingsOptions.restrictUserDomains() != null) {
1688+
contentJson.add("restrict_user_domains", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateAccountSettingsOptions.restrictUserDomains()));
1689+
}
16821690
if (updateAccountSettingsOptions.allowedIpAddresses() != null) {
16831691
contentJson.addProperty("allowed_ip_addresses", updateAccountSettingsOptions.allowedIpAddresses());
16841692
}
16851693
if (updateAccountSettingsOptions.mfa() != null) {
16861694
contentJson.addProperty("mfa", updateAccountSettingsOptions.mfa());
16871695
}
1688-
if (updateAccountSettingsOptions.userMfa() != null) {
1689-
contentJson.add("user_mfa", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateAccountSettingsOptions.userMfa()));
1690-
}
16911696
if (updateAccountSettingsOptions.sessionExpirationInSeconds() != null) {
16921697
contentJson.addProperty("session_expiration_in_seconds", updateAccountSettingsOptions.sessionExpirationInSeconds());
16931698
}
@@ -1703,6 +1708,9 @@ public ServiceCall<AccountSettingsResponse> updateAccountSettings(UpdateAccountS
17031708
if (updateAccountSettingsOptions.systemRefreshTokenExpirationInSeconds() != null) {
17041709
contentJson.addProperty("system_refresh_token_expiration_in_seconds", updateAccountSettingsOptions.systemRefreshTokenExpirationInSeconds());
17051710
}
1711+
if (updateAccountSettingsOptions.userMfa() != null) {
1712+
contentJson.add("user_mfa", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateAccountSettingsOptions.userMfa()));
1713+
}
17061714
builder.bodyJson(contentJson);
17071715
ResponseConverter<AccountSettingsResponse> responseConverter =
17081716
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<AccountSettingsResponse>() { }.getType());

0 commit comments

Comments
 (0)