Source:
public PlatformResourceRequest getPlatformResourceRequest( String accountId, String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, AccessConfigTypeQueryParam accessConfigType, CdpResourceType cdpResourceType) { PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest(); if (!Strings.isNullOrEmpty(credentialName)) { Credential credential = credentialService.getByNameForAccountId(credentialName, accountId, ENVIRONMENT); if (credential == null) { credential = credentialService.getByNameForAccountId(credentialName, accountId, AUDIT); } platformResourceRequest.setCredential(credential); } else if (!Strings.isNullOrEmpty(credentialCrn)) { Credential credential = credentialService.getByCrnForAccountId(credentialCrn, accountId, ENVIRONMENT); if (credential == null) { credential = credentialService.getByCrnForAccountId(credentialCrn, accountId, AUDIT); } platformResourceRequest.setCredential(credential); } else { throw new BadRequestException("The credentialCrn or the credentialName must be specified in the request"); } if (!Strings.isNullOrEmpty(platformVariant)) { platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform()); } else { platformResourceRequest.setPlatformVariant( Strings.isNullOrEmpty(platformVariant) ? platformResourceRequest.getCredential().getCloudPlatform() : platformVariant); } platformResourceRequest.setCdpResourceType(Objects.requireNonNullElse(cdpResourceType, CdpResourceType.DEFAULT)); platformResourceRequest.setRegion(region); platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform()); if (!Strings.isNullOrEmpty(availabilityZone)) { platformResourceRequest.setAvailabilityZone(availabilityZone); } String accessConfigTypeString = NullUtil.getIfNotNull(accessConfigType, Enum::name); if (accessConfigTypeString != null) { platformResourceRequest.setFilters(Map.of(ACCESS_CONFIG_TYPE, accessConfigTypeString)); } return platformResourceRequest; }

Target:
public PlatformResourceRequest getPlatformResourceRequest( String accountId, String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, AccessConfigTypeQueryParam accessConfigType, CdpResourceType cdpResourceType) { PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest(); if (!Strings.isNullOrEmpty(credentialName)) { Optional<Credential> credential = credentialService.getOptionalByNameForAccountId(credentialName, accountId, ENVIRONMENT); if (credential.isEmpty()) { credential = credentialService.getOptionalByNameForAccountId(credentialName, accountId, AUDIT); } platformResourceRequest.setCredential(credentialService.extractCredential(credential, credentialName)); } else if (!Strings.isNullOrEmpty(credentialCrn)) { Optional<Credential> credential = credentialService.getOptionalByCrnForAccountId(credentialCrn, accountId, ENVIRONMENT); if (credential.isEmpty()) { credential = credentialService.getOptionalByCrnForAccountId(credentialCrn, accountId, AUDIT); } platformResourceRequest.setCredential(credentialService.extractCredential(credential, credentialCrn)); } else { throw new BadRequestException("The credentialCrn or the credentialName must be specified in the request"); } if (!Strings.isNullOrEmpty(platformVariant)) { platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform()); } else { platformResourceRequest.setPlatformVariant( Strings.isNullOrEmpty(platformVariant) ? platformResourceRequest.getCredential().getCloudPlatform() : platformVariant); } platformResourceRequest.setCdpResourceType(Objects.requireNonNullElse(cdpResourceType, CdpResourceType.DEFAULT)); platformResourceRequest.setRegion(region); platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform()); if (!Strings.isNullOrEmpty(availabilityZone)) { platformResourceRequest.setAvailabilityZone(availabilityZone); } String accessConfigTypeString = NullUtil.getIfNotNull(accessConfigType, Enum::name); if (accessConfigTypeString != null) { platformResourceRequest.setFilters(Map.of(ACCESS_CONFIG_TYPE, accessConfigTypeString)); } return platformResourceRequest; }