Migration Guide - upgrading to [email protected]
=======================================================================================================================================================
| Current | New |
=======================================================================================================================================================
| import com.ibm.cloud.sdk.core.service.security.IamOptions; | import com.ibm.cloud.sdk.core.security.IamAuthenticator; |
| | import com.ibm.cloud.sdk.core.http.Response; |
| | import com.ibm.cloud.objectstorage.config.resource_configuration.v1.model.BucketPatch; |
===================================================================================================================================================================
| Current | New |
===================================================================================================================================================================
| IamOptions iamOptions = new IamOptions.Builder() | IamAuthenticator authenticator = new IamAuthenticator.Builder() |
| .apiKey(apiKey).url(ibmAuthEndpoint).build(); | .apikey(apiKey).url(ibmAuthEndpoint).build(); |
| | |
==========================================================================================================================================================================
| Current | New |
==========================================================================================================================================================================
| IamOptions iamOptions = new IamOptions.Builder() | BearerTokenAuthenticator authenticator = new BearerTokenAuthenticator(bearerToken); |
| .accessToken(accessToken).url(ibmAuthEndpoint).build(); | |
| | |
Credentials using IamOptions
are no longer supported. Rather,
resource-configuration
String and an instance of Authenticator
should be passed as below.
==========================================================================================================================================================================================
| Current | New |
==========================================================================================================================================================================================
| ResourceConfiguration configClient = new ResourceConfiguration(iamOptions); | ResourceConfiguration configClient = new ResourceConfiguration("resource-configuration", authenticator); |
-
Step-1 - Creating API objects
Activity-Tracking
====================================================================================================================================================================================== | Current | New | ====================================================================================================================================================================================== | ActivityTracking activityTrackingConfig = new ActivityTracking() | ActivityTracking activityTrackingConfig = new ActivityTracking.Builder() | | .setActivityTrackerCrn(activityTrackerCrn); | .activityTrackerCrn(activityTrackerCrn).build(); | | | | | ActivityTracking activityTrackingConfig = new ActivityTracking() | ActivityTracking activityTrackingConfig = new ActivityTracking.Builder() | | .setReadDataEvents(boolean); | .readDataEvents(boolean).build(); | | | | | ActivityTracking activityTrackingConfig = new ActivityTracking() | ActivityTracking activityTrackingConfig = new ActivityTracking.Builder() | | .setWriteDataEvents(boolean); | .writeDataEvents(boolean).build(); |
Metrics-Monitoring
================================================================================================================================================================================== | Current | New | ================================================================================================================================================================================== | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring() | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring.Builder() | | .setMetricsMonitoringCrn(metricsCrn); | .metricsMonitoringCrn(metricsCrn).build(); | | | | | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring() | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring.Builder() | | .setRequestMetricsEnabled(boolean); | .requestMetricsEnabled(boolean).build(); | | | | | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring() | MetricsMonitoring metricsMonitoringConfig = new MetricsMonitoring.Builder() | | .setUsageMetricsEnabled(boolean); | .usageMetricsEnabled(boolean).build(); |
Firewall
-
Passing List as parameter
|==================================================================================================================================================================| | Current | New | |==================================================================================================================================================================| | Firewall firewallConfig = new Firewall() | Firewall firewallConfig = new Firewall.Builder() | | .setAllowedIp(allowedIpAsList); | .allowedIp(allowedIpAsList).build(); | | | | | Firewall firewallConfig = new Firewall() | Firewall firewallConfig = new Firewall.Builder() | | .setAllowedNetworkType(allowedNetworkTypeAsList); | .allowedNetworkType(allowedNetworkTypeAsList).build(); | | | | | Firewall firewallConfig = new Firewall() | Firewall firewallConfig = new Firewall.Builder() | | .setDeniedIp(deniedIpAsList); | .deniedIp(deniedIpAsList).build(); |
-
Passing String as parameter
Firewall firewallConfig = new Firewall.Builder().addAllowedIp(allowedIpAsString).build(); Firewall firewallConfig = new Firewall.Builder().addAllowedNetworkType(allowedNetworkTypeaAString).build(); Firewall firewallConfig = new Firewall.Builder().addDeniedIp(deniedIpAsString).build();
NOTE:
allowedNetworkType
accepted values are likeAllowedNetworkType.X_PRIVATE
/AllowedNetworkType.X_PUBLIC
/AllowedNetworkType.DIRECT
.
-
-
Step-2 - Building a Patch Object from the above API objects
BucketPatch bucketPatch = new BucketPatch.Builder().activityTracking(activityTrackingConfig).build(); BucketPatch bucketPatch = new BucketPatch.Builder().firewall(firewallConfig).build(); BucketPatch bucketPatch = new BucketPatch.Builder().hardQuota(integer).build(); BucketPatch bucketPatch = new BucketPatch.Builder().metricsMonitoring(metricsMonitoringConfig).build();
-
Step-3 - Updating bucket configuration
|=============================================================================================================================================================================================| | Current | New | |=============================================================================================================================================================================================| | UpdateBucketConfigOptions bucketOptions = new UpdateBucketConfigOptions.Builder(bucketName) | UpdateBucketConfigOptions updateBucket = new UpdateBucketConfigOptions.Builder(bucketName) | | .apiName(apiConfig).build(); | .bucketPatch(bucketPatch.asPatch()).build(); |
- NOTE:
apiName
andapiConfig
areactivityTracking/firewall/hardQuota/metricsMonitoring
andactivityTrackingConfig/firewallConfig/hardQuotaConfig/metricsMonitoringConfig
respectively.
- NOTE:
-
Get-Bucket-Configuration
|=======================================================================================================================================================================| | Current | New | |=======================================================================================================================================================================| | Bucket bucket = = configClient.getBucketConfig(bucketOptions).execute(); | Bucket bucket = configClient.getBucketConfig(bucketOptions).execute().getResult(); |
-
Activity-Tracking
|==========================================================================================================================================================================================| | Current | New | |==========================================================================================================================================================================================| | String activityTrackingCrn = getBucketConfig.getActivityTracking().getActivityTrackerCrn(); | String activityTrackingCrn = getBucketConfig.getActivityTracking().activityTrackerCrn(); | | | | | boolean isReadEvents = getBucketConfig.getActivityTracking().isReadDataEvents(); | boolean isReadEvents = getBucketConfig.getActivityTracking().readDataEvents(); | | | | | boolean isWriteEvents = getBucketConfig.getActivityTracking().isWriteDataEvents(); | boolean isWriteEvents = getBucketConfig.getActivityTracking().writeDataEvents(); | | | |
-
Firewall
|===================================================================================================================================================================================| | Current | New | |===================================================================================================================================================================================| | List<String> allowedIp = getBucketConfig.getFirewall().getAllowedIp(); | List<String> allowedIp = getBucketConfig.getFirewall().allowedIp(); | | | | | List<String> allowedNetworkType = getBucketConfig.getFirewall().getAllowedNetworkType(); | List<String> allowedNetworkType = getBucketConfig.getFirewall().allowedNetworkType();| | | | | boolean isWriteEvents = getBucketConfig.getFirewall().getDeniedIp(); | List<String> deniedIp = getBucketConfig.getFirewall().deniedIp(); | | | |
-
Metrics-Monitoring
|======================================================================================================================================================================================================================| | Current | New | |======================================================================================================================================================================================================================| | String metricsMonitoringCrn = getBucketConfig.getMetricsMonitoring().getMetricsMonitoringCrn(); | String metricsMonitoringCrn = getBucketConfig.getBucketConfig.getMetricsMonitoring().metricsMonitoringCrn(); | | | | | boolean isRequestMetricsEnabled = getBucketConfig.getMetricsMonitoring().isRequestMetricsEnabled(); | boolean isRequestMetricsEnabled = getBucketConfig.getMetricsMonitoring().requestMetricsEnabled(); | | | | | boolean isUsageMetricsEnabled = getBucketConfig.getMetricsMonitoring().isUsageMetricsEnabled(); | boolean isUsageMetricsEnabled = getBucketConfig.getMetricsMonitoring().usageMetricsEnabled(); | | | |
|============================================================= |
| Current | New |
|==============================================================|
| ibm-cos-resource-config-sdk-java | ibm-cos-sdk-java-config |