diff --git a/.secrets.baseline b/.secrets.baseline index e16416ddfc..9fa4bce61c 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "package-lock.json|go.sum|^.secrets.baseline$", "lines": null }, - "generated_at": "2025-07-18T15:15:13Z", + "generated_at": "2026-06-08T08:32:21Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -90,7 +90,7 @@ "hashed_secret": "f0b0b291c4d22d76db59faaeb94802714dd6d884", "is_secret": false, "is_verified": false, - "line_number": 493, + "line_number": 494, "type": "Hex High Entropy String", "verified_result": null }, @@ -98,7 +98,7 @@ "hashed_secret": "4c41e7a08e8895da0c6066adf33bf389c202b4e2", "is_secret": false, "is_verified": false, - "line_number": 711, + "line_number": 712, "type": "Hex High Entropy String", "verified_result": null }, @@ -106,7 +106,7 @@ "hashed_secret": "ca8b3e9d1445b3218e3512da63b05c8f26f181e5", "is_secret": false, "is_verified": false, - "line_number": 722, + "line_number": 723, "type": "Hex High Entropy String", "verified_result": null } @@ -178,7 +178,7 @@ "hashed_secret": "69ceb65c6e41b82105f435246134b03da6fcdbf7", "is_secret": false, "is_verified": false, - "line_number": 2535, + "line_number": 2622, "type": "Secret Keyword", "verified_result": null } @@ -201,6 +201,168 @@ "verified_result": null } ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsTest.java": [ + { + "hashed_secret": "61bd9cf7208f6ac60767238bddf6275d8b5e0470", + "is_secret": false, + "is_verified": false, + "line_number": 118, + "type": "Hex High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "5ee95d2008b1f8c711bd529e56f8c0f5a0195c59", + "is_secret": false, + "is_verified": false, + "line_number": 350, + "type": "Base64 High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "25aa406161de00c66d48556243a8674a9e9586fe", + "is_secret": false, + "is_verified": false, + "line_number": 799, + "type": "Base64 High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 826, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 46, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 101, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 38, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 39, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 37, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 38, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 39, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 37, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 39, + "type": "Base64 High Entropy String", + "verified_result": null + }, + { + "hashed_secret": "61bd9cf7208f6ac60767238bddf6275d8b5e0470", + "is_secret": false, + "is_verified": false, + "line_number": 40, + "type": "Hex High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 39, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 101, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], + "modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptionsTest.java": [ + { + "hashed_secret": "ca15d23a2ccdee96d9e8e0ea5041e091d352266d", + "is_secret": false, + "is_verified": false, + "line_number": 47, + "type": "Base64 High Entropy String", + "verified_result": null + } + ], "modules/resource-controller/src/test/java/com/ibm/cloud/platform_services/resource_controller/v2/ResourceControllerTest.java": [ { "hashed_secret": "0f97a4e707b7424540793cb2078919ee6770e07f", @@ -228,7 +390,7 @@ } ] }, - "version": "0.13.1+ibm.62.dss", + "version": "0.13.1+ibm.64.dss", "word_list": { "file": null, "hash": null diff --git a/README.md b/README.md index 1c12b3aafd..9768663351 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ Service Name | Artifact Coordinates [IBM Cloud Shell](https://cloud.ibm.com/apidocs/cloudshell?code=java) | com.ibm.cloud:ibm-cloud-shell:0.75.2 [Open Service Broker](https://cloud.ibm.com/apidocs/resource-controller/ibm-cloud-osb-api?code=java) | com.ibm.cloud:open-service-broker:0.75.2 [Partner Management APIs](https://cloud.ibm.com/apidocs/partner-apis/partner?code=go) | com.ibm.cloud:partner-management:0.75.2 +[Platform Notifications](https://cloud.ibm.com/apidocs/platform-notifications?code=java) | com.ibm.cloud:platform-notifications:0.75.2 [Resource Controller](https://cloud.ibm.com/apidocs/resource-controller/resource-controller?code=java) | com.ibm.cloud:resource-controller:0.75.2 [Resource Manager](https://cloud.ibm.com/apidocs/resource-controller/resource-manager?code=java) | com.ibm.cloud:resource-manager:0.75.2 [Usage Metering](https://cloud.ibm.com/apidocs/usage-metering?code=java) | com.ibm.cloud:usage-metering:0.75.2 diff --git a/modules/coverage-reports/pom.xml b/modules/coverage-reports/pom.xml index 972ff34dc8..87bda4951d 100644 --- a/modules/coverage-reports/pom.xml +++ b/modules/coverage-reports/pom.xml @@ -108,6 +108,11 @@ partner-management ${project.version} + + ${project.groupId} + platform-notifications + ${project.version} + ${project.groupId} resource-controller diff --git a/modules/examples/pom.xml b/modules/examples/pom.xml index 8381ddda8f..f48f4df503 100644 --- a/modules/examples/pom.xml +++ b/modules/examples/pom.xml @@ -97,6 +97,11 @@ partner-management ${project.version} + + ${project.groupId} + platform-notifications + ${project.version} + ${project.groupId} resource-controller diff --git a/modules/examples/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsExamples.java b/modules/examples/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsExamples.java new file mode 100644 index 0000000000..06148c6651 --- /dev/null +++ b/modules/examples/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsExamples.java @@ -0,0 +1,330 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Acknowledgement; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototypeEventNotificationDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreateDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreatePreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListDistributionListDestinationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListNotificationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Notification; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationsPager; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferencesObject; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationResponseBody; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDistributionListDestinationOptions; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.util.CredentialUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class contains examples of how to use the Platform Notifications service. + * + * The following configuration properties are assumed to be defined: + * PLATFORM_NOTIFICATIONS_IAM_PROFILE_ID=<account_id> + * PLATFORM_NOTIFICATIONS_AUTH_TYPE=iam + * PLATFORM_NOTIFICATIONS_APIKEY=<apiKey> + * PLATFORM_NOTIFICATIONS_AUTH_URL=<IAM token service base URL - omit this if using the production environment> + * PLATFORM_NOTIFICATIONS_ACCOUNT_ID=<id> + * PLATFORM_NOTIFICATIONS_DESTINATION_ID=<account_id> + * PLATFORM_NOTIFICATIONS_IAM_ID=<iam_id> + * PLATFORM_NOTIFICATIONS_SERVICE_URL=<service_url> + * + * These configuration properties can be exported as environment variables, or stored + * in a configuration file and then: + * export IBM_CREDENTIALS_FILE=<name of configuration file> + */ +public class PlatformNotificationsExamples { + private static final Logger logger = LoggerFactory.getLogger(PlatformNotificationsExamples.class); + protected PlatformNotificationsExamples() { } + + static { + System.setProperty("IBM_CREDENTIALS_FILE", "../../platform_notifications_v1.env"); + } + + /** + * The main() function invokes operations of the Platform Notifications service. + * @param args command-line arguments + * @throws Exception an error occurred + */ + @SuppressWarnings("checkstyle:methodlength") + public static void main(String[] args) throws Exception { + PlatformNotifications platformNotificationsService = PlatformNotifications.newInstance(); + + // Load up our test-specific config properties. + Map testConfigProperties = CredentialUtils.getServiceProperties(PlatformNotifications.DEFAULT_SERVICE_NAME); + + // Load test data from config + String accountId = testConfigProperties.get("ACCOUNT_ID"); + String destinationId = testConfigProperties.get("DESTINATION_ID"); + String iamId = testConfigProperties.get("IAM_ID"); + + try { + System.out.println("listNotifications() result:"); + // begin-list_notifications + ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder() + .accountId(accountId) + .limit(Long.valueOf("50")) + .build(); + + NotificationsPager pager = new NotificationsPager(platformNotificationsService, listNotificationsOptions); + List allResults = new ArrayList<>(); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + allResults.addAll(nextPage); + } + + System.out.println(GsonSingleton.getGson().toJson(allResults)); + // end-list_notifications + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getAcknowledgement() result:"); + // begin-get_acknowledgement + GetAcknowledgementOptions getAcknowledgementOptions = new GetAcknowledgementOptions.Builder() + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.getAcknowledgement(getAcknowledgementOptions).execute(); + Acknowledgement acknowledgement = response.getResult(); + + System.out.println(acknowledgement); + // end-get_acknowledgement + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("replaceNotificationAcknowledgement() result:"); + // begin-replace_notification_acknowledgement + ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions = new ReplaceNotificationAcknowledgementOptions.Builder() + .lastAcknowledged(Long.valueOf("1772804159452")) + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.replaceNotificationAcknowledgement(replaceNotificationAcknowledgementOptions).execute(); + Acknowledgement acknowledgement = response.getResult(); + + System.out.println(acknowledgement); + // end-replace_notification_acknowledgement + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("listDistributionListDestinations() result:"); + // begin-list_distribution_list_destinations + ListDistributionListDestinationsOptions listDistributionListDestinationsOptions = new ListDistributionListDestinationsOptions.Builder() + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.listDistributionListDestinations(listDistributionListDestinationsOptions).execute(); + AddDestinationCollection addDestinationCollection = response.getResult(); + + System.out.println(addDestinationCollection); + // end-list_distribution_list_destinations + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("createDistributionListDestination() result:"); + // begin-create_distribution_list_destination + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeModel = new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder() + .destinationId(destinationId) + .destinationType("event_notifications") + .build(); + CreateDistributionListDestinationOptions createDistributionListDestinationOptions = new CreateDistributionListDestinationOptions.Builder() + .accountId(accountId) + .addDestinationPrototype(addDestinationPrototypeModel) + .build(); + + Response response = platformNotificationsService.createDistributionListDestination(createDistributionListDestinationOptions).execute(); + AddDestination addDestination = response.getResult(); + + System.out.println(addDestination); + // end-create_distribution_list_destination + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getDistributionListDestination() result:"); + // begin-get_distribution_list_destination + GetDistributionListDestinationOptions getDistributionListDestinationOptions = new GetDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .build(); + + Response response = platformNotificationsService.getDistributionListDestination(getDistributionListDestinationOptions).execute(); + AddDestination addDestination = response.getResult(); + + System.out.println(addDestination); + // end-get_distribution_list_destination + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("testDistributionListDestination() result:"); + // begin-test_distribution_list_destination + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder() + .destinationType("event_notifications") + .notificationType("incident") + .build(); + TestDistributionListDestinationOptions testDistributionListDestinationOptions = new TestDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .testDestinationRequestBodyPrototype(testDestinationRequestBodyPrototypeModel) + .build(); + + Response response = platformNotificationsService.testDistributionListDestination(testDistributionListDestinationOptions).execute(); + TestDestinationResponseBody testDestinationResponseBody = response.getResult(); + + System.out.println(testDestinationResponseBody); + // end-test_distribution_list_destination + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("createPreferences() result:"); + // begin-create_preferences + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + CreatePreferencesOptions createPreferencesOptions = new CreatePreferencesOptions.Builder() + .iamId(iamId) + .incidentSeverity1(preferenceValueWithUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.createPreferences(createPreferencesOptions).execute(); + PreferencesObject preferencesObject = response.getResult(); + + System.out.println(preferencesObject); + // end-create_preferences + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("getPreferences() result:"); + // begin-get_preferences + GetPreferencesOptions getPreferencesOptions = new GetPreferencesOptions.Builder() + .iamId(iamId) + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.getPreferences(getPreferencesOptions).execute(); + PreferencesObject preferencesObject = response.getResult(); + + System.out.println(preferencesObject); + // end-get_preferences + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + System.out.println("replaceNotificationPreferences() result:"); + // begin-replace_notification_preferences + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptions = new ReplaceNotificationPreferencesOptions.Builder() + .iamId(iamId) + .incidentSeverity1(preferenceValueWithUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.replaceNotificationPreferences(replaceNotificationPreferencesOptions).execute(); + PreferencesObject preferencesObject = response.getResult(); + + System.out.println(preferencesObject); + // end-replace_notification_preferences + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + // begin-delete_distribution_list_destination + DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptions = new DeleteDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .build(); + + Response response = platformNotificationsService.deleteDistributionListDestination(deleteDistributionListDestinationOptions).execute(); + // end-delete_distribution_list_destination + System.out.printf("deleteDistributionListDestination() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + + try { + // begin-delete_notification_preferences + DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptions = new DeleteNotificationPreferencesOptions.Builder() + .iamId(iamId) + .accountId(accountId) + .build(); + + Response response = platformNotificationsService.deleteNotificationPreferences(deleteNotificationPreferencesOptions).execute(); + // end-delete_notification_preferences + System.out.printf("deleteNotificationPreferences() response status code: %d%n", response.getStatusCode()); + } catch (ServiceResponseException e) { + logger.error(String.format("Service returned status code %s: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e); + } + } +} diff --git a/modules/platform-notifications/pom.xml b/modules/platform-notifications/pom.xml new file mode 100644 index 0000000000..06c3c08971 --- /dev/null +++ b/modules/platform-notifications/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + + + + platform-services + com.ibm.cloud + 99-SNAPSHOT + ../.. + + + + platform-notifications + + + IBM Cloud Platform Notifications + jar + + + + com.ibm.cloud + sdk-core + + + + platform-services-common + com.ibm.cloud + + + + platform-services-common + ${project.groupId} + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + + + + IBM Cloud DevX SDK Development + devxsdk@us.ibm.com + https://www.ibm.com/ + + + + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotifications.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotifications.java new file mode 100644 index 0000000000..2bc020f8de --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotifications.java @@ -0,0 +1,598 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.108.0-56772134-20251111-102802 + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1; + +import com.google.gson.JsonObject; +import com.ibm.cloud.platform_services.common.SdkCommon; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Acknowledgement; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreateDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreatePreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListDistributionListDestinationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListNotificationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferencesObject; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationResponseBody; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDistributionListDestinationOptions; +import com.ibm.cloud.sdk.core.http.RequestBuilder; +import com.ibm.cloud.sdk.core.http.ResponseConverter; +import com.ibm.cloud.sdk.core.http.ServiceCall; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; +import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * API for IBM Cloud account notifications, providing capabilities to: + * - View notifications + * - Get and update acknowledgements + * - Manage user communication preferences + * - Manage notification distribution lists + * . + * + * API Version: 1.0.0 + */ +public class PlatformNotifications extends BaseService { + + /** + * Default service name used when configuring the `PlatformNotifications` client. + */ + public static final String DEFAULT_SERVICE_NAME = "platform_notifications"; + + /** + * Default service endpoint URL. + */ + public static final String DEFAULT_SERVICE_URL = "https://notifications.cloud.ibm.com/api"; + + /** + * Class method which constructs an instance of the `PlatformNotifications` client. + * The default service name is used to configure the client instance. + * + * @return an instance of the `PlatformNotifications` client using external configuration + */ + public static PlatformNotifications newInstance() { + return newInstance(DEFAULT_SERVICE_NAME); + } + + /** + * Class method which constructs an instance of the `PlatformNotifications` client. + * The specified service name is used to configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + * @return an instance of the `PlatformNotifications` client using external configuration + */ + public static PlatformNotifications newInstance(String serviceName) { + Authenticator authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName); + PlatformNotifications service = new PlatformNotifications(serviceName, authenticator); + service.configureService(serviceName); + return service; + } + + /** + * Constructs an instance of the `PlatformNotifications` client. + * The specified service name and authenticator are used to configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client + */ + public PlatformNotifications(String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + } + + /** + * Get user notifications. + * + * Retrieve all notifications for the requested user. + * + * @param listNotificationsOptions the {@link ListNotificationsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link NotificationCollection} + */ + public ServiceCall listNotifications(ListNotificationsOptions listNotificationsOptions) { + if (listNotificationsOptions == null) { + listNotificationsOptions = new ListNotificationsOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications")); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "listNotifications"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (listNotificationsOptions.accountId() != null) { + builder.query("account_id", String.valueOf(listNotificationsOptions.accountId())); + } + if (listNotificationsOptions.start() != null) { + builder.query("start", String.valueOf(listNotificationsOptions.start())); + } + if (listNotificationsOptions.limit() != null) { + builder.query("limit", String.valueOf(listNotificationsOptions.limit())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get user notifications. + * + * Retrieve all notifications for the requested user. + * + * @return a {@link ServiceCall} with a result of type {@link NotificationCollection} + */ + public ServiceCall listNotifications() { + return listNotifications(null); + } + + /** + * Get acknowledgement. + * + * Retrieve the ID of the last notification acknowledged by the user for a specific account. + * + * @param getAcknowledgementOptions the {@link GetAcknowledgementOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Acknowledgement} + */ + public ServiceCall getAcknowledgement(GetAcknowledgementOptions getAcknowledgementOptions) { + if (getAcknowledgementOptions == null) { + getAcknowledgementOptions = new GetAcknowledgementOptions.Builder().build(); + } + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/acknowledgement")); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "getAcknowledgement"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (getAcknowledgementOptions.accountId() != null) { + builder.query("account_id", String.valueOf(getAcknowledgementOptions.accountId())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get acknowledgement. + * + * Retrieve the ID of the last notification acknowledged by the user for a specific account. + * + * @return a {@link ServiceCall} with a result of type {@link Acknowledgement} + */ + public ServiceCall getAcknowledgement() { + return getAcknowledgement(null); + } + + /** + * Update acknowledgement. + * + * Update the ID of the last notification acknowledged by the user for a specific account. + * + * @param replaceNotificationAcknowledgementOptions the {@link ReplaceNotificationAcknowledgementOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link Acknowledgement} + */ + public ServiceCall replaceNotificationAcknowledgement(ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(replaceNotificationAcknowledgementOptions, + "replaceNotificationAcknowledgementOptions cannot be null"); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/acknowledgement")); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "replaceNotificationAcknowledgement"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (replaceNotificationAcknowledgementOptions.accountId() != null) { + builder.query("account_id", String.valueOf(replaceNotificationAcknowledgementOptions.accountId())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("last_acknowledged", replaceNotificationAcknowledgementOptions.lastAcknowledged()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get all destination entries. + * + * Retrieve all destinations in the distribution list for the specified account. + * + * @param listDistributionListDestinationsOptions the {@link ListDistributionListDestinationsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link AddDestinationCollection} + */ + public ServiceCall listDistributionListDestinations(ListDistributionListDestinationsOptions listDistributionListDestinationsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(listDistributionListDestinationsOptions, + "listDistributionListDestinationsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("account_id", listDistributionListDestinationsOptions.accountId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/distribution_lists/{account_id}/destinations", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "listDistributionListDestinations"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Add a destination entry. + * + * Add a destination entry to the distribution list. A maximum of 10 destination entries per destination type. In + * terms of enterprise accounts, you can provide an Event Notifications destination that is from a different account + * than the distribution list account, provided these two accounts are from the same enterprise and the user has + * permission to manage the Event Notifications destinations on both accounts. + * + * @param createDistributionListDestinationOptions the {@link CreateDistributionListDestinationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link AddDestination} + */ + public ServiceCall createDistributionListDestination(CreateDistributionListDestinationOptions createDistributionListDestinationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createDistributionListDestinationOptions, + "createDistributionListDestinationOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("account_id", createDistributionListDestinationOptions.accountId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/distribution_lists/{account_id}/destinations", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "createDistributionListDestination"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(createDistributionListDestinationOptions.addDestinationPrototype()), "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a destination entry. + * + * Retrieve a specific destination from the distribution list of the account. + * + * @param getDistributionListDestinationOptions the {@link GetDistributionListDestinationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link AddDestination} + */ + public ServiceCall getDistributionListDestination(GetDistributionListDestinationOptions getDistributionListDestinationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getDistributionListDestinationOptions, + "getDistributionListDestinationOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("account_id", getDistributionListDestinationOptions.accountId()); + pathParamsMap.put("destination_id", getDistributionListDestinationOptions.destinationId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/distribution_lists/{account_id}/destinations/{destination_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "getDistributionListDestination"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a destination entry. + * + * Remove a destination entry. + * + * @param deleteDistributionListDestinationOptions the {@link DeleteDistributionListDestinationOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteDistributionListDestination(DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDistributionListDestinationOptions, + "deleteDistributionListDestinationOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("account_id", deleteDistributionListDestinationOptions.accountId()); + pathParamsMap.put("destination_id", deleteDistributionListDestinationOptions.destinationId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/distribution_lists/{account_id}/destinations/{destination_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "deleteDistributionListDestination"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Test a destination entry. + * + * Send a test notification to a destination in the distribution list. This allows you to verify that the destination + * is properly configured and can receive notifications. + * + * @param testDistributionListDestinationOptions the {@link TestDistributionListDestinationOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link TestDestinationResponseBody} + */ + public ServiceCall testDistributionListDestination(TestDistributionListDestinationOptions testDistributionListDestinationOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(testDistributionListDestinationOptions, + "testDistributionListDestinationOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("account_id", testDistributionListDestinationOptions.accountId()); + pathParamsMap.put("destination_id", testDistributionListDestinationOptions.destinationId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/distribution_lists/{account_id}/destinations/{destination_id}/test", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "testDistributionListDestination"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.bodyContent(com.ibm.cloud.sdk.core.util.GsonSingleton.getGsonWithoutPrettyPrinting().toJson(testDistributionListDestinationOptions.testDestinationRequestBodyPrototype()), "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get all communication preferences. + * + * Retrieve all communication preferences of a user in an account. + * + * @param getPreferencesOptions the {@link GetPreferencesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PreferencesObject} + */ + public ServiceCall getPreferences(GetPreferencesOptions getPreferencesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getPreferencesOptions, + "getPreferencesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("iam_id", getPreferencesOptions.iamId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/{iam_id}/preferences", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "getPreferences"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (getPreferencesOptions.accountId() != null) { + builder.query("account_id", String.valueOf(getPreferencesOptions.accountId())); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create communication preferences. + * + * Create communication preferences for the specified account. + * + * @param createPreferencesOptions the {@link CreatePreferencesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PreferencesObject} + */ + public ServiceCall createPreferences(CreatePreferencesOptions createPreferencesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createPreferencesOptions, + "createPreferencesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("iam_id", createPreferencesOptions.iamId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/{iam_id}/preferences", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "createPreferences"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (createPreferencesOptions.accountId() != null) { + builder.query("account_id", String.valueOf(createPreferencesOptions.accountId())); + } + final JsonObject contentJson = new JsonObject(); + if (createPreferencesOptions.incidentSeverity1() != null) { + contentJson.add("incident_severity1", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.incidentSeverity1())); + } + if (createPreferencesOptions.incidentSeverity2() != null) { + contentJson.add("incident_severity2", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.incidentSeverity2())); + } + if (createPreferencesOptions.incidentSeverity3() != null) { + contentJson.add("incident_severity3", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.incidentSeverity3())); + } + if (createPreferencesOptions.incidentSeverity4() != null) { + contentJson.add("incident_severity4", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.incidentSeverity4())); + } + if (createPreferencesOptions.maintenanceHigh() != null) { + contentJson.add("maintenance_high", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.maintenanceHigh())); + } + if (createPreferencesOptions.maintenanceMedium() != null) { + contentJson.add("maintenance_medium", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.maintenanceMedium())); + } + if (createPreferencesOptions.maintenanceLow() != null) { + contentJson.add("maintenance_low", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.maintenanceLow())); + } + if (createPreferencesOptions.announcementsMajor() != null) { + contentJson.add("announcements_major", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.announcementsMajor())); + } + if (createPreferencesOptions.announcementsMinor() != null) { + contentJson.add("announcements_minor", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.announcementsMinor())); + } + if (createPreferencesOptions.securityNormal() != null) { + contentJson.add("security_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.securityNormal())); + } + if (createPreferencesOptions.accountNormal() != null) { + contentJson.add("account_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.accountNormal())); + } + if (createPreferencesOptions.billingAndUsageOrder() != null) { + contentJson.add("billing_and_usage_order", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.billingAndUsageOrder())); + } + if (createPreferencesOptions.billingAndUsageInvoices() != null) { + contentJson.add("billing_and_usage_invoices", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.billingAndUsageInvoices())); + } + if (createPreferencesOptions.billingAndUsagePayments() != null) { + contentJson.add("billing_and_usage_payments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.billingAndUsagePayments())); + } + if (createPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes() != null) { + contentJson.add("billing_and_usage_subscriptions_and_promo_codes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes())); + } + if (createPreferencesOptions.billingAndUsageSpendingAlerts() != null) { + contentJson.add("billing_and_usage_spending_alerts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.billingAndUsageSpendingAlerts())); + } + if (createPreferencesOptions.resourceactivityNormal() != null) { + contentJson.add("resourceactivity_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.resourceactivityNormal())); + } + if (createPreferencesOptions.orderingReview() != null) { + contentJson.add("ordering_review", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.orderingReview())); + } + if (createPreferencesOptions.orderingApproved() != null) { + contentJson.add("ordering_approved", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.orderingApproved())); + } + if (createPreferencesOptions.orderingApprovedVsi() != null) { + contentJson.add("ordering_approved_vsi", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.orderingApprovedVsi())); + } + if (createPreferencesOptions.orderingApprovedServer() != null) { + contentJson.add("ordering_approved_server", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.orderingApprovedServer())); + } + if (createPreferencesOptions.provisioningReloadComplete() != null) { + contentJson.add("provisioning_reload_complete", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.provisioningReloadComplete())); + } + if (createPreferencesOptions.provisioningCompleteVsi() != null) { + contentJson.add("provisioning_complete_vsi", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.provisioningCompleteVsi())); + } + if (createPreferencesOptions.provisioningCompleteServer() != null) { + contentJson.add("provisioning_complete_server", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createPreferencesOptions.provisioningCompleteServer())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update communication preferences. + * + * Update communication preferences for the specified account. + * + * @param replaceNotificationPreferencesOptions the {@link ReplaceNotificationPreferencesOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link PreferencesObject} + */ + public ServiceCall replaceNotificationPreferences(ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(replaceNotificationPreferencesOptions, + "replaceNotificationPreferencesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("iam_id", replaceNotificationPreferencesOptions.iamId()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/{iam_id}/preferences", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "replaceNotificationPreferences"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (replaceNotificationPreferencesOptions.accountId() != null) { + builder.query("account_id", String.valueOf(replaceNotificationPreferencesOptions.accountId())); + } + final JsonObject contentJson = new JsonObject(); + if (replaceNotificationPreferencesOptions.incidentSeverity1() != null) { + contentJson.add("incident_severity1", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.incidentSeverity1())); + } + if (replaceNotificationPreferencesOptions.incidentSeverity2() != null) { + contentJson.add("incident_severity2", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.incidentSeverity2())); + } + if (replaceNotificationPreferencesOptions.incidentSeverity3() != null) { + contentJson.add("incident_severity3", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.incidentSeverity3())); + } + if (replaceNotificationPreferencesOptions.incidentSeverity4() != null) { + contentJson.add("incident_severity4", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.incidentSeverity4())); + } + if (replaceNotificationPreferencesOptions.maintenanceHigh() != null) { + contentJson.add("maintenance_high", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.maintenanceHigh())); + } + if (replaceNotificationPreferencesOptions.maintenanceMedium() != null) { + contentJson.add("maintenance_medium", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.maintenanceMedium())); + } + if (replaceNotificationPreferencesOptions.maintenanceLow() != null) { + contentJson.add("maintenance_low", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.maintenanceLow())); + } + if (replaceNotificationPreferencesOptions.announcementsMajor() != null) { + contentJson.add("announcements_major", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.announcementsMajor())); + } + if (replaceNotificationPreferencesOptions.announcementsMinor() != null) { + contentJson.add("announcements_minor", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.announcementsMinor())); + } + if (replaceNotificationPreferencesOptions.securityNormal() != null) { + contentJson.add("security_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.securityNormal())); + } + if (replaceNotificationPreferencesOptions.accountNormal() != null) { + contentJson.add("account_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.accountNormal())); + } + if (replaceNotificationPreferencesOptions.billingAndUsageOrder() != null) { + contentJson.add("billing_and_usage_order", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.billingAndUsageOrder())); + } + if (replaceNotificationPreferencesOptions.billingAndUsageInvoices() != null) { + contentJson.add("billing_and_usage_invoices", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.billingAndUsageInvoices())); + } + if (replaceNotificationPreferencesOptions.billingAndUsagePayments() != null) { + contentJson.add("billing_and_usage_payments", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.billingAndUsagePayments())); + } + if (replaceNotificationPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes() != null) { + contentJson.add("billing_and_usage_subscriptions_and_promo_codes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes())); + } + if (replaceNotificationPreferencesOptions.billingAndUsageSpendingAlerts() != null) { + contentJson.add("billing_and_usage_spending_alerts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.billingAndUsageSpendingAlerts())); + } + if (replaceNotificationPreferencesOptions.resourceactivityNormal() != null) { + contentJson.add("resourceactivity_normal", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.resourceactivityNormal())); + } + if (replaceNotificationPreferencesOptions.orderingReview() != null) { + contentJson.add("ordering_review", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.orderingReview())); + } + if (replaceNotificationPreferencesOptions.orderingApproved() != null) { + contentJson.add("ordering_approved", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.orderingApproved())); + } + if (replaceNotificationPreferencesOptions.orderingApprovedVsi() != null) { + contentJson.add("ordering_approved_vsi", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.orderingApprovedVsi())); + } + if (replaceNotificationPreferencesOptions.orderingApprovedServer() != null) { + contentJson.add("ordering_approved_server", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.orderingApprovedServer())); + } + if (replaceNotificationPreferencesOptions.provisioningReloadComplete() != null) { + contentJson.add("provisioning_reload_complete", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.provisioningReloadComplete())); + } + if (replaceNotificationPreferencesOptions.provisioningCompleteVsi() != null) { + contentJson.add("provisioning_complete_vsi", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.provisioningCompleteVsi())); + } + if (replaceNotificationPreferencesOptions.provisioningCompleteServer() != null) { + contentJson.add("provisioning_complete_server", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(replaceNotificationPreferencesOptions.provisioningCompleteServer())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Reset all preferences to their default values. + * + * Delete all communication preferences for the specified account, and reset all preferences to their default values. + * + * @param deleteNotificationPreferencesOptions the {@link DeleteNotificationPreferencesOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteNotificationPreferences(DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteNotificationPreferencesOptions, + "deleteNotificationPreferencesOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("iam_id", deleteNotificationPreferencesOptions.iamId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/notifications/{iam_id}/preferences", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("platform_notifications", "v1", "deleteNotificationPreferences"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + if (deleteNotificationPreferencesOptions.accountId() != null) { + builder.query("account_id", String.valueOf(deleteNotificationPreferencesOptions.accountId())); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + +} diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Acknowledgement.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Acknowledgement.java new file mode 100644 index 0000000000..a42124c2e0 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Acknowledgement.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Status indicating whether the user has unread notifications. + */ +public class Acknowledgement extends GenericModel { + + @SerializedName("has_unread") + protected Boolean hasUnread; + @SerializedName("last_acknowledged") + protected Long lastAcknowledged; + + protected Acknowledgement() { } + + /** + * Gets the hasUnread. + * + * Indicates whether the user has unread notifications. + * + * @return the hasUnread + */ + public Boolean isHasUnread() { + return hasUnread; + } + + /** + * Gets the lastAcknowledged. + * + * The timestamp of the last acknowledgement. + * + * @return the lastAcknowledged + */ + public Long getLastAcknowledged() { + return lastAcknowledged; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestination.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestination.java new file mode 100644 index 0000000000..a17a498207 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestination.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * AddDestination. + * + * Classes which extend this class: + * - AddDestinationEventNotificationDestination + */ +public class AddDestination extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "destination_type"; + protected static java.util.Map> discriminatorMapping; + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put("event_notifications", AddDestinationEventNotificationDestination.class); + } + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + @SerializedName("destination_id") + protected String destinationId; + @SerializedName("destination_type") + protected String destinationType; + + protected AddDestination() { } + + /** + * Gets the destinationId. + * + * The GUID of the Event Notifications instance. + * + * @return the destinationId + */ + public String getDestinationId() { + return destinationId; + } + + /** + * Gets the destinationType. + * + * The type of the destination. + * + * @return the destinationType + */ + public String getDestinationType() { + return destinationType; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollection.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollection.java new file mode 100644 index 0000000000..c2ec369e05 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollection.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * List of destinations in the distribution list. + */ +public class AddDestinationCollection extends GenericModel { + + protected List destinations; + + protected AddDestinationCollection() { } + + /** + * Gets the destinations. + * + * Array of destination entries. + * + * @return the destinations + */ + public List getDestinations() { + return destinations; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestination.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestination.java new file mode 100644 index 0000000000..a56052a9e7 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestination.java @@ -0,0 +1,32 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +/** + * An Event Notifications destination entry in the distribution list. + */ +public class AddDestinationEventNotificationDestination extends AddDestination { + + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + + protected AddDestinationEventNotificationDestination() { } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototype.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototype.java new file mode 100644 index 0000000000..3127ea3723 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototype.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * AddDestinationPrototype. + * + * Classes which extend this class: + * - AddDestinationPrototypeEventNotificationDestinationPrototype + */ +public class AddDestinationPrototype extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "destination_type"; + protected static java.util.Map> discriminatorMapping; + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put("event_notifications", AddDestinationPrototypeEventNotificationDestinationPrototype.class); + } + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + @SerializedName("destination_id") + protected String destinationId; + @SerializedName("destination_type") + protected String destinationType; + + protected AddDestinationPrototype() { } + + /** + * Gets the destinationId. + * + * The GUID of the Event Notifications instance. + * + * @return the destinationId + */ + public String destinationId() { + return destinationId; + } + + /** + * Gets the destinationType. + * + * The type of the destination. + * + * @return the destinationType + */ + public String destinationType() { + return destinationType; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototype.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototype.java new file mode 100644 index 0000000000..641b6c262a --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototype.java @@ -0,0 +1,116 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +/** + * Prototype for creating an Event Notifications destination entry. + */ +public class AddDestinationPrototypeEventNotificationDestinationPrototype extends AddDestinationPrototype { + + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + + /** + * Builder. + */ + public static class Builder { + private String destinationId; + private String destinationType; + + /** + * Instantiates a new Builder from an existing AddDestinationPrototypeEventNotificationDestinationPrototype instance. + * + * @param addDestinationPrototypeEventNotificationDestinationPrototype the instance to initialize the Builder with + */ + public Builder(AddDestinationPrototype addDestinationPrototypeEventNotificationDestinationPrototype) { + this.destinationId = addDestinationPrototypeEventNotificationDestinationPrototype.destinationId; + this.destinationType = addDestinationPrototypeEventNotificationDestinationPrototype.destinationType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param destinationId the destinationId + * @param destinationType the destinationType + */ + public Builder(String destinationId, String destinationType) { + this.destinationId = destinationId; + this.destinationType = destinationType; + } + + /** + * Builds a AddDestinationPrototypeEventNotificationDestinationPrototype. + * + * @return the new AddDestinationPrototypeEventNotificationDestinationPrototype instance + */ + public AddDestinationPrototypeEventNotificationDestinationPrototype build() { + return new AddDestinationPrototypeEventNotificationDestinationPrototype(this); + } + + /** + * Set the destinationId. + * + * @param destinationId the destinationId + * @return the AddDestinationPrototypeEventNotificationDestinationPrototype builder + */ + public Builder destinationId(String destinationId) { + this.destinationId = destinationId; + return this; + } + + /** + * Set the destinationType. + * + * @param destinationType the destinationType + * @return the AddDestinationPrototypeEventNotificationDestinationPrototype builder + */ + public Builder destinationType(String destinationType) { + this.destinationType = destinationType; + return this; + } + } + + protected AddDestinationPrototypeEventNotificationDestinationPrototype() { } + + protected AddDestinationPrototypeEventNotificationDestinationPrototype(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.destinationId, + "destinationId cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.destinationType, + "destinationType cannot be null"); + destinationId = builder.destinationId; + destinationType = builder.destinationType; + } + + /** + * New builder. + * + * @return a AddDestinationPrototypeEventNotificationDestinationPrototype builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptions.java new file mode 100644 index 0000000000..54dc00e246 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptions.java @@ -0,0 +1,132 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createDistributionListDestination options. + */ +public class CreateDistributionListDestinationOptions extends GenericModel { + + protected String accountId; + protected AddDestinationPrototype addDestinationPrototype; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private AddDestinationPrototype addDestinationPrototype; + + /** + * Instantiates a new Builder from an existing CreateDistributionListDestinationOptions instance. + * + * @param createDistributionListDestinationOptions the instance to initialize the Builder with + */ + private Builder(CreateDistributionListDestinationOptions createDistributionListDestinationOptions) { + this.accountId = createDistributionListDestinationOptions.accountId; + this.addDestinationPrototype = createDistributionListDestinationOptions.addDestinationPrototype; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param addDestinationPrototype the addDestinationPrototype + */ + public Builder(String accountId, AddDestinationPrototype addDestinationPrototype) { + this.accountId = accountId; + this.addDestinationPrototype = addDestinationPrototype; + } + + /** + * Builds a CreateDistributionListDestinationOptions. + * + * @return the new CreateDistributionListDestinationOptions instance + */ + public CreateDistributionListDestinationOptions build() { + return new CreateDistributionListDestinationOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the CreateDistributionListDestinationOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the addDestinationPrototype. + * + * @param addDestinationPrototype the addDestinationPrototype + * @return the CreateDistributionListDestinationOptions builder + */ + public Builder addDestinationPrototype(AddDestinationPrototype addDestinationPrototype) { + this.addDestinationPrototype = addDestinationPrototype; + return this; + } + } + + protected CreateDistributionListDestinationOptions() { } + + protected CreateDistributionListDestinationOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.addDestinationPrototype, + "addDestinationPrototype cannot be null"); + accountId = builder.accountId; + addDestinationPrototype = builder.addDestinationPrototype; + } + + /** + * New builder. + * + * @return a CreateDistributionListDestinationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the addDestinationPrototype. + * + * @return the addDestinationPrototype + */ + public AddDestinationPrototype addDestinationPrototype() { + return addDestinationPrototype; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptions.java new file mode 100644 index 0000000000..b1371bd8d4 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptions.java @@ -0,0 +1,788 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createPreferences options. + */ +public class CreatePreferencesOptions extends GenericModel { + + protected String iamId; + protected PreferenceValueWithUpdates incidentSeverity1; + protected PreferenceValueWithUpdates incidentSeverity2; + protected PreferenceValueWithUpdates incidentSeverity3; + protected PreferenceValueWithUpdates incidentSeverity4; + protected PreferenceValueWithUpdates maintenanceHigh; + protected PreferenceValueWithUpdates maintenanceMedium; + protected PreferenceValueWithUpdates maintenanceLow; + protected PreferenceValueWithoutUpdates announcementsMajor; + protected PreferenceValueWithoutUpdates announcementsMinor; + protected PreferenceValueWithoutUpdates securityNormal; + protected PreferenceValueWithoutUpdates accountNormal; + protected PreferenceValueWithoutUpdates billingAndUsageOrder; + protected PreferenceValueWithoutUpdates billingAndUsageInvoices; + protected PreferenceValueWithoutUpdates billingAndUsagePayments; + protected PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + protected PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + protected PreferenceValueWithoutUpdates resourceactivityNormal; + protected PreferenceValueWithoutUpdates orderingReview; + protected PreferenceValueWithoutUpdates orderingApproved; + protected PreferenceValueWithoutUpdates orderingApprovedVsi; + protected PreferenceValueWithoutUpdates orderingApprovedServer; + protected PreferenceValueWithoutUpdates provisioningReloadComplete; + protected PreferenceValueWithoutUpdates provisioningCompleteVsi; + protected PreferenceValueWithoutUpdates provisioningCompleteServer; + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String iamId; + private PreferenceValueWithUpdates incidentSeverity1; + private PreferenceValueWithUpdates incidentSeverity2; + private PreferenceValueWithUpdates incidentSeverity3; + private PreferenceValueWithUpdates incidentSeverity4; + private PreferenceValueWithUpdates maintenanceHigh; + private PreferenceValueWithUpdates maintenanceMedium; + private PreferenceValueWithUpdates maintenanceLow; + private PreferenceValueWithoutUpdates announcementsMajor; + private PreferenceValueWithoutUpdates announcementsMinor; + private PreferenceValueWithoutUpdates securityNormal; + private PreferenceValueWithoutUpdates accountNormal; + private PreferenceValueWithoutUpdates billingAndUsageOrder; + private PreferenceValueWithoutUpdates billingAndUsageInvoices; + private PreferenceValueWithoutUpdates billingAndUsagePayments; + private PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + private PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + private PreferenceValueWithoutUpdates resourceactivityNormal; + private PreferenceValueWithoutUpdates orderingReview; + private PreferenceValueWithoutUpdates orderingApproved; + private PreferenceValueWithoutUpdates orderingApprovedVsi; + private PreferenceValueWithoutUpdates orderingApprovedServer; + private PreferenceValueWithoutUpdates provisioningReloadComplete; + private PreferenceValueWithoutUpdates provisioningCompleteVsi; + private PreferenceValueWithoutUpdates provisioningCompleteServer; + private String accountId; + + /** + * Instantiates a new Builder from an existing CreatePreferencesOptions instance. + * + * @param createPreferencesOptions the instance to initialize the Builder with + */ + private Builder(CreatePreferencesOptions createPreferencesOptions) { + this.iamId = createPreferencesOptions.iamId; + this.incidentSeverity1 = createPreferencesOptions.incidentSeverity1; + this.incidentSeverity2 = createPreferencesOptions.incidentSeverity2; + this.incidentSeverity3 = createPreferencesOptions.incidentSeverity3; + this.incidentSeverity4 = createPreferencesOptions.incidentSeverity4; + this.maintenanceHigh = createPreferencesOptions.maintenanceHigh; + this.maintenanceMedium = createPreferencesOptions.maintenanceMedium; + this.maintenanceLow = createPreferencesOptions.maintenanceLow; + this.announcementsMajor = createPreferencesOptions.announcementsMajor; + this.announcementsMinor = createPreferencesOptions.announcementsMinor; + this.securityNormal = createPreferencesOptions.securityNormal; + this.accountNormal = createPreferencesOptions.accountNormal; + this.billingAndUsageOrder = createPreferencesOptions.billingAndUsageOrder; + this.billingAndUsageInvoices = createPreferencesOptions.billingAndUsageInvoices; + this.billingAndUsagePayments = createPreferencesOptions.billingAndUsagePayments; + this.billingAndUsageSubscriptionsAndPromoCodes = createPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes; + this.billingAndUsageSpendingAlerts = createPreferencesOptions.billingAndUsageSpendingAlerts; + this.resourceactivityNormal = createPreferencesOptions.resourceactivityNormal; + this.orderingReview = createPreferencesOptions.orderingReview; + this.orderingApproved = createPreferencesOptions.orderingApproved; + this.orderingApprovedVsi = createPreferencesOptions.orderingApprovedVsi; + this.orderingApprovedServer = createPreferencesOptions.orderingApprovedServer; + this.provisioningReloadComplete = createPreferencesOptions.provisioningReloadComplete; + this.provisioningCompleteVsi = createPreferencesOptions.provisioningCompleteVsi; + this.provisioningCompleteServer = createPreferencesOptions.provisioningCompleteServer; + this.accountId = createPreferencesOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param iamId the iamId + */ + public Builder(String iamId) { + this.iamId = iamId; + } + + /** + * Builds a CreatePreferencesOptions. + * + * @return the new CreatePreferencesOptions instance + */ + public CreatePreferencesOptions build() { + return new CreatePreferencesOptions(this); + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the CreatePreferencesOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the incidentSeverity1. + * + * @param incidentSeverity1 the incidentSeverity1 + * @return the CreatePreferencesOptions builder + */ + public Builder incidentSeverity1(PreferenceValueWithUpdates incidentSeverity1) { + this.incidentSeverity1 = incidentSeverity1; + return this; + } + + /** + * Set the incidentSeverity2. + * + * @param incidentSeverity2 the incidentSeverity2 + * @return the CreatePreferencesOptions builder + */ + public Builder incidentSeverity2(PreferenceValueWithUpdates incidentSeverity2) { + this.incidentSeverity2 = incidentSeverity2; + return this; + } + + /** + * Set the incidentSeverity3. + * + * @param incidentSeverity3 the incidentSeverity3 + * @return the CreatePreferencesOptions builder + */ + public Builder incidentSeverity3(PreferenceValueWithUpdates incidentSeverity3) { + this.incidentSeverity3 = incidentSeverity3; + return this; + } + + /** + * Set the incidentSeverity4. + * + * @param incidentSeverity4 the incidentSeverity4 + * @return the CreatePreferencesOptions builder + */ + public Builder incidentSeverity4(PreferenceValueWithUpdates incidentSeverity4) { + this.incidentSeverity4 = incidentSeverity4; + return this; + } + + /** + * Set the maintenanceHigh. + * + * @param maintenanceHigh the maintenanceHigh + * @return the CreatePreferencesOptions builder + */ + public Builder maintenanceHigh(PreferenceValueWithUpdates maintenanceHigh) { + this.maintenanceHigh = maintenanceHigh; + return this; + } + + /** + * Set the maintenanceMedium. + * + * @param maintenanceMedium the maintenanceMedium + * @return the CreatePreferencesOptions builder + */ + public Builder maintenanceMedium(PreferenceValueWithUpdates maintenanceMedium) { + this.maintenanceMedium = maintenanceMedium; + return this; + } + + /** + * Set the maintenanceLow. + * + * @param maintenanceLow the maintenanceLow + * @return the CreatePreferencesOptions builder + */ + public Builder maintenanceLow(PreferenceValueWithUpdates maintenanceLow) { + this.maintenanceLow = maintenanceLow; + return this; + } + + /** + * Set the announcementsMajor. + * + * @param announcementsMajor the announcementsMajor + * @return the CreatePreferencesOptions builder + */ + public Builder announcementsMajor(PreferenceValueWithoutUpdates announcementsMajor) { + this.announcementsMajor = announcementsMajor; + return this; + } + + /** + * Set the announcementsMinor. + * + * @param announcementsMinor the announcementsMinor + * @return the CreatePreferencesOptions builder + */ + public Builder announcementsMinor(PreferenceValueWithoutUpdates announcementsMinor) { + this.announcementsMinor = announcementsMinor; + return this; + } + + /** + * Set the securityNormal. + * + * @param securityNormal the securityNormal + * @return the CreatePreferencesOptions builder + */ + public Builder securityNormal(PreferenceValueWithoutUpdates securityNormal) { + this.securityNormal = securityNormal; + return this; + } + + /** + * Set the accountNormal. + * + * @param accountNormal the accountNormal + * @return the CreatePreferencesOptions builder + */ + public Builder accountNormal(PreferenceValueWithoutUpdates accountNormal) { + this.accountNormal = accountNormal; + return this; + } + + /** + * Set the billingAndUsageOrder. + * + * @param billingAndUsageOrder the billingAndUsageOrder + * @return the CreatePreferencesOptions builder + */ + public Builder billingAndUsageOrder(PreferenceValueWithoutUpdates billingAndUsageOrder) { + this.billingAndUsageOrder = billingAndUsageOrder; + return this; + } + + /** + * Set the billingAndUsageInvoices. + * + * @param billingAndUsageInvoices the billingAndUsageInvoices + * @return the CreatePreferencesOptions builder + */ + public Builder billingAndUsageInvoices(PreferenceValueWithoutUpdates billingAndUsageInvoices) { + this.billingAndUsageInvoices = billingAndUsageInvoices; + return this; + } + + /** + * Set the billingAndUsagePayments. + * + * @param billingAndUsagePayments the billingAndUsagePayments + * @return the CreatePreferencesOptions builder + */ + public Builder billingAndUsagePayments(PreferenceValueWithoutUpdates billingAndUsagePayments) { + this.billingAndUsagePayments = billingAndUsagePayments; + return this; + } + + /** + * Set the billingAndUsageSubscriptionsAndPromoCodes. + * + * @param billingAndUsageSubscriptionsAndPromoCodes the billingAndUsageSubscriptionsAndPromoCodes + * @return the CreatePreferencesOptions builder + */ + public Builder billingAndUsageSubscriptionsAndPromoCodes(PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes) { + this.billingAndUsageSubscriptionsAndPromoCodes = billingAndUsageSubscriptionsAndPromoCodes; + return this; + } + + /** + * Set the billingAndUsageSpendingAlerts. + * + * @param billingAndUsageSpendingAlerts the billingAndUsageSpendingAlerts + * @return the CreatePreferencesOptions builder + */ + public Builder billingAndUsageSpendingAlerts(PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts) { + this.billingAndUsageSpendingAlerts = billingAndUsageSpendingAlerts; + return this; + } + + /** + * Set the resourceactivityNormal. + * + * @param resourceactivityNormal the resourceactivityNormal + * @return the CreatePreferencesOptions builder + */ + public Builder resourceactivityNormal(PreferenceValueWithoutUpdates resourceactivityNormal) { + this.resourceactivityNormal = resourceactivityNormal; + return this; + } + + /** + * Set the orderingReview. + * + * @param orderingReview the orderingReview + * @return the CreatePreferencesOptions builder + */ + public Builder orderingReview(PreferenceValueWithoutUpdates orderingReview) { + this.orderingReview = orderingReview; + return this; + } + + /** + * Set the orderingApproved. + * + * @param orderingApproved the orderingApproved + * @return the CreatePreferencesOptions builder + */ + public Builder orderingApproved(PreferenceValueWithoutUpdates orderingApproved) { + this.orderingApproved = orderingApproved; + return this; + } + + /** + * Set the orderingApprovedVsi. + * + * @param orderingApprovedVsi the orderingApprovedVsi + * @return the CreatePreferencesOptions builder + */ + public Builder orderingApprovedVsi(PreferenceValueWithoutUpdates orderingApprovedVsi) { + this.orderingApprovedVsi = orderingApprovedVsi; + return this; + } + + /** + * Set the orderingApprovedServer. + * + * @param orderingApprovedServer the orderingApprovedServer + * @return the CreatePreferencesOptions builder + */ + public Builder orderingApprovedServer(PreferenceValueWithoutUpdates orderingApprovedServer) { + this.orderingApprovedServer = orderingApprovedServer; + return this; + } + + /** + * Set the provisioningReloadComplete. + * + * @param provisioningReloadComplete the provisioningReloadComplete + * @return the CreatePreferencesOptions builder + */ + public Builder provisioningReloadComplete(PreferenceValueWithoutUpdates provisioningReloadComplete) { + this.provisioningReloadComplete = provisioningReloadComplete; + return this; + } + + /** + * Set the provisioningCompleteVsi. + * + * @param provisioningCompleteVsi the provisioningCompleteVsi + * @return the CreatePreferencesOptions builder + */ + public Builder provisioningCompleteVsi(PreferenceValueWithoutUpdates provisioningCompleteVsi) { + this.provisioningCompleteVsi = provisioningCompleteVsi; + return this; + } + + /** + * Set the provisioningCompleteServer. + * + * @param provisioningCompleteServer the provisioningCompleteServer + * @return the CreatePreferencesOptions builder + */ + public Builder provisioningCompleteServer(PreferenceValueWithoutUpdates provisioningCompleteServer) { + this.provisioningCompleteServer = provisioningCompleteServer; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the CreatePreferencesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the preferencesObject. + * + * @param preferencesObject the preferencesObject + * @return the CreatePreferencesOptions builder + */ + public Builder preferencesObject(PreferencesObject preferencesObject) { + this.incidentSeverity1 = preferencesObject.incidentSeverity1(); + this.incidentSeverity2 = preferencesObject.incidentSeverity2(); + this.incidentSeverity3 = preferencesObject.incidentSeverity3(); + this.incidentSeverity4 = preferencesObject.incidentSeverity4(); + this.maintenanceHigh = preferencesObject.maintenanceHigh(); + this.maintenanceMedium = preferencesObject.maintenanceMedium(); + this.maintenanceLow = preferencesObject.maintenanceLow(); + this.announcementsMajor = preferencesObject.announcementsMajor(); + this.announcementsMinor = preferencesObject.announcementsMinor(); + this.securityNormal = preferencesObject.securityNormal(); + this.accountNormal = preferencesObject.accountNormal(); + this.billingAndUsageOrder = preferencesObject.billingAndUsageOrder(); + this.billingAndUsageInvoices = preferencesObject.billingAndUsageInvoices(); + this.billingAndUsagePayments = preferencesObject.billingAndUsagePayments(); + this.billingAndUsageSubscriptionsAndPromoCodes = preferencesObject.billingAndUsageSubscriptionsAndPromoCodes(); + this.billingAndUsageSpendingAlerts = preferencesObject.billingAndUsageSpendingAlerts(); + this.resourceactivityNormal = preferencesObject.resourceactivityNormal(); + this.orderingReview = preferencesObject.orderingReview(); + this.orderingApproved = preferencesObject.orderingApproved(); + this.orderingApprovedVsi = preferencesObject.orderingApprovedVsi(); + this.orderingApprovedServer = preferencesObject.orderingApprovedServer(); + this.provisioningReloadComplete = preferencesObject.provisioningReloadComplete(); + this.provisioningCompleteVsi = preferencesObject.provisioningCompleteVsi(); + this.provisioningCompleteServer = preferencesObject.provisioningCompleteServer(); + return this; + } + } + + protected CreatePreferencesOptions() { } + + protected CreatePreferencesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + iamId = builder.iamId; + incidentSeverity1 = builder.incidentSeverity1; + incidentSeverity2 = builder.incidentSeverity2; + incidentSeverity3 = builder.incidentSeverity3; + incidentSeverity4 = builder.incidentSeverity4; + maintenanceHigh = builder.maintenanceHigh; + maintenanceMedium = builder.maintenanceMedium; + maintenanceLow = builder.maintenanceLow; + announcementsMajor = builder.announcementsMajor; + announcementsMinor = builder.announcementsMinor; + securityNormal = builder.securityNormal; + accountNormal = builder.accountNormal; + billingAndUsageOrder = builder.billingAndUsageOrder; + billingAndUsageInvoices = builder.billingAndUsageInvoices; + billingAndUsagePayments = builder.billingAndUsagePayments; + billingAndUsageSubscriptionsAndPromoCodes = builder.billingAndUsageSubscriptionsAndPromoCodes; + billingAndUsageSpendingAlerts = builder.billingAndUsageSpendingAlerts; + resourceactivityNormal = builder.resourceactivityNormal; + orderingReview = builder.orderingReview; + orderingApproved = builder.orderingApproved; + orderingApprovedVsi = builder.orderingApprovedVsi; + orderingApprovedServer = builder.orderingApprovedServer; + provisioningReloadComplete = builder.provisioningReloadComplete; + provisioningCompleteVsi = builder.provisioningCompleteVsi; + provisioningCompleteServer = builder.provisioningCompleteServer; + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a CreatePreferencesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the iamId. + * + * The IAM ID of the user. Must match the IAM ID in the bearer token. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the incidentSeverity1. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity1 + */ + public PreferenceValueWithUpdates incidentSeverity1() { + return incidentSeverity1; + } + + /** + * Gets the incidentSeverity2. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity2 + */ + public PreferenceValueWithUpdates incidentSeverity2() { + return incidentSeverity2; + } + + /** + * Gets the incidentSeverity3. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity3 + */ + public PreferenceValueWithUpdates incidentSeverity3() { + return incidentSeverity3; + } + + /** + * Gets the incidentSeverity4. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity4 + */ + public PreferenceValueWithUpdates incidentSeverity4() { + return incidentSeverity4; + } + + /** + * Gets the maintenanceHigh. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceHigh + */ + public PreferenceValueWithUpdates maintenanceHigh() { + return maintenanceHigh; + } + + /** + * Gets the maintenanceMedium. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceMedium + */ + public PreferenceValueWithUpdates maintenanceMedium() { + return maintenanceMedium; + } + + /** + * Gets the maintenanceLow. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceLow + */ + public PreferenceValueWithUpdates maintenanceLow() { + return maintenanceLow; + } + + /** + * Gets the announcementsMajor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMajor + */ + public PreferenceValueWithoutUpdates announcementsMajor() { + return announcementsMajor; + } + + /** + * Gets the announcementsMinor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMinor + */ + public PreferenceValueWithoutUpdates announcementsMinor() { + return announcementsMinor; + } + + /** + * Gets the securityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the securityNormal + */ + public PreferenceValueWithoutUpdates securityNormal() { + return securityNormal; + } + + /** + * Gets the accountNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the accountNormal + */ + public PreferenceValueWithoutUpdates accountNormal() { + return accountNormal; + } + + /** + * Gets the billingAndUsageOrder. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageOrder + */ + public PreferenceValueWithoutUpdates billingAndUsageOrder() { + return billingAndUsageOrder; + } + + /** + * Gets the billingAndUsageInvoices. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageInvoices + */ + public PreferenceValueWithoutUpdates billingAndUsageInvoices() { + return billingAndUsageInvoices; + } + + /** + * Gets the billingAndUsagePayments. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsagePayments + */ + public PreferenceValueWithoutUpdates billingAndUsagePayments() { + return billingAndUsagePayments; + } + + /** + * Gets the billingAndUsageSubscriptionsAndPromoCodes. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSubscriptionsAndPromoCodes + */ + public PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes() { + return billingAndUsageSubscriptionsAndPromoCodes; + } + + /** + * Gets the billingAndUsageSpendingAlerts. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSpendingAlerts + */ + public PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts() { + return billingAndUsageSpendingAlerts; + } + + /** + * Gets the resourceactivityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the resourceactivityNormal + */ + public PreferenceValueWithoutUpdates resourceactivityNormal() { + return resourceactivityNormal; + } + + /** + * Gets the orderingReview. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingReview + */ + public PreferenceValueWithoutUpdates orderingReview() { + return orderingReview; + } + + /** + * Gets the orderingApproved. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApproved + */ + public PreferenceValueWithoutUpdates orderingApproved() { + return orderingApproved; + } + + /** + * Gets the orderingApprovedVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedVsi + */ + public PreferenceValueWithoutUpdates orderingApprovedVsi() { + return orderingApprovedVsi; + } + + /** + * Gets the orderingApprovedServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedServer + */ + public PreferenceValueWithoutUpdates orderingApprovedServer() { + return orderingApprovedServer; + } + + /** + * Gets the provisioningReloadComplete. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningReloadComplete + */ + public PreferenceValueWithoutUpdates provisioningReloadComplete() { + return provisioningReloadComplete; + } + + /** + * Gets the provisioningCompleteVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteVsi + */ + public PreferenceValueWithoutUpdates provisioningCompleteVsi() { + return provisioningCompleteVsi; + } + + /** + * Gets the provisioningCompleteServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteServer + */ + public PreferenceValueWithoutUpdates provisioningCompleteServer() { + return provisioningCompleteServer; + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptions.java new file mode 100644 index 0000000000..836df6bc53 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteDistributionListDestination options. + */ +public class DeleteDistributionListDestinationOptions extends GenericModel { + + protected String accountId; + protected String destinationId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String destinationId; + + /** + * Instantiates a new Builder from an existing DeleteDistributionListDestinationOptions instance. + * + * @param deleteDistributionListDestinationOptions the instance to initialize the Builder with + */ + private Builder(DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptions) { + this.accountId = deleteDistributionListDestinationOptions.accountId; + this.destinationId = deleteDistributionListDestinationOptions.destinationId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param destinationId the destinationId + */ + public Builder(String accountId, String destinationId) { + this.accountId = accountId; + this.destinationId = destinationId; + } + + /** + * Builds a DeleteDistributionListDestinationOptions. + * + * @return the new DeleteDistributionListDestinationOptions instance + */ + public DeleteDistributionListDestinationOptions build() { + return new DeleteDistributionListDestinationOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the DeleteDistributionListDestinationOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the destinationId. + * + * @param destinationId the destinationId + * @return the DeleteDistributionListDestinationOptions builder + */ + public Builder destinationId(String destinationId) { + this.destinationId = destinationId; + return this; + } + } + + protected DeleteDistributionListDestinationOptions() { } + + protected DeleteDistributionListDestinationOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.destinationId, + "destinationId cannot be empty"); + accountId = builder.accountId; + destinationId = builder.destinationId; + } + + /** + * New builder. + * + * @return a DeleteDistributionListDestinationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the destinationId. + * + * The ID of the destination. + * + * @return the destinationId + */ + public String destinationId() { + return destinationId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptions.java new file mode 100644 index 0000000000..98e3da3d9b --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptions.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteNotificationPreferences options. + */ +public class DeleteNotificationPreferencesOptions extends GenericModel { + + protected String iamId; + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String iamId; + private String accountId; + + /** + * Instantiates a new Builder from an existing DeleteNotificationPreferencesOptions instance. + * + * @param deleteNotificationPreferencesOptions the instance to initialize the Builder with + */ + private Builder(DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptions) { + this.iamId = deleteNotificationPreferencesOptions.iamId; + this.accountId = deleteNotificationPreferencesOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param iamId the iamId + */ + public Builder(String iamId) { + this.iamId = iamId; + } + + /** + * Builds a DeleteNotificationPreferencesOptions. + * + * @return the new DeleteNotificationPreferencesOptions instance + */ + public DeleteNotificationPreferencesOptions build() { + return new DeleteNotificationPreferencesOptions(this); + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the DeleteNotificationPreferencesOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the DeleteNotificationPreferencesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + } + + protected DeleteNotificationPreferencesOptions() { } + + protected DeleteNotificationPreferencesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + iamId = builder.iamId; + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a DeleteNotificationPreferencesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the iamId. + * + * The IAM ID of the user. Must match the IAM ID in the bearer token. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptions.java new file mode 100644 index 0000000000..f776ba8b1e --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptions.java @@ -0,0 +1,93 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getAcknowledgement options. + */ +public class GetAcknowledgementOptions extends GenericModel { + + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + + /** + * Instantiates a new Builder from an existing GetAcknowledgementOptions instance. + * + * @param getAcknowledgementOptions the instance to initialize the Builder with + */ + private Builder(GetAcknowledgementOptions getAcknowledgementOptions) { + this.accountId = getAcknowledgementOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetAcknowledgementOptions. + * + * @return the new GetAcknowledgementOptions instance + */ + public GetAcknowledgementOptions build() { + return new GetAcknowledgementOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the GetAcknowledgementOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + } + + protected GetAcknowledgementOptions() { } + + protected GetAcknowledgementOptions(Builder builder) { + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a GetAcknowledgementOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptions.java new file mode 100644 index 0000000000..45c0878581 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getDistributionListDestination options. + */ +public class GetDistributionListDestinationOptions extends GenericModel { + + protected String accountId; + protected String destinationId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String destinationId; + + /** + * Instantiates a new Builder from an existing GetDistributionListDestinationOptions instance. + * + * @param getDistributionListDestinationOptions the instance to initialize the Builder with + */ + private Builder(GetDistributionListDestinationOptions getDistributionListDestinationOptions) { + this.accountId = getDistributionListDestinationOptions.accountId; + this.destinationId = getDistributionListDestinationOptions.destinationId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param destinationId the destinationId + */ + public Builder(String accountId, String destinationId) { + this.accountId = accountId; + this.destinationId = destinationId; + } + + /** + * Builds a GetDistributionListDestinationOptions. + * + * @return the new GetDistributionListDestinationOptions instance + */ + public GetDistributionListDestinationOptions build() { + return new GetDistributionListDestinationOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the GetDistributionListDestinationOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the destinationId. + * + * @param destinationId the destinationId + * @return the GetDistributionListDestinationOptions builder + */ + public Builder destinationId(String destinationId) { + this.destinationId = destinationId; + return this; + } + } + + protected GetDistributionListDestinationOptions() { } + + protected GetDistributionListDestinationOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.destinationId, + "destinationId cannot be empty"); + accountId = builder.accountId; + destinationId = builder.destinationId; + } + + /** + * New builder. + * + * @return a GetDistributionListDestinationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the destinationId. + * + * The ID of the destination. + * + * @return the destinationId + */ + public String destinationId() { + return destinationId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptions.java new file mode 100644 index 0000000000..2b9ea6081b --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptions.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getPreferences options. + */ +public class GetPreferencesOptions extends GenericModel { + + protected String iamId; + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String iamId; + private String accountId; + + /** + * Instantiates a new Builder from an existing GetPreferencesOptions instance. + * + * @param getPreferencesOptions the instance to initialize the Builder with + */ + private Builder(GetPreferencesOptions getPreferencesOptions) { + this.iamId = getPreferencesOptions.iamId; + this.accountId = getPreferencesOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param iamId the iamId + */ + public Builder(String iamId) { + this.iamId = iamId; + } + + /** + * Builds a GetPreferencesOptions. + * + * @return the new GetPreferencesOptions instance + */ + public GetPreferencesOptions build() { + return new GetPreferencesOptions(this); + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the GetPreferencesOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the GetPreferencesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + } + + protected GetPreferencesOptions() { } + + protected GetPreferencesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + iamId = builder.iamId; + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a GetPreferencesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the iamId. + * + * The IAM ID of the user. Must match the IAM ID in the bearer token. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptions.java new file mode 100644 index 0000000000..5d8d7b4fa7 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listDistributionListDestinations options. + */ +public class ListDistributionListDestinationsOptions extends GenericModel { + + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + + /** + * Instantiates a new Builder from an existing ListDistributionListDestinationsOptions instance. + * + * @param listDistributionListDestinationsOptions the instance to initialize the Builder with + */ + private Builder(ListDistributionListDestinationsOptions listDistributionListDestinationsOptions) { + this.accountId = listDistributionListDestinationsOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + */ + public Builder(String accountId) { + this.accountId = accountId; + } + + /** + * Builds a ListDistributionListDestinationsOptions. + * + * @return the new ListDistributionListDestinationsOptions instance + */ + public ListDistributionListDestinationsOptions build() { + return new ListDistributionListDestinationsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListDistributionListDestinationsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + } + + protected ListDistributionListDestinationsOptions() { } + + protected ListDistributionListDestinationsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a ListDistributionListDestinationsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptions.java new file mode 100644 index 0000000000..275570da4a --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptions.java @@ -0,0 +1,146 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The listNotifications options. + */ +public class ListNotificationsOptions extends GenericModel { + + protected String accountId; + protected String start; + protected Long limit; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String start; + private Long limit; + + /** + * Instantiates a new Builder from an existing ListNotificationsOptions instance. + * + * @param listNotificationsOptions the instance to initialize the Builder with + */ + private Builder(ListNotificationsOptions listNotificationsOptions) { + this.accountId = listNotificationsOptions.accountId; + this.start = listNotificationsOptions.start; + this.limit = listNotificationsOptions.limit; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a ListNotificationsOptions. + * + * @return the new ListNotificationsOptions instance + */ + public ListNotificationsOptions build() { + return new ListNotificationsOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ListNotificationsOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the start. + * + * @param start the start + * @return the ListNotificationsOptions builder + */ + public Builder start(String start) { + this.start = start; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ListNotificationsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + } + + protected ListNotificationsOptions() { } + + protected ListNotificationsOptions(Builder builder) { + accountId = builder.accountId; + start = builder.start; + limit = builder.limit; + } + + /** + * New builder. + * + * @return a ListNotificationsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the start. + * + * An opaque page token that specifies the resource to start the page on or after. If unspecified, the first page of + * results is returned. + * + * @return the start + */ + public String start() { + return start; + } + + /** + * Gets the limit. + * + * The maximum number of items to return per page. If unspecified, a default limit of 50 is used. + * + * @return the limit + */ + public Long limit() { + return limit; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Notification.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Notification.java new file mode 100644 index 0000000000..4c8100f0be --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/Notification.java @@ -0,0 +1,338 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A notification entry. + */ +public class Notification extends GenericModel { + + /** + * The category of the notification. + */ + public interface Category { + /** incident. */ + String INCIDENT = "incident"; + /** maintenance. */ + String MAINTENANCE = "maintenance"; + /** announcements. */ + String ANNOUNCEMENTS = "announcements"; + /** security_bulletins. */ + String SECURITY_BULLETINS = "security_bulletins"; + /** security. */ + String SECURITY = "security"; + /** resource. */ + String RESOURCE = "resource"; + /** billing_and_usage. */ + String BILLING_AND_USAGE = "billing_and_usage"; + /** ordering. */ + String ORDERING = "ordering"; + /** provisioning. */ + String PROVISIONING = "provisioning"; + /** account. */ + String ACCOUNT = "account"; + } + + /** + * The current state of the notification. + */ + public interface State { + /** new. */ + String X_NEW = "new"; + /** in-progress. */ + String IN_PROGRESS = "in-progress"; + /** complete. */ + String COMPLETE = "complete"; + /** resolved. */ + String RESOLVED = "resolved"; + } + + /** + * The completion code of the notification. + */ + public interface CompletionCode { + /** successful. */ + String SUCCESSFUL = "successful"; + /** failed. */ + String FAILED = "failed"; + /** cancelled. */ + String CANCELLED = "cancelled"; + } + + protected String title; + protected String body; + protected String id; + protected String category; + @SerializedName("component_names") + protected List componentNames; + @SerializedName("start_time") + protected Long startTime; + @SerializedName("is_global") + protected Boolean isGlobal; + protected String state; + protected List regions; + @SerializedName("crn_masks") + protected List crnMasks; + @SerializedName("record_id") + protected String recordId; + @SerializedName("source_id") + protected String sourceId; + @SerializedName("completion_code") + protected String completionCode; + @SerializedName("end_time") + protected Long endTime; + @SerializedName("update_time") + protected Long updateTime; + protected Long severity; + @SerializedName("lucene_query") + protected String luceneQuery; + @SerializedName("resource_link") + protected String resourceLink; + @SerializedName("creation_timestamp") + protected Long creationTimestamp; + + protected Notification() { } + + /** + * Gets the title. + * + * The title of the notification. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the body. + * + * The body content of the notification. + * + * @return the body + */ + public String getBody() { + return body; + } + + /** + * Gets the id. + * + * The unique identifier for the notification. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the category. + * + * The category of the notification. + * + * @return the category + */ + public String getCategory() { + return category; + } + + /** + * Gets the componentNames. + * + * Array of component/service names affected by this notification. + * + * @return the componentNames + */ + public List getComponentNames() { + return componentNames; + } + + /** + * Gets the startTime. + * + * The start time of the notification in Unix timestamp (seconds). + * + * @return the startTime + */ + public Long getStartTime() { + return startTime; + } + + /** + * Gets the isGlobal. + * + * Indicates if the notification is global. + * + * @return the isGlobal + */ + public Boolean isIsGlobal() { + return isGlobal; + } + + /** + * Gets the state. + * + * The current state of the notification. + * + * @return the state + */ + public String getState() { + return state; + } + + /** + * Gets the regions. + * + * Array of region identifiers affected by this notification. + * + * @return the regions + */ + public List getRegions() { + return regions; + } + + /** + * Gets the crnMasks. + * + * Array of CRN masks that define the scope of affected resources. + * + * @return the crnMasks + */ + public List getCrnMasks() { + return crnMasks; + } + + /** + * Gets the recordId. + * + * The record identifier for tracking purposes. + * + * @return the recordId + */ + public String getRecordId() { + return recordId; + } + + /** + * Gets the sourceId. + * + * The source identifier of the notification. + * + * @return the sourceId + */ + public String getSourceId() { + return sourceId; + } + + /** + * Gets the completionCode. + * + * The completion code of the notification. + * + * @return the completionCode + */ + public String getCompletionCode() { + return completionCode; + } + + /** + * Gets the endTime. + * + * The end time of the notification in Unix timestamp (seconds). + * + * @return the endTime + */ + public Long getEndTime() { + return endTime; + } + + /** + * Gets the updateTime. + * + * The last update time of the notification in Unix timestamp (seconds). + * + * @return the updateTime + */ + public Long getUpdateTime() { + return updateTime; + } + + /** + * Gets the severity. + * + * The severity level of the notification (0-3). The display value depends on the notification type: + * + * **Incidents:** + * - 1 = Severity 1 + * - 2 = Severity 2 + * - 3 = Severity 3 + * - 0 = Severity 4 + * + * **Maintenance:** + * - 1 = High + * - 2 = Medium + * - 3 = Low + * + * **Announcements:** + * - 1 = Major + * - 0 = Minor. + * + * @return the severity + */ + public Long getSeverity() { + return severity; + } + + /** + * Gets the luceneQuery. + * + * Lucene query string for filtering affected resources. Only present when instance targets are specified and + * resource_link is not available. Mutually exclusive with resource_link. + * + * @return the luceneQuery + */ + public String getLuceneQuery() { + return luceneQuery; + } + + /** + * Gets the resourceLink. + * + * Link to additional resource information or documentation. Takes precedence over lucene_query when both are + * available. Mutually exclusive with lucene_query. + * + * @return the resourceLink + */ + public String getResourceLink() { + return resourceLink; + } + + /** + * Gets the creationTimestamp. + * + * The timestamp when the notification was created. + * + * @return the creationTimestamp + */ + public Long getCreationTimestamp() { + return creationTimestamp; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollection.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollection.java new file mode 100644 index 0000000000..f5a9e7dd03 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollection.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Collection of user notifications with token-based pagination metadata. + */ +public class NotificationCollection extends GenericModel { + + protected Long limit; + @SerializedName("total_count") + protected Long totalCount; + protected PaginationLink first; + protected PaginationLinkWithToken previous; + protected PaginationLinkWithToken next; + protected PaginationLinkWithToken last; + protected List notifications; + + protected NotificationCollection() { } + + /** + * Gets the limit. + * + * The maximum number of items returned in this response. + * + * @return the limit + */ + public Long getLimit() { + return limit; + } + + /** + * Gets the totalCount. + * + * The total number of notifications in the collection. + * + * @return the totalCount + */ + public Long getTotalCount() { + return totalCount; + } + + /** + * Gets the first. + * + * A pagination link object containing the URL to a page. + * + * @return the first + */ + public PaginationLink getFirst() { + return first; + } + + /** + * Gets the previous. + * + * A pagination link object with a page token. Used for next, previous, and last page links. + * + * @return the previous + */ + public PaginationLinkWithToken getPrevious() { + return previous; + } + + /** + * Gets the next. + * + * A pagination link object with a page token. Used for next, previous, and last page links. + * + * @return the next + */ + public PaginationLinkWithToken getNext() { + return next; + } + + /** + * Gets the last. + * + * A pagination link object with a page token. Used for next, previous, and last page links. + * + * @return the last + */ + public PaginationLinkWithToken getLast() { + return last; + } + + /** + * Gets the notifications. + * + * Array of notification entries. + * + * @return the notifications + */ + public List getNotifications() { + return notifications; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationsPager.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationsPager.java new file mode 100644 index 0000000000..2d0b52acfd --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationsPager.java @@ -0,0 +1,108 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.PlatformNotifications; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * NotificationsPager can be used to simplify the use of the "listNotifications" method. + */ +public class NotificationsPager { + private static class PageContext { + private String next; + public String getNext() { + return next; + } + public void setNext(String next) { + this.next = next; + } + } + + protected boolean hasNext; + protected ListNotificationsOptions options; + protected PlatformNotifications client; + protected PageContext pageContext; + + // Hide the default ctor. + protected NotificationsPager() { } + + /** + * Constructs a new NotificationsPager instance with the specified client and options model instance. + * @param client the PlatformNotifications instance to be used to invoke the "listNotifications" method + * @param options the ListNotificationsOptions instance to be used to invoke the "listNotifications" method + */ + public NotificationsPager(PlatformNotifications client, ListNotificationsOptions options) { + if (options.start() != null) { + throw new IllegalArgumentException("The options 'start' field should not be set"); + } + + this.hasNext = true; + this.client = client; + this.options = options.newBuilder().build(); + this.pageContext = new PageContext(); + } + + /** + * Returns true if there are more results to be retrieved. + * @return boolean + */ + public boolean hasNext() { + return hasNext; + } + + /** + * Returns the next page of results. + * @return a List<Notification> that contains the next page of results + */ + public List getNext() { + if (!hasNext()) { + throw new NoSuchElementException("No more results available"); + } + + ListNotificationsOptions.Builder builder = this.options.newBuilder(); + if (this.pageContext.getNext() != null) { + builder.start(this.pageContext.getNext()); + } + this.options = builder.build(); + + NotificationCollection result = client.listNotifications(options).execute().getResult(); + + String next = null; + if (result.getNext() != null) { + next = result.getNext().getStart(); + } + this.pageContext.setNext(next); + if (next == null) { + this.hasNext = false; + } + + return result.getNotifications(); + } + + /** + * Returns all results by invoking getNext() repeatedly until all pages of results have been retrieved. + * @return a List<Notification> containing all results returned by the "listNotifications" method + */ + public List getAll() { + List results = new ArrayList<>(); + while (hasNext()) { + List nextPage = getNext(); + results.addAll(nextPage); + } + return results; + } +} diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLink.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLink.java new file mode 100644 index 0000000000..ee12bff04c --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLink.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A pagination link object containing the URL to a page. + */ +public class PaginationLink extends GenericModel { + + protected String href; + + protected PaginationLink() { } + + /** + * Gets the href. + * + * The full URL path to the page. + * + * @return the href + */ + public String getHref() { + return href; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithToken.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithToken.java new file mode 100644 index 0000000000..6baa2c9c2c --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithToken.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * A pagination link object with a page token. Used for next, previous, and last page links. + */ +public class PaginationLinkWithToken extends GenericModel { + + protected String href; + protected String start; + + protected PaginationLinkWithToken() { } + + /** + * Gets the href. + * + * Complete URL to the page. + * + * @return the href + */ + public String getHref() { + return href; + } + + /** + * Gets the start. + * + * Opaque page token that can be used to retrieve the page. + * + * @return the start + */ + public String getStart() { + return start; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdates.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdates.java new file mode 100644 index 0000000000..0226b07bef --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdates.java @@ -0,0 +1,155 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Preference settings for notification types that support updates. + */ +public class PreferenceValueWithUpdates extends GenericModel { + + public interface Channels { + /** email. */ + String EMAIL = "email"; + } + + protected List channels; + protected Boolean updates; + + /** + * Builder. + */ + public static class Builder { + private List channels; + private Boolean updates; + + /** + * Instantiates a new Builder from an existing PreferenceValueWithUpdates instance. + * + * @param preferenceValueWithUpdates the instance to initialize the Builder with + */ + private Builder(PreferenceValueWithUpdates preferenceValueWithUpdates) { + this.channels = preferenceValueWithUpdates.channels; + this.updates = preferenceValueWithUpdates.updates; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param channels the channels + */ + public Builder(List channels) { + this.channels = channels; + } + + /** + * Builds a PreferenceValueWithUpdates. + * + * @return the new PreferenceValueWithUpdates instance + */ + public PreferenceValueWithUpdates build() { + return new PreferenceValueWithUpdates(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the PreferenceValueWithUpdates builder + */ + public Builder addChannels(String channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, + "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the channels. + * Existing channels will be replaced. + * + * @param channels the channels + * @return the PreferenceValueWithUpdates builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + + /** + * Set the updates. + * + * @param updates the updates + * @return the PreferenceValueWithUpdates builder + */ + public Builder updates(Boolean updates) { + this.updates = updates; + return this; + } + } + + protected PreferenceValueWithUpdates() { } + + protected PreferenceValueWithUpdates(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.channels, + "channels cannot be null"); + channels = builder.channels; + updates = builder.updates; + } + + /** + * New builder. + * + * @return a PreferenceValueWithUpdates builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the channels. + * + * Array of communication channels for this preference. + * + * @return the channels + */ + public List channels() { + return channels; + } + + /** + * Gets the updates. + * + * Whether to receive updates for this preference. Optional, defaults to false if not provided. + * + * @return the updates + */ + public Boolean updates() { + return updates; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdates.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdates.java new file mode 100644 index 0000000000..47ca694928 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdates.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Preference settings for notification types that do not support updates. + */ +public class PreferenceValueWithoutUpdates extends GenericModel { + + public interface Channels { + /** email. */ + String EMAIL = "email"; + } + + protected List channels; + + /** + * Builder. + */ + public static class Builder { + private List channels; + + /** + * Instantiates a new Builder from an existing PreferenceValueWithoutUpdates instance. + * + * @param preferenceValueWithoutUpdates the instance to initialize the Builder with + */ + private Builder(PreferenceValueWithoutUpdates preferenceValueWithoutUpdates) { + this.channels = preferenceValueWithoutUpdates.channels; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param channels the channels + */ + public Builder(List channels) { + this.channels = channels; + } + + /** + * Builds a PreferenceValueWithoutUpdates. + * + * @return the new PreferenceValueWithoutUpdates instance + */ + public PreferenceValueWithoutUpdates build() { + return new PreferenceValueWithoutUpdates(this); + } + + /** + * Adds a new element to channels. + * + * @param channels the new element to be added + * @return the PreferenceValueWithoutUpdates builder + */ + public Builder addChannels(String channels) { + com.ibm.cloud.sdk.core.util.Validator.notNull(channels, + "channels cannot be null"); + if (this.channels == null) { + this.channels = new ArrayList(); + } + this.channels.add(channels); + return this; + } + + /** + * Set the channels. + * Existing channels will be replaced. + * + * @param channels the channels + * @return the PreferenceValueWithoutUpdates builder + */ + public Builder channels(List channels) { + this.channels = channels; + return this; + } + } + + protected PreferenceValueWithoutUpdates() { } + + protected PreferenceValueWithoutUpdates(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.channels, + "channels cannot be null"); + channels = builder.channels; + } + + /** + * New builder. + * + * @return a PreferenceValueWithoutUpdates builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the channels. + * + * Array of communication channels for this preference. + * + * @return the channels + */ + public List channels() { + return channels; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObject.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObject.java new file mode 100644 index 0000000000..4afadd9d74 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObject.java @@ -0,0 +1,717 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * User communication preferences object. Only include preferences where communication is desired; absence of a key + * means no communication for that preference type. + */ +public class PreferencesObject extends GenericModel { + + @SerializedName("incident_severity1") + protected PreferenceValueWithUpdates incidentSeverity1; + @SerializedName("incident_severity2") + protected PreferenceValueWithUpdates incidentSeverity2; + @SerializedName("incident_severity3") + protected PreferenceValueWithUpdates incidentSeverity3; + @SerializedName("incident_severity4") + protected PreferenceValueWithUpdates incidentSeverity4; + @SerializedName("maintenance_high") + protected PreferenceValueWithUpdates maintenanceHigh; + @SerializedName("maintenance_medium") + protected PreferenceValueWithUpdates maintenanceMedium; + @SerializedName("maintenance_low") + protected PreferenceValueWithUpdates maintenanceLow; + @SerializedName("announcements_major") + protected PreferenceValueWithoutUpdates announcementsMajor; + @SerializedName("announcements_minor") + protected PreferenceValueWithoutUpdates announcementsMinor; + @SerializedName("security_normal") + protected PreferenceValueWithoutUpdates securityNormal; + @SerializedName("account_normal") + protected PreferenceValueWithoutUpdates accountNormal; + @SerializedName("billing_and_usage_order") + protected PreferenceValueWithoutUpdates billingAndUsageOrder; + @SerializedName("billing_and_usage_invoices") + protected PreferenceValueWithoutUpdates billingAndUsageInvoices; + @SerializedName("billing_and_usage_payments") + protected PreferenceValueWithoutUpdates billingAndUsagePayments; + @SerializedName("billing_and_usage_subscriptions_and_promo_codes") + protected PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + @SerializedName("billing_and_usage_spending_alerts") + protected PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + @SerializedName("resourceactivity_normal") + protected PreferenceValueWithoutUpdates resourceactivityNormal; + @SerializedName("ordering_review") + protected PreferenceValueWithoutUpdates orderingReview; + @SerializedName("ordering_approved") + protected PreferenceValueWithoutUpdates orderingApproved; + @SerializedName("ordering_approved_vsi") + protected PreferenceValueWithoutUpdates orderingApprovedVsi; + @SerializedName("ordering_approved_server") + protected PreferenceValueWithoutUpdates orderingApprovedServer; + @SerializedName("provisioning_reload_complete") + protected PreferenceValueWithoutUpdates provisioningReloadComplete; + @SerializedName("provisioning_complete_vsi") + protected PreferenceValueWithoutUpdates provisioningCompleteVsi; + @SerializedName("provisioning_complete_server") + protected PreferenceValueWithoutUpdates provisioningCompleteServer; + + /** + * Builder. + */ + public static class Builder { + private PreferenceValueWithUpdates incidentSeverity1; + private PreferenceValueWithUpdates incidentSeverity2; + private PreferenceValueWithUpdates incidentSeverity3; + private PreferenceValueWithUpdates incidentSeverity4; + private PreferenceValueWithUpdates maintenanceHigh; + private PreferenceValueWithUpdates maintenanceMedium; + private PreferenceValueWithUpdates maintenanceLow; + private PreferenceValueWithoutUpdates announcementsMajor; + private PreferenceValueWithoutUpdates announcementsMinor; + private PreferenceValueWithoutUpdates securityNormal; + private PreferenceValueWithoutUpdates accountNormal; + private PreferenceValueWithoutUpdates billingAndUsageOrder; + private PreferenceValueWithoutUpdates billingAndUsageInvoices; + private PreferenceValueWithoutUpdates billingAndUsagePayments; + private PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + private PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + private PreferenceValueWithoutUpdates resourceactivityNormal; + private PreferenceValueWithoutUpdates orderingReview; + private PreferenceValueWithoutUpdates orderingApproved; + private PreferenceValueWithoutUpdates orderingApprovedVsi; + private PreferenceValueWithoutUpdates orderingApprovedServer; + private PreferenceValueWithoutUpdates provisioningReloadComplete; + private PreferenceValueWithoutUpdates provisioningCompleteVsi; + private PreferenceValueWithoutUpdates provisioningCompleteServer; + + /** + * Instantiates a new Builder from an existing PreferencesObject instance. + * + * @param preferencesObject the instance to initialize the Builder with + */ + private Builder(PreferencesObject preferencesObject) { + this.incidentSeverity1 = preferencesObject.incidentSeverity1; + this.incidentSeverity2 = preferencesObject.incidentSeverity2; + this.incidentSeverity3 = preferencesObject.incidentSeverity3; + this.incidentSeverity4 = preferencesObject.incidentSeverity4; + this.maintenanceHigh = preferencesObject.maintenanceHigh; + this.maintenanceMedium = preferencesObject.maintenanceMedium; + this.maintenanceLow = preferencesObject.maintenanceLow; + this.announcementsMajor = preferencesObject.announcementsMajor; + this.announcementsMinor = preferencesObject.announcementsMinor; + this.securityNormal = preferencesObject.securityNormal; + this.accountNormal = preferencesObject.accountNormal; + this.billingAndUsageOrder = preferencesObject.billingAndUsageOrder; + this.billingAndUsageInvoices = preferencesObject.billingAndUsageInvoices; + this.billingAndUsagePayments = preferencesObject.billingAndUsagePayments; + this.billingAndUsageSubscriptionsAndPromoCodes = preferencesObject.billingAndUsageSubscriptionsAndPromoCodes; + this.billingAndUsageSpendingAlerts = preferencesObject.billingAndUsageSpendingAlerts; + this.resourceactivityNormal = preferencesObject.resourceactivityNormal; + this.orderingReview = preferencesObject.orderingReview; + this.orderingApproved = preferencesObject.orderingApproved; + this.orderingApprovedVsi = preferencesObject.orderingApprovedVsi; + this.orderingApprovedServer = preferencesObject.orderingApprovedServer; + this.provisioningReloadComplete = preferencesObject.provisioningReloadComplete; + this.provisioningCompleteVsi = preferencesObject.provisioningCompleteVsi; + this.provisioningCompleteServer = preferencesObject.provisioningCompleteServer; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a PreferencesObject. + * + * @return the new PreferencesObject instance + */ + public PreferencesObject build() { + return new PreferencesObject(this); + } + + /** + * Set the incidentSeverity1. + * + * @param incidentSeverity1 the incidentSeverity1 + * @return the PreferencesObject builder + */ + public Builder incidentSeverity1(PreferenceValueWithUpdates incidentSeverity1) { + this.incidentSeverity1 = incidentSeverity1; + return this; + } + + /** + * Set the incidentSeverity2. + * + * @param incidentSeverity2 the incidentSeverity2 + * @return the PreferencesObject builder + */ + public Builder incidentSeverity2(PreferenceValueWithUpdates incidentSeverity2) { + this.incidentSeverity2 = incidentSeverity2; + return this; + } + + /** + * Set the incidentSeverity3. + * + * @param incidentSeverity3 the incidentSeverity3 + * @return the PreferencesObject builder + */ + public Builder incidentSeverity3(PreferenceValueWithUpdates incidentSeverity3) { + this.incidentSeverity3 = incidentSeverity3; + return this; + } + + /** + * Set the incidentSeverity4. + * + * @param incidentSeverity4 the incidentSeverity4 + * @return the PreferencesObject builder + */ + public Builder incidentSeverity4(PreferenceValueWithUpdates incidentSeverity4) { + this.incidentSeverity4 = incidentSeverity4; + return this; + } + + /** + * Set the maintenanceHigh. + * + * @param maintenanceHigh the maintenanceHigh + * @return the PreferencesObject builder + */ + public Builder maintenanceHigh(PreferenceValueWithUpdates maintenanceHigh) { + this.maintenanceHigh = maintenanceHigh; + return this; + } + + /** + * Set the maintenanceMedium. + * + * @param maintenanceMedium the maintenanceMedium + * @return the PreferencesObject builder + */ + public Builder maintenanceMedium(PreferenceValueWithUpdates maintenanceMedium) { + this.maintenanceMedium = maintenanceMedium; + return this; + } + + /** + * Set the maintenanceLow. + * + * @param maintenanceLow the maintenanceLow + * @return the PreferencesObject builder + */ + public Builder maintenanceLow(PreferenceValueWithUpdates maintenanceLow) { + this.maintenanceLow = maintenanceLow; + return this; + } + + /** + * Set the announcementsMajor. + * + * @param announcementsMajor the announcementsMajor + * @return the PreferencesObject builder + */ + public Builder announcementsMajor(PreferenceValueWithoutUpdates announcementsMajor) { + this.announcementsMajor = announcementsMajor; + return this; + } + + /** + * Set the announcementsMinor. + * + * @param announcementsMinor the announcementsMinor + * @return the PreferencesObject builder + */ + public Builder announcementsMinor(PreferenceValueWithoutUpdates announcementsMinor) { + this.announcementsMinor = announcementsMinor; + return this; + } + + /** + * Set the securityNormal. + * + * @param securityNormal the securityNormal + * @return the PreferencesObject builder + */ + public Builder securityNormal(PreferenceValueWithoutUpdates securityNormal) { + this.securityNormal = securityNormal; + return this; + } + + /** + * Set the accountNormal. + * + * @param accountNormal the accountNormal + * @return the PreferencesObject builder + */ + public Builder accountNormal(PreferenceValueWithoutUpdates accountNormal) { + this.accountNormal = accountNormal; + return this; + } + + /** + * Set the billingAndUsageOrder. + * + * @param billingAndUsageOrder the billingAndUsageOrder + * @return the PreferencesObject builder + */ + public Builder billingAndUsageOrder(PreferenceValueWithoutUpdates billingAndUsageOrder) { + this.billingAndUsageOrder = billingAndUsageOrder; + return this; + } + + /** + * Set the billingAndUsageInvoices. + * + * @param billingAndUsageInvoices the billingAndUsageInvoices + * @return the PreferencesObject builder + */ + public Builder billingAndUsageInvoices(PreferenceValueWithoutUpdates billingAndUsageInvoices) { + this.billingAndUsageInvoices = billingAndUsageInvoices; + return this; + } + + /** + * Set the billingAndUsagePayments. + * + * @param billingAndUsagePayments the billingAndUsagePayments + * @return the PreferencesObject builder + */ + public Builder billingAndUsagePayments(PreferenceValueWithoutUpdates billingAndUsagePayments) { + this.billingAndUsagePayments = billingAndUsagePayments; + return this; + } + + /** + * Set the billingAndUsageSubscriptionsAndPromoCodes. + * + * @param billingAndUsageSubscriptionsAndPromoCodes the billingAndUsageSubscriptionsAndPromoCodes + * @return the PreferencesObject builder + */ + public Builder billingAndUsageSubscriptionsAndPromoCodes(PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes) { + this.billingAndUsageSubscriptionsAndPromoCodes = billingAndUsageSubscriptionsAndPromoCodes; + return this; + } + + /** + * Set the billingAndUsageSpendingAlerts. + * + * @param billingAndUsageSpendingAlerts the billingAndUsageSpendingAlerts + * @return the PreferencesObject builder + */ + public Builder billingAndUsageSpendingAlerts(PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts) { + this.billingAndUsageSpendingAlerts = billingAndUsageSpendingAlerts; + return this; + } + + /** + * Set the resourceactivityNormal. + * + * @param resourceactivityNormal the resourceactivityNormal + * @return the PreferencesObject builder + */ + public Builder resourceactivityNormal(PreferenceValueWithoutUpdates resourceactivityNormal) { + this.resourceactivityNormal = resourceactivityNormal; + return this; + } + + /** + * Set the orderingReview. + * + * @param orderingReview the orderingReview + * @return the PreferencesObject builder + */ + public Builder orderingReview(PreferenceValueWithoutUpdates orderingReview) { + this.orderingReview = orderingReview; + return this; + } + + /** + * Set the orderingApproved. + * + * @param orderingApproved the orderingApproved + * @return the PreferencesObject builder + */ + public Builder orderingApproved(PreferenceValueWithoutUpdates orderingApproved) { + this.orderingApproved = orderingApproved; + return this; + } + + /** + * Set the orderingApprovedVsi. + * + * @param orderingApprovedVsi the orderingApprovedVsi + * @return the PreferencesObject builder + */ + public Builder orderingApprovedVsi(PreferenceValueWithoutUpdates orderingApprovedVsi) { + this.orderingApprovedVsi = orderingApprovedVsi; + return this; + } + + /** + * Set the orderingApprovedServer. + * + * @param orderingApprovedServer the orderingApprovedServer + * @return the PreferencesObject builder + */ + public Builder orderingApprovedServer(PreferenceValueWithoutUpdates orderingApprovedServer) { + this.orderingApprovedServer = orderingApprovedServer; + return this; + } + + /** + * Set the provisioningReloadComplete. + * + * @param provisioningReloadComplete the provisioningReloadComplete + * @return the PreferencesObject builder + */ + public Builder provisioningReloadComplete(PreferenceValueWithoutUpdates provisioningReloadComplete) { + this.provisioningReloadComplete = provisioningReloadComplete; + return this; + } + + /** + * Set the provisioningCompleteVsi. + * + * @param provisioningCompleteVsi the provisioningCompleteVsi + * @return the PreferencesObject builder + */ + public Builder provisioningCompleteVsi(PreferenceValueWithoutUpdates provisioningCompleteVsi) { + this.provisioningCompleteVsi = provisioningCompleteVsi; + return this; + } + + /** + * Set the provisioningCompleteServer. + * + * @param provisioningCompleteServer the provisioningCompleteServer + * @return the PreferencesObject builder + */ + public Builder provisioningCompleteServer(PreferenceValueWithoutUpdates provisioningCompleteServer) { + this.provisioningCompleteServer = provisioningCompleteServer; + return this; + } + } + + protected PreferencesObject() { } + + protected PreferencesObject(Builder builder) { + incidentSeverity1 = builder.incidentSeverity1; + incidentSeverity2 = builder.incidentSeverity2; + incidentSeverity3 = builder.incidentSeverity3; + incidentSeverity4 = builder.incidentSeverity4; + maintenanceHigh = builder.maintenanceHigh; + maintenanceMedium = builder.maintenanceMedium; + maintenanceLow = builder.maintenanceLow; + announcementsMajor = builder.announcementsMajor; + announcementsMinor = builder.announcementsMinor; + securityNormal = builder.securityNormal; + accountNormal = builder.accountNormal; + billingAndUsageOrder = builder.billingAndUsageOrder; + billingAndUsageInvoices = builder.billingAndUsageInvoices; + billingAndUsagePayments = builder.billingAndUsagePayments; + billingAndUsageSubscriptionsAndPromoCodes = builder.billingAndUsageSubscriptionsAndPromoCodes; + billingAndUsageSpendingAlerts = builder.billingAndUsageSpendingAlerts; + resourceactivityNormal = builder.resourceactivityNormal; + orderingReview = builder.orderingReview; + orderingApproved = builder.orderingApproved; + orderingApprovedVsi = builder.orderingApprovedVsi; + orderingApprovedServer = builder.orderingApprovedServer; + provisioningReloadComplete = builder.provisioningReloadComplete; + provisioningCompleteVsi = builder.provisioningCompleteVsi; + provisioningCompleteServer = builder.provisioningCompleteServer; + } + + /** + * New builder. + * + * @return a PreferencesObject builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the incidentSeverity1. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity1 + */ + public PreferenceValueWithUpdates incidentSeverity1() { + return incidentSeverity1; + } + + /** + * Gets the incidentSeverity2. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity2 + */ + public PreferenceValueWithUpdates incidentSeverity2() { + return incidentSeverity2; + } + + /** + * Gets the incidentSeverity3. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity3 + */ + public PreferenceValueWithUpdates incidentSeverity3() { + return incidentSeverity3; + } + + /** + * Gets the incidentSeverity4. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity4 + */ + public PreferenceValueWithUpdates incidentSeverity4() { + return incidentSeverity4; + } + + /** + * Gets the maintenanceHigh. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceHigh + */ + public PreferenceValueWithUpdates maintenanceHigh() { + return maintenanceHigh; + } + + /** + * Gets the maintenanceMedium. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceMedium + */ + public PreferenceValueWithUpdates maintenanceMedium() { + return maintenanceMedium; + } + + /** + * Gets the maintenanceLow. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceLow + */ + public PreferenceValueWithUpdates maintenanceLow() { + return maintenanceLow; + } + + /** + * Gets the announcementsMajor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMajor + */ + public PreferenceValueWithoutUpdates announcementsMajor() { + return announcementsMajor; + } + + /** + * Gets the announcementsMinor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMinor + */ + public PreferenceValueWithoutUpdates announcementsMinor() { + return announcementsMinor; + } + + /** + * Gets the securityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the securityNormal + */ + public PreferenceValueWithoutUpdates securityNormal() { + return securityNormal; + } + + /** + * Gets the accountNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the accountNormal + */ + public PreferenceValueWithoutUpdates accountNormal() { + return accountNormal; + } + + /** + * Gets the billingAndUsageOrder. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageOrder + */ + public PreferenceValueWithoutUpdates billingAndUsageOrder() { + return billingAndUsageOrder; + } + + /** + * Gets the billingAndUsageInvoices. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageInvoices + */ + public PreferenceValueWithoutUpdates billingAndUsageInvoices() { + return billingAndUsageInvoices; + } + + /** + * Gets the billingAndUsagePayments. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsagePayments + */ + public PreferenceValueWithoutUpdates billingAndUsagePayments() { + return billingAndUsagePayments; + } + + /** + * Gets the billingAndUsageSubscriptionsAndPromoCodes. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSubscriptionsAndPromoCodes + */ + public PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes() { + return billingAndUsageSubscriptionsAndPromoCodes; + } + + /** + * Gets the billingAndUsageSpendingAlerts. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSpendingAlerts + */ + public PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts() { + return billingAndUsageSpendingAlerts; + } + + /** + * Gets the resourceactivityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the resourceactivityNormal + */ + public PreferenceValueWithoutUpdates resourceactivityNormal() { + return resourceactivityNormal; + } + + /** + * Gets the orderingReview. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingReview + */ + public PreferenceValueWithoutUpdates orderingReview() { + return orderingReview; + } + + /** + * Gets the orderingApproved. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApproved + */ + public PreferenceValueWithoutUpdates orderingApproved() { + return orderingApproved; + } + + /** + * Gets the orderingApprovedVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedVsi + */ + public PreferenceValueWithoutUpdates orderingApprovedVsi() { + return orderingApprovedVsi; + } + + /** + * Gets the orderingApprovedServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedServer + */ + public PreferenceValueWithoutUpdates orderingApprovedServer() { + return orderingApprovedServer; + } + + /** + * Gets the provisioningReloadComplete. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningReloadComplete + */ + public PreferenceValueWithoutUpdates provisioningReloadComplete() { + return provisioningReloadComplete; + } + + /** + * Gets the provisioningCompleteVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteVsi + */ + public PreferenceValueWithoutUpdates provisioningCompleteVsi() { + return provisioningCompleteVsi; + } + + /** + * Gets the provisioningCompleteServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteServer + */ + public PreferenceValueWithoutUpdates provisioningCompleteServer() { + return provisioningCompleteServer; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptions.java new file mode 100644 index 0000000000..fad97f3d8d --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptions.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The replaceNotificationAcknowledgement options. + */ +public class ReplaceNotificationAcknowledgementOptions extends GenericModel { + + protected Long lastAcknowledged; + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private Long lastAcknowledged; + private String accountId; + + /** + * Instantiates a new Builder from an existing ReplaceNotificationAcknowledgementOptions instance. + * + * @param replaceNotificationAcknowledgementOptions the instance to initialize the Builder with + */ + private Builder(ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions) { + this.lastAcknowledged = replaceNotificationAcknowledgementOptions.lastAcknowledged; + this.accountId = replaceNotificationAcknowledgementOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param lastAcknowledged the lastAcknowledged + */ + public Builder(Long lastAcknowledged) { + this.lastAcknowledged = lastAcknowledged; + } + + /** + * Builds a ReplaceNotificationAcknowledgementOptions. + * + * @return the new ReplaceNotificationAcknowledgementOptions instance + */ + public ReplaceNotificationAcknowledgementOptions build() { + return new ReplaceNotificationAcknowledgementOptions(this); + } + + /** + * Set the lastAcknowledged. + * + * @param lastAcknowledged the lastAcknowledged + * @return the ReplaceNotificationAcknowledgementOptions builder + */ + public Builder lastAcknowledged(long lastAcknowledged) { + this.lastAcknowledged = lastAcknowledged; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ReplaceNotificationAcknowledgementOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + } + + protected ReplaceNotificationAcknowledgementOptions() { } + + protected ReplaceNotificationAcknowledgementOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.lastAcknowledged, + "lastAcknowledged cannot be null"); + lastAcknowledged = builder.lastAcknowledged; + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a ReplaceNotificationAcknowledgementOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the lastAcknowledged. + * + * The timestamp of the last acknowledgement. + * + * @return the lastAcknowledged + */ + public Long lastAcknowledged() { + return lastAcknowledged; + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptions.java new file mode 100644 index 0000000000..d4fa43be2c --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptions.java @@ -0,0 +1,788 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The replaceNotificationPreferences options. + */ +public class ReplaceNotificationPreferencesOptions extends GenericModel { + + protected String iamId; + protected PreferenceValueWithUpdates incidentSeverity1; + protected PreferenceValueWithUpdates incidentSeverity2; + protected PreferenceValueWithUpdates incidentSeverity3; + protected PreferenceValueWithUpdates incidentSeverity4; + protected PreferenceValueWithUpdates maintenanceHigh; + protected PreferenceValueWithUpdates maintenanceMedium; + protected PreferenceValueWithUpdates maintenanceLow; + protected PreferenceValueWithoutUpdates announcementsMajor; + protected PreferenceValueWithoutUpdates announcementsMinor; + protected PreferenceValueWithoutUpdates securityNormal; + protected PreferenceValueWithoutUpdates accountNormal; + protected PreferenceValueWithoutUpdates billingAndUsageOrder; + protected PreferenceValueWithoutUpdates billingAndUsageInvoices; + protected PreferenceValueWithoutUpdates billingAndUsagePayments; + protected PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + protected PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + protected PreferenceValueWithoutUpdates resourceactivityNormal; + protected PreferenceValueWithoutUpdates orderingReview; + protected PreferenceValueWithoutUpdates orderingApproved; + protected PreferenceValueWithoutUpdates orderingApprovedVsi; + protected PreferenceValueWithoutUpdates orderingApprovedServer; + protected PreferenceValueWithoutUpdates provisioningReloadComplete; + protected PreferenceValueWithoutUpdates provisioningCompleteVsi; + protected PreferenceValueWithoutUpdates provisioningCompleteServer; + protected String accountId; + + /** + * Builder. + */ + public static class Builder { + private String iamId; + private PreferenceValueWithUpdates incidentSeverity1; + private PreferenceValueWithUpdates incidentSeverity2; + private PreferenceValueWithUpdates incidentSeverity3; + private PreferenceValueWithUpdates incidentSeverity4; + private PreferenceValueWithUpdates maintenanceHigh; + private PreferenceValueWithUpdates maintenanceMedium; + private PreferenceValueWithUpdates maintenanceLow; + private PreferenceValueWithoutUpdates announcementsMajor; + private PreferenceValueWithoutUpdates announcementsMinor; + private PreferenceValueWithoutUpdates securityNormal; + private PreferenceValueWithoutUpdates accountNormal; + private PreferenceValueWithoutUpdates billingAndUsageOrder; + private PreferenceValueWithoutUpdates billingAndUsageInvoices; + private PreferenceValueWithoutUpdates billingAndUsagePayments; + private PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes; + private PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts; + private PreferenceValueWithoutUpdates resourceactivityNormal; + private PreferenceValueWithoutUpdates orderingReview; + private PreferenceValueWithoutUpdates orderingApproved; + private PreferenceValueWithoutUpdates orderingApprovedVsi; + private PreferenceValueWithoutUpdates orderingApprovedServer; + private PreferenceValueWithoutUpdates provisioningReloadComplete; + private PreferenceValueWithoutUpdates provisioningCompleteVsi; + private PreferenceValueWithoutUpdates provisioningCompleteServer; + private String accountId; + + /** + * Instantiates a new Builder from an existing ReplaceNotificationPreferencesOptions instance. + * + * @param replaceNotificationPreferencesOptions the instance to initialize the Builder with + */ + private Builder(ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptions) { + this.iamId = replaceNotificationPreferencesOptions.iamId; + this.incidentSeverity1 = replaceNotificationPreferencesOptions.incidentSeverity1; + this.incidentSeverity2 = replaceNotificationPreferencesOptions.incidentSeverity2; + this.incidentSeverity3 = replaceNotificationPreferencesOptions.incidentSeverity3; + this.incidentSeverity4 = replaceNotificationPreferencesOptions.incidentSeverity4; + this.maintenanceHigh = replaceNotificationPreferencesOptions.maintenanceHigh; + this.maintenanceMedium = replaceNotificationPreferencesOptions.maintenanceMedium; + this.maintenanceLow = replaceNotificationPreferencesOptions.maintenanceLow; + this.announcementsMajor = replaceNotificationPreferencesOptions.announcementsMajor; + this.announcementsMinor = replaceNotificationPreferencesOptions.announcementsMinor; + this.securityNormal = replaceNotificationPreferencesOptions.securityNormal; + this.accountNormal = replaceNotificationPreferencesOptions.accountNormal; + this.billingAndUsageOrder = replaceNotificationPreferencesOptions.billingAndUsageOrder; + this.billingAndUsageInvoices = replaceNotificationPreferencesOptions.billingAndUsageInvoices; + this.billingAndUsagePayments = replaceNotificationPreferencesOptions.billingAndUsagePayments; + this.billingAndUsageSubscriptionsAndPromoCodes = replaceNotificationPreferencesOptions.billingAndUsageSubscriptionsAndPromoCodes; + this.billingAndUsageSpendingAlerts = replaceNotificationPreferencesOptions.billingAndUsageSpendingAlerts; + this.resourceactivityNormal = replaceNotificationPreferencesOptions.resourceactivityNormal; + this.orderingReview = replaceNotificationPreferencesOptions.orderingReview; + this.orderingApproved = replaceNotificationPreferencesOptions.orderingApproved; + this.orderingApprovedVsi = replaceNotificationPreferencesOptions.orderingApprovedVsi; + this.orderingApprovedServer = replaceNotificationPreferencesOptions.orderingApprovedServer; + this.provisioningReloadComplete = replaceNotificationPreferencesOptions.provisioningReloadComplete; + this.provisioningCompleteVsi = replaceNotificationPreferencesOptions.provisioningCompleteVsi; + this.provisioningCompleteServer = replaceNotificationPreferencesOptions.provisioningCompleteServer; + this.accountId = replaceNotificationPreferencesOptions.accountId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param iamId the iamId + */ + public Builder(String iamId) { + this.iamId = iamId; + } + + /** + * Builds a ReplaceNotificationPreferencesOptions. + * + * @return the new ReplaceNotificationPreferencesOptions instance + */ + public ReplaceNotificationPreferencesOptions build() { + return new ReplaceNotificationPreferencesOptions(this); + } + + /** + * Set the iamId. + * + * @param iamId the iamId + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder iamId(String iamId) { + this.iamId = iamId; + return this; + } + + /** + * Set the incidentSeverity1. + * + * @param incidentSeverity1 the incidentSeverity1 + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder incidentSeverity1(PreferenceValueWithUpdates incidentSeverity1) { + this.incidentSeverity1 = incidentSeverity1; + return this; + } + + /** + * Set the incidentSeverity2. + * + * @param incidentSeverity2 the incidentSeverity2 + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder incidentSeverity2(PreferenceValueWithUpdates incidentSeverity2) { + this.incidentSeverity2 = incidentSeverity2; + return this; + } + + /** + * Set the incidentSeverity3. + * + * @param incidentSeverity3 the incidentSeverity3 + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder incidentSeverity3(PreferenceValueWithUpdates incidentSeverity3) { + this.incidentSeverity3 = incidentSeverity3; + return this; + } + + /** + * Set the incidentSeverity4. + * + * @param incidentSeverity4 the incidentSeverity4 + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder incidentSeverity4(PreferenceValueWithUpdates incidentSeverity4) { + this.incidentSeverity4 = incidentSeverity4; + return this; + } + + /** + * Set the maintenanceHigh. + * + * @param maintenanceHigh the maintenanceHigh + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder maintenanceHigh(PreferenceValueWithUpdates maintenanceHigh) { + this.maintenanceHigh = maintenanceHigh; + return this; + } + + /** + * Set the maintenanceMedium. + * + * @param maintenanceMedium the maintenanceMedium + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder maintenanceMedium(PreferenceValueWithUpdates maintenanceMedium) { + this.maintenanceMedium = maintenanceMedium; + return this; + } + + /** + * Set the maintenanceLow. + * + * @param maintenanceLow the maintenanceLow + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder maintenanceLow(PreferenceValueWithUpdates maintenanceLow) { + this.maintenanceLow = maintenanceLow; + return this; + } + + /** + * Set the announcementsMajor. + * + * @param announcementsMajor the announcementsMajor + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder announcementsMajor(PreferenceValueWithoutUpdates announcementsMajor) { + this.announcementsMajor = announcementsMajor; + return this; + } + + /** + * Set the announcementsMinor. + * + * @param announcementsMinor the announcementsMinor + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder announcementsMinor(PreferenceValueWithoutUpdates announcementsMinor) { + this.announcementsMinor = announcementsMinor; + return this; + } + + /** + * Set the securityNormal. + * + * @param securityNormal the securityNormal + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder securityNormal(PreferenceValueWithoutUpdates securityNormal) { + this.securityNormal = securityNormal; + return this; + } + + /** + * Set the accountNormal. + * + * @param accountNormal the accountNormal + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder accountNormal(PreferenceValueWithoutUpdates accountNormal) { + this.accountNormal = accountNormal; + return this; + } + + /** + * Set the billingAndUsageOrder. + * + * @param billingAndUsageOrder the billingAndUsageOrder + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder billingAndUsageOrder(PreferenceValueWithoutUpdates billingAndUsageOrder) { + this.billingAndUsageOrder = billingAndUsageOrder; + return this; + } + + /** + * Set the billingAndUsageInvoices. + * + * @param billingAndUsageInvoices the billingAndUsageInvoices + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder billingAndUsageInvoices(PreferenceValueWithoutUpdates billingAndUsageInvoices) { + this.billingAndUsageInvoices = billingAndUsageInvoices; + return this; + } + + /** + * Set the billingAndUsagePayments. + * + * @param billingAndUsagePayments the billingAndUsagePayments + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder billingAndUsagePayments(PreferenceValueWithoutUpdates billingAndUsagePayments) { + this.billingAndUsagePayments = billingAndUsagePayments; + return this; + } + + /** + * Set the billingAndUsageSubscriptionsAndPromoCodes. + * + * @param billingAndUsageSubscriptionsAndPromoCodes the billingAndUsageSubscriptionsAndPromoCodes + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder billingAndUsageSubscriptionsAndPromoCodes(PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes) { + this.billingAndUsageSubscriptionsAndPromoCodes = billingAndUsageSubscriptionsAndPromoCodes; + return this; + } + + /** + * Set the billingAndUsageSpendingAlerts. + * + * @param billingAndUsageSpendingAlerts the billingAndUsageSpendingAlerts + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder billingAndUsageSpendingAlerts(PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts) { + this.billingAndUsageSpendingAlerts = billingAndUsageSpendingAlerts; + return this; + } + + /** + * Set the resourceactivityNormal. + * + * @param resourceactivityNormal the resourceactivityNormal + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder resourceactivityNormal(PreferenceValueWithoutUpdates resourceactivityNormal) { + this.resourceactivityNormal = resourceactivityNormal; + return this; + } + + /** + * Set the orderingReview. + * + * @param orderingReview the orderingReview + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder orderingReview(PreferenceValueWithoutUpdates orderingReview) { + this.orderingReview = orderingReview; + return this; + } + + /** + * Set the orderingApproved. + * + * @param orderingApproved the orderingApproved + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder orderingApproved(PreferenceValueWithoutUpdates orderingApproved) { + this.orderingApproved = orderingApproved; + return this; + } + + /** + * Set the orderingApprovedVsi. + * + * @param orderingApprovedVsi the orderingApprovedVsi + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder orderingApprovedVsi(PreferenceValueWithoutUpdates orderingApprovedVsi) { + this.orderingApprovedVsi = orderingApprovedVsi; + return this; + } + + /** + * Set the orderingApprovedServer. + * + * @param orderingApprovedServer the orderingApprovedServer + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder orderingApprovedServer(PreferenceValueWithoutUpdates orderingApprovedServer) { + this.orderingApprovedServer = orderingApprovedServer; + return this; + } + + /** + * Set the provisioningReloadComplete. + * + * @param provisioningReloadComplete the provisioningReloadComplete + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder provisioningReloadComplete(PreferenceValueWithoutUpdates provisioningReloadComplete) { + this.provisioningReloadComplete = provisioningReloadComplete; + return this; + } + + /** + * Set the provisioningCompleteVsi. + * + * @param provisioningCompleteVsi the provisioningCompleteVsi + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder provisioningCompleteVsi(PreferenceValueWithoutUpdates provisioningCompleteVsi) { + this.provisioningCompleteVsi = provisioningCompleteVsi; + return this; + } + + /** + * Set the provisioningCompleteServer. + * + * @param provisioningCompleteServer the provisioningCompleteServer + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder provisioningCompleteServer(PreferenceValueWithoutUpdates provisioningCompleteServer) { + this.provisioningCompleteServer = provisioningCompleteServer; + return this; + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the preferencesObject. + * + * @param preferencesObject the preferencesObject + * @return the ReplaceNotificationPreferencesOptions builder + */ + public Builder preferencesObject(PreferencesObject preferencesObject) { + this.incidentSeverity1 = preferencesObject.incidentSeverity1(); + this.incidentSeverity2 = preferencesObject.incidentSeverity2(); + this.incidentSeverity3 = preferencesObject.incidentSeverity3(); + this.incidentSeverity4 = preferencesObject.incidentSeverity4(); + this.maintenanceHigh = preferencesObject.maintenanceHigh(); + this.maintenanceMedium = preferencesObject.maintenanceMedium(); + this.maintenanceLow = preferencesObject.maintenanceLow(); + this.announcementsMajor = preferencesObject.announcementsMajor(); + this.announcementsMinor = preferencesObject.announcementsMinor(); + this.securityNormal = preferencesObject.securityNormal(); + this.accountNormal = preferencesObject.accountNormal(); + this.billingAndUsageOrder = preferencesObject.billingAndUsageOrder(); + this.billingAndUsageInvoices = preferencesObject.billingAndUsageInvoices(); + this.billingAndUsagePayments = preferencesObject.billingAndUsagePayments(); + this.billingAndUsageSubscriptionsAndPromoCodes = preferencesObject.billingAndUsageSubscriptionsAndPromoCodes(); + this.billingAndUsageSpendingAlerts = preferencesObject.billingAndUsageSpendingAlerts(); + this.resourceactivityNormal = preferencesObject.resourceactivityNormal(); + this.orderingReview = preferencesObject.orderingReview(); + this.orderingApproved = preferencesObject.orderingApproved(); + this.orderingApprovedVsi = preferencesObject.orderingApprovedVsi(); + this.orderingApprovedServer = preferencesObject.orderingApprovedServer(); + this.provisioningReloadComplete = preferencesObject.provisioningReloadComplete(); + this.provisioningCompleteVsi = preferencesObject.provisioningCompleteVsi(); + this.provisioningCompleteServer = preferencesObject.provisioningCompleteServer(); + return this; + } + } + + protected ReplaceNotificationPreferencesOptions() { } + + protected ReplaceNotificationPreferencesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.iamId, + "iamId cannot be empty"); + iamId = builder.iamId; + incidentSeverity1 = builder.incidentSeverity1; + incidentSeverity2 = builder.incidentSeverity2; + incidentSeverity3 = builder.incidentSeverity3; + incidentSeverity4 = builder.incidentSeverity4; + maintenanceHigh = builder.maintenanceHigh; + maintenanceMedium = builder.maintenanceMedium; + maintenanceLow = builder.maintenanceLow; + announcementsMajor = builder.announcementsMajor; + announcementsMinor = builder.announcementsMinor; + securityNormal = builder.securityNormal; + accountNormal = builder.accountNormal; + billingAndUsageOrder = builder.billingAndUsageOrder; + billingAndUsageInvoices = builder.billingAndUsageInvoices; + billingAndUsagePayments = builder.billingAndUsagePayments; + billingAndUsageSubscriptionsAndPromoCodes = builder.billingAndUsageSubscriptionsAndPromoCodes; + billingAndUsageSpendingAlerts = builder.billingAndUsageSpendingAlerts; + resourceactivityNormal = builder.resourceactivityNormal; + orderingReview = builder.orderingReview; + orderingApproved = builder.orderingApproved; + orderingApprovedVsi = builder.orderingApprovedVsi; + orderingApprovedServer = builder.orderingApprovedServer; + provisioningReloadComplete = builder.provisioningReloadComplete; + provisioningCompleteVsi = builder.provisioningCompleteVsi; + provisioningCompleteServer = builder.provisioningCompleteServer; + accountId = builder.accountId; + } + + /** + * New builder. + * + * @return a ReplaceNotificationPreferencesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the iamId. + * + * The IAM ID of the user. Must match the IAM ID in the bearer token. + * + * @return the iamId + */ + public String iamId() { + return iamId; + } + + /** + * Gets the incidentSeverity1. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity1 + */ + public PreferenceValueWithUpdates incidentSeverity1() { + return incidentSeverity1; + } + + /** + * Gets the incidentSeverity2. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity2 + */ + public PreferenceValueWithUpdates incidentSeverity2() { + return incidentSeverity2; + } + + /** + * Gets the incidentSeverity3. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity3 + */ + public PreferenceValueWithUpdates incidentSeverity3() { + return incidentSeverity3; + } + + /** + * Gets the incidentSeverity4. + * + * Preference settings for notification types that support updates. + * + * @return the incidentSeverity4 + */ + public PreferenceValueWithUpdates incidentSeverity4() { + return incidentSeverity4; + } + + /** + * Gets the maintenanceHigh. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceHigh + */ + public PreferenceValueWithUpdates maintenanceHigh() { + return maintenanceHigh; + } + + /** + * Gets the maintenanceMedium. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceMedium + */ + public PreferenceValueWithUpdates maintenanceMedium() { + return maintenanceMedium; + } + + /** + * Gets the maintenanceLow. + * + * Preference settings for notification types that support updates. + * + * @return the maintenanceLow + */ + public PreferenceValueWithUpdates maintenanceLow() { + return maintenanceLow; + } + + /** + * Gets the announcementsMajor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMajor + */ + public PreferenceValueWithoutUpdates announcementsMajor() { + return announcementsMajor; + } + + /** + * Gets the announcementsMinor. + * + * Preference settings for notification types that do not support updates. + * + * @return the announcementsMinor + */ + public PreferenceValueWithoutUpdates announcementsMinor() { + return announcementsMinor; + } + + /** + * Gets the securityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the securityNormal + */ + public PreferenceValueWithoutUpdates securityNormal() { + return securityNormal; + } + + /** + * Gets the accountNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the accountNormal + */ + public PreferenceValueWithoutUpdates accountNormal() { + return accountNormal; + } + + /** + * Gets the billingAndUsageOrder. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageOrder + */ + public PreferenceValueWithoutUpdates billingAndUsageOrder() { + return billingAndUsageOrder; + } + + /** + * Gets the billingAndUsageInvoices. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageInvoices + */ + public PreferenceValueWithoutUpdates billingAndUsageInvoices() { + return billingAndUsageInvoices; + } + + /** + * Gets the billingAndUsagePayments. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsagePayments + */ + public PreferenceValueWithoutUpdates billingAndUsagePayments() { + return billingAndUsagePayments; + } + + /** + * Gets the billingAndUsageSubscriptionsAndPromoCodes. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSubscriptionsAndPromoCodes + */ + public PreferenceValueWithoutUpdates billingAndUsageSubscriptionsAndPromoCodes() { + return billingAndUsageSubscriptionsAndPromoCodes; + } + + /** + * Gets the billingAndUsageSpendingAlerts. + * + * Preference settings for notification types that do not support updates. + * + * @return the billingAndUsageSpendingAlerts + */ + public PreferenceValueWithoutUpdates billingAndUsageSpendingAlerts() { + return billingAndUsageSpendingAlerts; + } + + /** + * Gets the resourceactivityNormal. + * + * Preference settings for notification types that do not support updates. + * + * @return the resourceactivityNormal + */ + public PreferenceValueWithoutUpdates resourceactivityNormal() { + return resourceactivityNormal; + } + + /** + * Gets the orderingReview. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingReview + */ + public PreferenceValueWithoutUpdates orderingReview() { + return orderingReview; + } + + /** + * Gets the orderingApproved. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApproved + */ + public PreferenceValueWithoutUpdates orderingApproved() { + return orderingApproved; + } + + /** + * Gets the orderingApprovedVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedVsi + */ + public PreferenceValueWithoutUpdates orderingApprovedVsi() { + return orderingApprovedVsi; + } + + /** + * Gets the orderingApprovedServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the orderingApprovedServer + */ + public PreferenceValueWithoutUpdates orderingApprovedServer() { + return orderingApprovedServer; + } + + /** + * Gets the provisioningReloadComplete. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningReloadComplete + */ + public PreferenceValueWithoutUpdates provisioningReloadComplete() { + return provisioningReloadComplete; + } + + /** + * Gets the provisioningCompleteVsi. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteVsi + */ + public PreferenceValueWithoutUpdates provisioningCompleteVsi() { + return provisioningCompleteVsi; + } + + /** + * Gets the provisioningCompleteServer. + * + * Preference settings for notification types that do not support updates. + * + * @return the provisioningCompleteServer + */ + public PreferenceValueWithoutUpdates provisioningCompleteServer() { + return provisioningCompleteServer; + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. If not provided, the account ID from the bearer token will be used. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototype.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototype.java new file mode 100644 index 0000000000..66c89ff007 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototype.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * TestDestinationRequestBodyPrototype. + * + * Classes which extend this class: + * - TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype + */ +public class TestDestinationRequestBodyPrototype extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "destination_type"; + protected static java.util.Map> discriminatorMapping; + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put("event_notifications", TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.class); + } + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + /** + * The type of the notification to test. + */ + public interface NotificationType { + /** incident. */ + String INCIDENT = "incident"; + /** announcements. */ + String ANNOUNCEMENTS = "announcements"; + /** maintenance. */ + String MAINTENANCE = "maintenance"; + /** security_bulletins. */ + String SECURITY_BULLETINS = "security_bulletins"; + /** resource. */ + String RESOURCE = "resource"; + /** billing_and_usage. */ + String BILLING_AND_USAGE = "billing_and_usage"; + } + + @SerializedName("destination_type") + protected String destinationType; + @SerializedName("notification_type") + protected String notificationType; + + protected TestDestinationRequestBodyPrototype() { } + + /** + * Gets the destinationType. + * + * The type of the destination. + * + * @return the destinationType + */ + public String destinationType() { + return destinationType; + } + + /** + * Gets the notificationType. + * + * The type of the notification to test. + * + * @return the notificationType + */ + public String notificationType() { + return notificationType; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.java new file mode 100644 index 0000000000..de47e5f969 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +/** + * Request body for testing an Event Notifications destination. + */ +public class TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype extends TestDestinationRequestBodyPrototype { + + /** + * The type of the destination. + */ + public interface DestinationType { + /** event_notifications. */ + String EVENT_NOTIFICATIONS = "event_notifications"; + } + + /** + * The type of the notification to test. + */ + public interface NotificationType { + /** incident. */ + String INCIDENT = "incident"; + /** announcements. */ + String ANNOUNCEMENTS = "announcements"; + /** maintenance. */ + String MAINTENANCE = "maintenance"; + /** security_bulletins. */ + String SECURITY_BULLETINS = "security_bulletins"; + /** resource. */ + String RESOURCE = "resource"; + /** billing_and_usage. */ + String BILLING_AND_USAGE = "billing_and_usage"; + } + + + /** + * Builder. + */ + public static class Builder { + private String destinationType; + private String notificationType; + + /** + * Instantiates a new Builder from an existing TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype instance. + * + * @param testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype the instance to initialize the Builder with + */ + public Builder(TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype) { + this.destinationType = testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.destinationType; + this.notificationType = testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.notificationType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param destinationType the destinationType + * @param notificationType the notificationType + */ + public Builder(String destinationType, String notificationType) { + this.destinationType = destinationType; + this.notificationType = notificationType; + } + + /** + * Builds a TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype. + * + * @return the new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype instance + */ + public TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype build() { + return new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype(this); + } + + /** + * Set the destinationType. + * + * @param destinationType the destinationType + * @return the TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype builder + */ + public Builder destinationType(String destinationType) { + this.destinationType = destinationType; + return this; + } + + /** + * Set the notificationType. + * + * @param notificationType the notificationType + * @return the TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype builder + */ + public Builder notificationType(String notificationType) { + this.notificationType = notificationType; + return this; + } + } + + protected TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype() { } + + protected TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.destinationType, + "destinationType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.notificationType, + "notificationType cannot be null"); + destinationType = builder.destinationType; + notificationType = builder.notificationType; + } + + /** + * New builder. + * + * @return a TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBody.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBody.java new file mode 100644 index 0000000000..2c85078454 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBody.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Response from the test notification endpoint. + */ +public class TestDestinationResponseBody extends GenericModel { + + protected String message; + + protected TestDestinationResponseBody() { } + + /** + * Gets the message. + * + * The status message that indicates the test result. + * + * @return the message + */ + public String getMessage() { + return message; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptions.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptions.java new file mode 100644 index 0000000000..3018e69f76 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptions.java @@ -0,0 +1,162 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The testDistributionListDestination options. + */ +public class TestDistributionListDestinationOptions extends GenericModel { + + protected String accountId; + protected String destinationId; + protected TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototype; + + /** + * Builder. + */ + public static class Builder { + private String accountId; + private String destinationId; + private TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototype; + + /** + * Instantiates a new Builder from an existing TestDistributionListDestinationOptions instance. + * + * @param testDistributionListDestinationOptions the instance to initialize the Builder with + */ + private Builder(TestDistributionListDestinationOptions testDistributionListDestinationOptions) { + this.accountId = testDistributionListDestinationOptions.accountId; + this.destinationId = testDistributionListDestinationOptions.destinationId; + this.testDestinationRequestBodyPrototype = testDistributionListDestinationOptions.testDestinationRequestBodyPrototype; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param accountId the accountId + * @param destinationId the destinationId + * @param testDestinationRequestBodyPrototype the testDestinationRequestBodyPrototype + */ + public Builder(String accountId, String destinationId, TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototype) { + this.accountId = accountId; + this.destinationId = destinationId; + this.testDestinationRequestBodyPrototype = testDestinationRequestBodyPrototype; + } + + /** + * Builds a TestDistributionListDestinationOptions. + * + * @return the new TestDistributionListDestinationOptions instance + */ + public TestDistributionListDestinationOptions build() { + return new TestDistributionListDestinationOptions(this); + } + + /** + * Set the accountId. + * + * @param accountId the accountId + * @return the TestDistributionListDestinationOptions builder + */ + public Builder accountId(String accountId) { + this.accountId = accountId; + return this; + } + + /** + * Set the destinationId. + * + * @param destinationId the destinationId + * @return the TestDistributionListDestinationOptions builder + */ + public Builder destinationId(String destinationId) { + this.destinationId = destinationId; + return this; + } + + /** + * Set the testDestinationRequestBodyPrototype. + * + * @param testDestinationRequestBodyPrototype the testDestinationRequestBodyPrototype + * @return the TestDistributionListDestinationOptions builder + */ + public Builder testDestinationRequestBodyPrototype(TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototype) { + this.testDestinationRequestBodyPrototype = testDestinationRequestBodyPrototype; + return this; + } + } + + protected TestDistributionListDestinationOptions() { } + + protected TestDistributionListDestinationOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.accountId, + "accountId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.destinationId, + "destinationId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.testDestinationRequestBodyPrototype, + "testDestinationRequestBodyPrototype cannot be null"); + accountId = builder.accountId; + destinationId = builder.destinationId; + testDestinationRequestBodyPrototype = builder.testDestinationRequestBodyPrototype; + } + + /** + * New builder. + * + * @return a TestDistributionListDestinationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the accountId. + * + * The IBM Cloud account ID. + * + * @return the accountId + */ + public String accountId() { + return accountId; + } + + /** + * Gets the destinationId. + * + * The ID of the destination. + * + * @return the destinationId + */ + public String destinationId() { + return destinationId; + } + + /** + * Gets the testDestinationRequestBodyPrototype. + * + * @return the testDestinationRequestBodyPrototype + */ + public TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototype() { + return testDestinationRequestBodyPrototype; + } +} + diff --git a/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/package-info.java b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/package-info.java new file mode 100644 index 0000000000..8e831f3d05 --- /dev/null +++ b/modules/platform-notifications/src/main/java/com/ibm/cloud/platform_services/platform_notifications/v1/package-info.java @@ -0,0 +1,17 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/** + * Platform Notifications v1. + */ +package com.ibm.cloud.platform_services.platform_notifications.v1; diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsIT.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsIT.java new file mode 100644 index 0000000000..867f2e887b --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsIT.java @@ -0,0 +1,496 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Acknowledgement; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationEventNotificationDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototypeEventNotificationDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreateDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreatePreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListDistributionListDestinationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListNotificationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Notification; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationsPager; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLink; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLinkWithToken; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferencesObject; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationResponseBody; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.platform_services.test.SdkIntegrationTestBase; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.CredentialUtils; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Integration test class for the PlatformNotifications service. + */ +public class PlatformNotificationsIT extends SdkIntegrationTestBase { + public PlatformNotifications service = null; + public static Map config = null; + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + private static String accountId; + private static String destinationId; + private static String iamId; + + /** + * This method provides our config filename to the base class. + */ + + public String getConfigFilename() { + return "../../platform_notifications_v1.env"; + } + + @BeforeClass + public void constructService() { + // Ask super if we should skip the tests. + if (skipTests()) { + return; + } + + service = PlatformNotifications.newInstance(); + assertNotNull(service); + assertNotNull(service.getServiceUrl()); + + // Load up our test-specific config properties. + config = CredentialUtils.getServiceProperties(PlatformNotifications.DEFAULT_SERVICE_NAME); + assertNotNull(config); + + service.setServiceUrl(config.get("URL")); + + assertFalse(config.isEmpty()); + assertEquals(service.getServiceUrl(), config.get("URL")); + + // Load test data from config + accountId = config.get("ACCOUNT_ID"); + destinationId = config.get("DESTINATION_ID"); + iamId = config.get("IAM_ID"); + + assertNotNull(accountId, "ACCOUNT_ID must be set in config"); + assertNotNull(destinationId, "DESTINATION_ID must be set in config"); + assertNotNull(iamId, "IAM_ID must be set in config"); + + service.enableRetries(4, 30); + + System.out.println("Setup complete."); + } + + @Test + public void testListNotifications() throws Exception { + try { + ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder() + .accountId(accountId) + .limit(Long.valueOf("50")) + .build(); + + // Invoke operation + Response response = service.listNotifications(listNotificationsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + NotificationCollection notificationCollectionResult = response.getResult(); + assertNotNull(notificationCollectionResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testListNotifications" }) + public void testListNotificationsWithPager() throws Exception { + try { + ListNotificationsOptions options = new ListNotificationsOptions.Builder() + .accountId(accountId) + .limit(Long.valueOf("50")) + .build(); + + // Test getNext(). + List allResults = new ArrayList<>(); + NotificationsPager pager = new NotificationsPager(service, options); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + assertNotNull(nextPage); + allResults.addAll(nextPage); + } + assertFalse(allResults.isEmpty()); + + // Test getAll(); + pager = new NotificationsPager(service, options); + List allItems = pager.getAll(); + assertNotNull(allItems); + assertFalse(allItems.isEmpty()); + + assertEquals(allItems.size(), allResults.size()); + System.out.println(String.format("Retrieved a total of %d item(s) with pagination.", allResults.size())); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testListNotifications" }) + public void testGetAcknowledgement() throws Exception { + try { + GetAcknowledgementOptions getAcknowledgementOptions = new GetAcknowledgementOptions.Builder() + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.getAcknowledgement(getAcknowledgementOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + Acknowledgement acknowledgementResult = response.getResult(); + assertNotNull(acknowledgementResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetAcknowledgement" }) + public void testReplaceNotificationAcknowledgement() throws Exception { + try { + ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptions = new ReplaceNotificationAcknowledgementOptions.Builder() + .lastAcknowledged(Long.valueOf("1772804159452")) + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.replaceNotificationAcknowledgement(replaceNotificationAcknowledgementOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + Acknowledgement acknowledgementResult = response.getResult(); + assertNotNull(acknowledgementResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testReplaceNotificationAcknowledgement" }) + public void testListDistributionListDestinations() throws Exception { + try { + ListDistributionListDestinationsOptions listDistributionListDestinationsOptions = new ListDistributionListDestinationsOptions.Builder() + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.listDistributionListDestinations(listDistributionListDestinationsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + AddDestinationCollection addDestinationCollectionResult = response.getResult(); + assertNotNull(addDestinationCollectionResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testListDistributionListDestinations" }) + public void testCreateDistributionListDestination() throws Exception { + try { + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeModel = new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder() + .destinationId(destinationId) + .destinationType("event_notifications") + .build(); + + CreateDistributionListDestinationOptions createDistributionListDestinationOptions = new CreateDistributionListDestinationOptions.Builder() + .accountId(accountId) + .addDestinationPrototype(addDestinationPrototypeModel) + .build(); + + // Invoke operation + Response response = service.createDistributionListDestination(createDistributionListDestinationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + AddDestination addDestinationResult = response.getResult(); + assertNotNull(addDestinationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testCreateDistributionListDestination" }) + public void testGetDistributionListDestination() throws Exception { + try { + GetDistributionListDestinationOptions getDistributionListDestinationOptions = new GetDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .build(); + + // Invoke operation + Response response = service.getDistributionListDestination(getDistributionListDestinationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + AddDestination addDestinationResult = response.getResult(); + assertNotNull(addDestinationResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetDistributionListDestination" }) + public void testTestDistributionListDestination() throws Exception { + try { + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder() + .destinationType("event_notifications") + .notificationType("incident") + .build(); + + TestDistributionListDestinationOptions testDistributionListDestinationOptions = new TestDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .testDestinationRequestBodyPrototype(testDestinationRequestBodyPrototypeModel) + .build(); + + // Invoke operation + Response response = service.testDistributionListDestination(testDistributionListDestinationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + TestDestinationResponseBody testDestinationResponseBodyResult = response.getResult(); + assertNotNull(testDestinationResponseBodyResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetDistributionListDestination" }) + public void testCreatePreferences() throws Exception { + try { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + + CreatePreferencesOptions createPreferencesOptions = new CreatePreferencesOptions.Builder() + .iamId(iamId) + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.createPreferences(createPreferencesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 201); + + PreferencesObject preferencesObjectResult = response.getResult(); + assertNotNull(preferencesObjectResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testCreatePreferences" }) + public void testGetPreferences() throws Exception { + try { + GetPreferencesOptions getPreferencesOptions = new GetPreferencesOptions.Builder() + .iamId(iamId) + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.getPreferences(getPreferencesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PreferencesObject preferencesObjectResult = response.getResult(); + assertNotNull(preferencesObjectResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testGetPreferences" }) + public void testReplaceNotificationPreferences() throws Exception { + try { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + + ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptions = new ReplaceNotificationPreferencesOptions.Builder() + .iamId(iamId) + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.replaceNotificationPreferences(replaceNotificationPreferencesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + PreferencesObject preferencesObjectResult = response.getResult(); + assertNotNull(preferencesObjectResult); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testReplaceNotificationPreferences" }) + public void testDeleteDistributionListDestination() throws Exception { + try { + DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptions = new DeleteDistributionListDestinationOptions.Builder() + .accountId(accountId) + .destinationId(destinationId) + .build(); + + // Invoke operation + Response response = service.deleteDistributionListDestination(deleteDistributionListDestinationOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @Test(dependsOnMethods = { "testDeleteDistributionListDestination" }) + public void testDeleteNotificationPreferences() throws Exception { + try { + DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptions = new DeleteNotificationPreferencesOptions.Builder() + .iamId(iamId) + .accountId(accountId) + .build(); + + // Invoke operation + Response response = service.deleteNotificationPreferences(deleteNotificationPreferencesOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @AfterClass + public void tearDown() { + // Add any clean up logic here + System.out.println("Clean up complete."); + } + } diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsTest.java new file mode 100644 index 0000000000..e705290c16 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/PlatformNotificationsTest.java @@ -0,0 +1,877 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1; + +import com.ibm.cloud.platform_services.platform_notifications.v1.PlatformNotifications; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Acknowledgement; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationEventNotificationDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototypeEventNotificationDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreateDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreatePreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListDistributionListDestinationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListNotificationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Notification; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationsPager; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLink; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLinkWithToken; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferencesObject; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationResponseBody; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PlatformNotifications service. + */ +public class PlatformNotificationsTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected PlatformNotifications platformNotificationsService; + + // Construct the service with a null authenticator (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + new PlatformNotifications(serviceName, null); + } + + // Test the listNotifications operation with a valid options model parameter + @Test + public void testListNotificationsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"limit\": 50, \"total_count\": 232, \"first\": {\"href\": \"https://notifications.cloud.ibm.com/api/v1/notifications?limit=50\"}, \"previous\": {\"href\": \"https://notifications.cloud.ibm.com/api/v1/notifications?start=3fe78a36b9aa7f26&limit=50\", \"start\": \"3fe78a36b9aa7f26\"}, \"next\": {\"href\": \"https://notifications.cloud.ibm.com/api/v1/notifications?start=3fe78a36b9aa7f26&limit=50\", \"start\": \"3fe78a36b9aa7f26\"}, \"last\": {\"href\": \"https://notifications.cloud.ibm.com/api/v1/notifications?start=3fe78a36b9aa7f26&limit=50\", \"start\": \"3fe78a36b9aa7f26\"}, \"notifications\": [{\"title\": \"System Maintenance Scheduled\", \"body\": \"Scheduled maintenance will occur on March 15th from 10:00 AM to 11:00 AM UTC.\", \"id\": \"12345\", \"category\": \"maintenance\", \"component_names\": [\"componentNames\"], \"start_time\": 1771791490, \"is_global\": false, \"state\": \"new\", \"regions\": [\"regions\"], \"crn_masks\": [\"crnMasks\"], \"record_id\": \"rec-67890\", \"source_id\": \"src-11111\", \"completion_code\": \"successful\", \"end_time\": 1771791490, \"update_time\": 1771791490, \"severity\": 2, \"lucene_query\": \"region:us-south AND service_name:event-notifications\", \"resource_link\": \"https://cloud.ibm.com/status/incident/12345\", \"creation_timestamp\": 1772804159452}]}"; + String listNotificationsPath = "/v1/notifications"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListNotificationsOptions model + ListNotificationsOptions listNotificationsOptionsModel = new ListNotificationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .start("3fe78a36b9aa7f26") + .limit(Long.valueOf("50")) + .build(); + + // Invoke listNotifications() with a valid options model and verify the result + Response response = platformNotificationsService.listNotifications(listNotificationsOptionsModel).execute(); + assertNotNull(response); + NotificationCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listNotificationsPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(query.get("start"), "3fe78a36b9aa7f26"); + assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("50")); + } + + // Test the listNotifications operation with and without retries enabled + @Test + public void testListNotificationsWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testListNotificationsWOptions(); + + platformNotificationsService.disableRetries(); + testListNotificationsWOptions(); + } + + // Test the listNotifications operation using the NotificationsPager.getNext() method + @Test + public void testListNotificationsWithPagerGetNext() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"total_count\":2,\"limit\":1,\"notifications\":[{\"title\":\"System Maintenance Scheduled\",\"body\":\"Scheduled maintenance will occur on March 15th from 10:00 AM to 11:00 AM UTC.\",\"id\":\"12345\",\"category\":\"maintenance\",\"component_names\":[\"componentNames\"],\"start_time\":1771791490,\"is_global\":false,\"state\":\"new\",\"regions\":[\"regions\"],\"crn_masks\":[\"crnMasks\"],\"record_id\":\"rec-67890\",\"source_id\":\"src-11111\",\"completion_code\":\"successful\",\"end_time\":1771791490,\"update_time\":1771791490,\"severity\":2,\"lucene_query\":\"region:us-south AND service_name:event-notifications\",\"resource_link\":\"https://cloud.ibm.com/status/incident/12345\",\"creation_timestamp\":1772804159452}]}"; + String mockResponsePage2 = "{\"total_count\":2,\"limit\":1,\"notifications\":[{\"title\":\"System Maintenance Scheduled\",\"body\":\"Scheduled maintenance will occur on March 15th from 10:00 AM to 11:00 AM UTC.\",\"id\":\"12345\",\"category\":\"maintenance\",\"component_names\":[\"componentNames\"],\"start_time\":1771791490,\"is_global\":false,\"state\":\"new\",\"regions\":[\"regions\"],\"crn_masks\":[\"crnMasks\"],\"record_id\":\"rec-67890\",\"source_id\":\"src-11111\",\"completion_code\":\"successful\",\"end_time\":1771791490,\"update_time\":1771791490,\"severity\":2,\"lucene_query\":\"region:us-south AND service_name:event-notifications\",\"resource_link\":\"https://cloud.ibm.com/status/incident/12345\",\"creation_timestamp\":1772804159452}]}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .limit(Long.valueOf("50")) + .build(); + + List allResults = new ArrayList<>(); + NotificationsPager pager = new NotificationsPager(platformNotificationsService, listNotificationsOptions); + while (pager.hasNext()) { + List nextPage = pager.getNext(); + assertNotNull(nextPage); + allResults.addAll(nextPage); + } + assertEquals(allResults.size(), 2); + } + + // Test the listNotifications operation using the NotificationsPager.getAll() method + @Test + public void testListNotificationsWithPagerGetAll() throws Throwable { + // Set up the two-page mock response. + String mockResponsePage1 = "{\"next\":{\"start\":\"1\"},\"total_count\":2,\"limit\":1,\"notifications\":[{\"title\":\"System Maintenance Scheduled\",\"body\":\"Scheduled maintenance will occur on March 15th from 10:00 AM to 11:00 AM UTC.\",\"id\":\"12345\",\"category\":\"maintenance\",\"component_names\":[\"componentNames\"],\"start_time\":1771791490,\"is_global\":false,\"state\":\"new\",\"regions\":[\"regions\"],\"crn_masks\":[\"crnMasks\"],\"record_id\":\"rec-67890\",\"source_id\":\"src-11111\",\"completion_code\":\"successful\",\"end_time\":1771791490,\"update_time\":1771791490,\"severity\":2,\"lucene_query\":\"region:us-south AND service_name:event-notifications\",\"resource_link\":\"https://cloud.ibm.com/status/incident/12345\",\"creation_timestamp\":1772804159452}]}"; + String mockResponsePage2 = "{\"total_count\":2,\"limit\":1,\"notifications\":[{\"title\":\"System Maintenance Scheduled\",\"body\":\"Scheduled maintenance will occur on March 15th from 10:00 AM to 11:00 AM UTC.\",\"id\":\"12345\",\"category\":\"maintenance\",\"component_names\":[\"componentNames\"],\"start_time\":1771791490,\"is_global\":false,\"state\":\"new\",\"regions\":[\"regions\"],\"crn_masks\":[\"crnMasks\"],\"record_id\":\"rec-67890\",\"source_id\":\"src-11111\",\"completion_code\":\"successful\",\"end_time\":1771791490,\"update_time\":1771791490,\"severity\":2,\"lucene_query\":\"region:us-south AND service_name:event-notifications\",\"resource_link\":\"https://cloud.ibm.com/status/incident/12345\",\"creation_timestamp\":1772804159452}]}"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage1)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponsePage2)); + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(400) + .setBody("{\"message\": \"No more results available!\"}")); + + ListNotificationsOptions listNotificationsOptions = new ListNotificationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .limit(Long.valueOf("50")) + .build(); + + NotificationsPager pager = new NotificationsPager(platformNotificationsService, listNotificationsOptions); + List allResults = pager.getAll(); + assertNotNull(allResults); + assertEquals(allResults.size(), 2); + } + + // Test the getAcknowledgement operation with a valid options model parameter + @Test + public void testGetAcknowledgementWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"has_unread\": true, \"last_acknowledged\": 1772804159452}"; + String getAcknowledgementPath = "/v1/notifications/acknowledgement"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetAcknowledgementOptions model + GetAcknowledgementOptions getAcknowledgementOptionsModel = new GetAcknowledgementOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke getAcknowledgement() with a valid options model and verify the result + Response response = platformNotificationsService.getAcknowledgement(getAcknowledgementOptionsModel).execute(); + assertNotNull(response); + Acknowledgement responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAcknowledgementPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the getAcknowledgement operation with and without retries enabled + @Test + public void testGetAcknowledgementWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testGetAcknowledgementWOptions(); + + platformNotificationsService.disableRetries(); + testGetAcknowledgementWOptions(); + } + + // Test the replaceNotificationAcknowledgement operation with a valid options model parameter + @Test + public void testReplaceNotificationAcknowledgementWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"has_unread\": true, \"last_acknowledged\": 1772804159452}"; + String replaceNotificationAcknowledgementPath = "/v1/notifications/acknowledgement"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ReplaceNotificationAcknowledgementOptions model + ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptionsModel = new ReplaceNotificationAcknowledgementOptions.Builder() + .lastAcknowledged(Long.valueOf("1772804159452")) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke replaceNotificationAcknowledgement() with a valid options model and verify the result + Response response = platformNotificationsService.replaceNotificationAcknowledgement(replaceNotificationAcknowledgementOptionsModel).execute(); + assertNotNull(response); + Acknowledgement responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, replaceNotificationAcknowledgementPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the replaceNotificationAcknowledgement operation with and without retries enabled + @Test + public void testReplaceNotificationAcknowledgementWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testReplaceNotificationAcknowledgementWOptions(); + + platformNotificationsService.disableRetries(); + testReplaceNotificationAcknowledgementWOptions(); + } + + // Test the replaceNotificationAcknowledgement operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceNotificationAcknowledgementNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.replaceNotificationAcknowledgement(null).execute(); + } + + // Test the listDistributionListDestinations operation with a valid options model parameter + @Test + public void testListDistributionListDestinationsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"destinations\": [{\"destination_id\": \"12345678-1234-1234-1234-123456789012\", \"destination_type\": \"event_notifications\"}]}"; + String listDistributionListDestinationsPath = "/v1/distribution_lists/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/destinations"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the ListDistributionListDestinationsOptions model + ListDistributionListDestinationsOptions listDistributionListDestinationsOptionsModel = new ListDistributionListDestinationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke listDistributionListDestinations() with a valid options model and verify the result + Response response = platformNotificationsService.listDistributionListDestinations(listDistributionListDestinationsOptionsModel).execute(); + assertNotNull(response); + AddDestinationCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDistributionListDestinationsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the listDistributionListDestinations operation with and without retries enabled + @Test + public void testListDistributionListDestinationsWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testListDistributionListDestinationsWOptions(); + + platformNotificationsService.disableRetries(); + testListDistributionListDestinationsWOptions(); + } + + // Test the listDistributionListDestinations operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDistributionListDestinationsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.listDistributionListDestinations(null).execute(); + } + + // Test the createDistributionListDestination operation with a valid options model parameter + @Test + public void testCreateDistributionListDestinationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"destination_id\": \"12345678-1234-1234-1234-123456789012\", \"destination_type\": \"event_notifications\"}"; + String createDistributionListDestinationPath = "/v1/distribution_lists/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/destinations"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the AddDestinationPrototypeEventNotificationDestinationPrototype model + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeModel = new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder() + .destinationId("12345678-1234-1234-1234-123456789012") + .destinationType("event_notifications") + .build(); + + // Construct an instance of the CreateDistributionListDestinationOptions model + CreateDistributionListDestinationOptions createDistributionListDestinationOptionsModel = new CreateDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .addDestinationPrototype(addDestinationPrototypeModel) + .build(); + + // Invoke createDistributionListDestination() with a valid options model and verify the result + Response response = platformNotificationsService.createDistributionListDestination(createDistributionListDestinationOptionsModel).execute(); + assertNotNull(response); + AddDestination responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDistributionListDestinationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createDistributionListDestination operation with and without retries enabled + @Test + public void testCreateDistributionListDestinationWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testCreateDistributionListDestinationWOptions(); + + platformNotificationsService.disableRetries(); + testCreateDistributionListDestinationWOptions(); + } + + // Test the createDistributionListDestination operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDistributionListDestinationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.createDistributionListDestination(null).execute(); + } + + // Test the getDistributionListDestination operation with a valid options model parameter + @Test + public void testGetDistributionListDestinationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"destination_id\": \"12345678-1234-1234-1234-123456789012\", \"destination_type\": \"event_notifications\"}"; + String getDistributionListDestinationPath = "/v1/distribution_lists/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/destinations/12345678-1234-1234-1234-123456789012"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetDistributionListDestinationOptions model + GetDistributionListDestinationOptions getDistributionListDestinationOptionsModel = new GetDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .build(); + + // Invoke getDistributionListDestination() with a valid options model and verify the result + Response response = platformNotificationsService.getDistributionListDestination(getDistributionListDestinationOptionsModel).execute(); + assertNotNull(response); + AddDestination responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDistributionListDestinationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getDistributionListDestination operation with and without retries enabled + @Test + public void testGetDistributionListDestinationWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testGetDistributionListDestinationWOptions(); + + platformNotificationsService.disableRetries(); + testGetDistributionListDestinationWOptions(); + } + + // Test the getDistributionListDestination operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDistributionListDestinationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.getDistributionListDestination(null).execute(); + } + + // Test the deleteDistributionListDestination operation with a valid options model parameter + @Test + public void testDeleteDistributionListDestinationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteDistributionListDestinationPath = "/v1/distribution_lists/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/destinations/12345678-1234-1234-1234-123456789012"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteDistributionListDestinationOptions model + DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptionsModel = new DeleteDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .build(); + + // Invoke deleteDistributionListDestination() with a valid options model and verify the result + Response response = platformNotificationsService.deleteDistributionListDestination(deleteDistributionListDestinationOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDistributionListDestinationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteDistributionListDestination operation with and without retries enabled + @Test + public void testDeleteDistributionListDestinationWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testDeleteDistributionListDestinationWOptions(); + + platformNotificationsService.disableRetries(); + testDeleteDistributionListDestinationWOptions(); + } + + // Test the deleteDistributionListDestination operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDistributionListDestinationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.deleteDistributionListDestination(null).execute(); + } + + // Test the testDistributionListDestination operation with a valid options model parameter + @Test + public void testTestDistributionListDestinationWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"message\": \"success\"}"; + String testDistributionListDestinationPath = "/v1/distribution_lists/a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/destinations/12345678-1234-1234-1234-123456789012/test"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype model + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder() + .destinationType("event_notifications") + .notificationType("incident") + .build(); + + // Construct an instance of the TestDistributionListDestinationOptions model + TestDistributionListDestinationOptions testDistributionListDestinationOptionsModel = new TestDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .testDestinationRequestBodyPrototype(testDestinationRequestBodyPrototypeModel) + .build(); + + // Invoke testDistributionListDestination() with a valid options model and verify the result + Response response = platformNotificationsService.testDistributionListDestination(testDistributionListDestinationOptionsModel).execute(); + assertNotNull(response); + TestDestinationResponseBody responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, testDistributionListDestinationPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the testDistributionListDestination operation with and without retries enabled + @Test + public void testTestDistributionListDestinationWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testTestDistributionListDestinationWOptions(); + + platformNotificationsService.disableRetries(); + testTestDistributionListDestinationWOptions(); + } + + // Test the testDistributionListDestination operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTestDistributionListDestinationNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.testDistributionListDestination(null).execute(); + } + + // Test the getPreferences operation with a valid options model parameter + @Test + public void testGetPreferencesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"incident_severity1\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity2\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity3\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity4\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_high\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_medium\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_low\": {\"channels\": [\"email\"], \"updates\": true}, \"announcements_major\": {\"channels\": [\"email\"]}, \"announcements_minor\": {\"channels\": [\"email\"]}, \"security_normal\": {\"channels\": [\"email\"]}, \"account_normal\": {\"channels\": [\"email\"]}, \"billing_and_usage_order\": {\"channels\": [\"email\"]}, \"billing_and_usage_invoices\": {\"channels\": [\"email\"]}, \"billing_and_usage_payments\": {\"channels\": [\"email\"]}, \"billing_and_usage_subscriptions_and_promo_codes\": {\"channels\": [\"email\"]}, \"billing_and_usage_spending_alerts\": {\"channels\": [\"email\"]}, \"resourceactivity_normal\": {\"channels\": [\"email\"]}, \"ordering_review\": {\"channels\": [\"email\"]}, \"ordering_approved\": {\"channels\": [\"email\"]}, \"ordering_approved_vsi\": {\"channels\": [\"email\"]}, \"ordering_approved_server\": {\"channels\": [\"email\"]}, \"provisioning_reload_complete\": {\"channels\": [\"email\"]}, \"provisioning_complete_vsi\": {\"channels\": [\"email\"]}, \"provisioning_complete_server\": {\"channels\": [\"email\"]}}"; + String getPreferencesPath = "/v1/notifications/IBMid-1234567890/preferences"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetPreferencesOptions model + GetPreferencesOptions getPreferencesOptionsModel = new GetPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke getPreferences() with a valid options model and verify the result + Response response = platformNotificationsService.getPreferences(getPreferencesOptionsModel).execute(); + assertNotNull(response); + PreferencesObject responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getPreferencesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the getPreferences operation with and without retries enabled + @Test + public void testGetPreferencesWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testGetPreferencesWOptions(); + + platformNotificationsService.disableRetries(); + testGetPreferencesWOptions(); + } + + // Test the getPreferences operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPreferencesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.getPreferences(null).execute(); + } + + // Test the createPreferences operation with a valid options model parameter + @Test + public void testCreatePreferencesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"incident_severity1\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity2\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity3\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity4\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_high\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_medium\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_low\": {\"channels\": [\"email\"], \"updates\": true}, \"announcements_major\": {\"channels\": [\"email\"]}, \"announcements_minor\": {\"channels\": [\"email\"]}, \"security_normal\": {\"channels\": [\"email\"]}, \"account_normal\": {\"channels\": [\"email\"]}, \"billing_and_usage_order\": {\"channels\": [\"email\"]}, \"billing_and_usage_invoices\": {\"channels\": [\"email\"]}, \"billing_and_usage_payments\": {\"channels\": [\"email\"]}, \"billing_and_usage_subscriptions_and_promo_codes\": {\"channels\": [\"email\"]}, \"billing_and_usage_spending_alerts\": {\"channels\": [\"email\"]}, \"resourceactivity_normal\": {\"channels\": [\"email\"]}, \"ordering_review\": {\"channels\": [\"email\"]}, \"ordering_approved\": {\"channels\": [\"email\"]}, \"ordering_approved_vsi\": {\"channels\": [\"email\"]}, \"ordering_approved_server\": {\"channels\": [\"email\"]}, \"provisioning_reload_complete\": {\"channels\": [\"email\"]}, \"provisioning_complete_vsi\": {\"channels\": [\"email\"]}, \"provisioning_complete_server\": {\"channels\": [\"email\"]}}"; + String createPreferencesPath = "/v1/notifications/IBMid-1234567890/preferences"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + // Construct an instance of the PreferenceValueWithUpdates model + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + + // Construct an instance of the PreferenceValueWithoutUpdates model + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + + // Construct an instance of the CreatePreferencesOptions model + CreatePreferencesOptions createPreferencesOptionsModel = new CreatePreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke createPreferences() with a valid options model and verify the result + Response response = platformNotificationsService.createPreferences(createPreferencesOptionsModel).execute(); + assertNotNull(response); + PreferencesObject responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createPreferencesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the createPreferences operation with and without retries enabled + @Test + public void testCreatePreferencesWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testCreatePreferencesWOptions(); + + platformNotificationsService.disableRetries(); + testCreatePreferencesWOptions(); + } + + // Test the createPreferences operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePreferencesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.createPreferences(null).execute(); + } + + // Test the replaceNotificationPreferences operation with a valid options model parameter + @Test + public void testReplaceNotificationPreferencesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"incident_severity1\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity2\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity3\": {\"channels\": [\"email\"], \"updates\": true}, \"incident_severity4\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_high\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_medium\": {\"channels\": [\"email\"], \"updates\": true}, \"maintenance_low\": {\"channels\": [\"email\"], \"updates\": true}, \"announcements_major\": {\"channels\": [\"email\"]}, \"announcements_minor\": {\"channels\": [\"email\"]}, \"security_normal\": {\"channels\": [\"email\"]}, \"account_normal\": {\"channels\": [\"email\"]}, \"billing_and_usage_order\": {\"channels\": [\"email\"]}, \"billing_and_usage_invoices\": {\"channels\": [\"email\"]}, \"billing_and_usage_payments\": {\"channels\": [\"email\"]}, \"billing_and_usage_subscriptions_and_promo_codes\": {\"channels\": [\"email\"]}, \"billing_and_usage_spending_alerts\": {\"channels\": [\"email\"]}, \"resourceactivity_normal\": {\"channels\": [\"email\"]}, \"ordering_review\": {\"channels\": [\"email\"]}, \"ordering_approved\": {\"channels\": [\"email\"]}, \"ordering_approved_vsi\": {\"channels\": [\"email\"]}, \"ordering_approved_server\": {\"channels\": [\"email\"]}, \"provisioning_reload_complete\": {\"channels\": [\"email\"]}, \"provisioning_complete_vsi\": {\"channels\": [\"email\"]}, \"provisioning_complete_server\": {\"channels\": [\"email\"]}}"; + String replaceNotificationPreferencesPath = "/v1/notifications/IBMid-1234567890/preferences"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the PreferenceValueWithUpdates model + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + + // Construct an instance of the PreferenceValueWithoutUpdates model + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + + // Construct an instance of the ReplaceNotificationPreferencesOptions model + ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptionsModel = new ReplaceNotificationPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke replaceNotificationPreferences() with a valid options model and verify the result + Response response = platformNotificationsService.replaceNotificationPreferences(replaceNotificationPreferencesOptionsModel).execute(); + assertNotNull(response); + PreferencesObject responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, replaceNotificationPreferencesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the replaceNotificationPreferences operation with and without retries enabled + @Test + public void testReplaceNotificationPreferencesWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testReplaceNotificationPreferencesWOptions(); + + platformNotificationsService.disableRetries(); + testReplaceNotificationPreferencesWOptions(); + } + + // Test the replaceNotificationPreferences operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceNotificationPreferencesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.replaceNotificationPreferences(null).execute(); + } + + // Test the deleteNotificationPreferences operation with a valid options model parameter + @Test + public void testDeleteNotificationPreferencesWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteNotificationPreferencesPath = "/v1/notifications/IBMid-1234567890/preferences"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteNotificationPreferencesOptions model + DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptionsModel = new DeleteNotificationPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + + // Invoke deleteNotificationPreferences() with a valid options model and verify the result + Response response = platformNotificationsService.deleteNotificationPreferences(deleteNotificationPreferencesOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteNotificationPreferencesPath); + // Verify query params + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + assertEquals(query.get("account_id"), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + // Test the deleteNotificationPreferences operation with and without retries enabled + @Test + public void testDeleteNotificationPreferencesWRetries() throws Throwable { + platformNotificationsService.enableRetries(4, 30); + testDeleteNotificationPreferencesWOptions(); + + platformNotificationsService.disableRetries(); + testDeleteNotificationPreferencesWOptions(); + } + + // Test the deleteNotificationPreferences operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteNotificationPreferencesNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + platformNotificationsService.deleteNotificationPreferences(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + platformNotificationsService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + System.setProperty("TESTSERVICE_AUTH_TYPE", "noAuth"); + final String serviceName = "testService"; + + platformNotificationsService = PlatformNotifications.newInstance(serviceName); + String url = server.url("/").toString(); + platformNotificationsService.setServiceUrl(url); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AcknowledgementTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AcknowledgementTest.java new file mode 100644 index 0000000000..dd3d10b662 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AcknowledgementTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Acknowledgement; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Acknowledgement model. + */ +public class AcknowledgementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAcknowledgement() throws Throwable { + Acknowledgement acknowledgementModel = new Acknowledgement(); + assertNull(acknowledgementModel.isHasUnread()); + assertNull(acknowledgementModel.getLastAcknowledged()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollectionTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollectionTest.java new file mode 100644 index 0000000000..03ab99a13c --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationCollectionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationEventNotificationDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AddDestinationCollection model. + */ +public class AddDestinationCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDestinationCollection() throws Throwable { + AddDestinationCollection addDestinationCollectionModel = new AddDestinationCollection(); + assertNull(addDestinationCollectionModel.getDestinations()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestinationTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestinationTest.java new file mode 100644 index 0000000000..0902581bac --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationEventNotificationDestinationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationEventNotificationDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AddDestinationEventNotificationDestination model. + */ +public class AddDestinationEventNotificationDestinationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDestinationEventNotificationDestination() throws Throwable { + AddDestinationEventNotificationDestination addDestinationEventNotificationDestinationModel = new AddDestinationEventNotificationDestination(); + assertNull(addDestinationEventNotificationDestinationModel.getDestinationId()); + assertNull(addDestinationEventNotificationDestinationModel.getDestinationType()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototypeTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototypeTest.java new file mode 100644 index 0000000000..9495fae21e --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeEventNotificationDestinationPrototypeTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototypeEventNotificationDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AddDestinationPrototypeEventNotificationDestinationPrototype model. + */ +public class AddDestinationPrototypeEventNotificationDestinationPrototypeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDestinationPrototypeEventNotificationDestinationPrototype() throws Throwable { + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeEventNotificationDestinationPrototypeModel = new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder() + .destinationId("12345678-1234-1234-1234-123456789012") + .destinationType("event_notifications") + .build(); + assertEquals(addDestinationPrototypeEventNotificationDestinationPrototypeModel.destinationId(), "12345678-1234-1234-1234-123456789012"); + assertEquals(addDestinationPrototypeEventNotificationDestinationPrototypeModel.destinationType(), "event_notifications"); + + String json = TestUtilities.serialize(addDestinationPrototypeEventNotificationDestinationPrototypeModel); + + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeEventNotificationDestinationPrototypeModelNew = TestUtilities.deserialize(json, AddDestinationPrototypeEventNotificationDestinationPrototype.class); + assertTrue(addDestinationPrototypeEventNotificationDestinationPrototypeModelNew instanceof AddDestinationPrototypeEventNotificationDestinationPrototype); + assertEquals(addDestinationPrototypeEventNotificationDestinationPrototypeModelNew.destinationId(), "12345678-1234-1234-1234-123456789012"); + assertEquals(addDestinationPrototypeEventNotificationDestinationPrototypeModelNew.destinationType(), "event_notifications"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDestinationPrototypeEventNotificationDestinationPrototypeError() throws Throwable { + new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeTest.java new file mode 100644 index 0000000000..3756149c81 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationPrototypeTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AddDestinationPrototype model. + */ +public class AddDestinationPrototypeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testAddDestinationPrototype() throws Throwable { + AddDestinationPrototype addDestinationPrototypeModel = new AddDestinationPrototype(); + assertNotNull(addDestinationPrototypeModel); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationTest.java new file mode 100644 index 0000000000..5b6a9e47c0 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/AddDestinationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestination; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the AddDestination model. + */ +public class AddDestinationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testAddDestination() throws Throwable { + AddDestination addDestinationModel = new AddDestination(); + assertNotNull(addDestinationModel); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptionsTest.java new file mode 100644 index 0000000000..fca42f8d39 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreateDistributionListDestinationOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.AddDestinationPrototypeEventNotificationDestinationPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreateDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CreateDistributionListDestinationOptions model. + */ +public class CreateDistributionListDestinationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDistributionListDestinationOptions() throws Throwable { + AddDestinationPrototypeEventNotificationDestinationPrototype addDestinationPrototypeModel = new AddDestinationPrototypeEventNotificationDestinationPrototype.Builder() + .destinationId("12345678-1234-1234-1234-123456789012") + .destinationType("event_notifications") + .build(); + assertEquals(addDestinationPrototypeModel.destinationId(), "12345678-1234-1234-1234-123456789012"); + assertEquals(addDestinationPrototypeModel.destinationType(), "event_notifications"); + + CreateDistributionListDestinationOptions createDistributionListDestinationOptionsModel = new CreateDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .addDestinationPrototype(addDestinationPrototypeModel) + .build(); + assertEquals(createDistributionListDestinationOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(createDistributionListDestinationOptionsModel.addDestinationPrototype(), addDestinationPrototypeModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDistributionListDestinationOptionsError() throws Throwable { + new CreateDistributionListDestinationOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptionsTest.java new file mode 100644 index 0000000000..1f49decf38 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/CreatePreferencesOptionsTest.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.CreatePreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the CreatePreferencesOptions model. + */ +public class CreatePreferencesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreatePreferencesOptions() throws Throwable { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + assertEquals(preferenceValueWithUpdatesModel.channels(), java.util.Arrays.asList("email")); + assertEquals(preferenceValueWithUpdatesModel.updates(), Boolean.valueOf(true)); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + assertEquals(preferenceValueWithoutUpdatesModel.channels(), java.util.Arrays.asList("email")); + + CreatePreferencesOptions createPreferencesOptionsModel = new CreatePreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(createPreferencesOptionsModel.iamId(), "IBMid-1234567890"); + assertEquals(createPreferencesOptionsModel.incidentSeverity1(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.incidentSeverity2(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.incidentSeverity3(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.incidentSeverity4(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.maintenanceHigh(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.maintenanceMedium(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.maintenanceLow(), preferenceValueWithUpdatesModel); + assertEquals(createPreferencesOptionsModel.announcementsMajor(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.announcementsMinor(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.securityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.accountNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.billingAndUsageOrder(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.billingAndUsageInvoices(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.billingAndUsagePayments(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.billingAndUsageSubscriptionsAndPromoCodes(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.billingAndUsageSpendingAlerts(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.resourceactivityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.orderingReview(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.orderingApproved(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.orderingApprovedVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.orderingApprovedServer(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.provisioningReloadComplete(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.provisioningCompleteVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.provisioningCompleteServer(), preferenceValueWithoutUpdatesModel); + assertEquals(createPreferencesOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreatePreferencesOptionsError() throws Throwable { + new CreatePreferencesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptionsTest.java new file mode 100644 index 0000000000..109520e783 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteDistributionListDestinationOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DeleteDistributionListDestinationOptions model. + */ +public class DeleteDistributionListDestinationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDistributionListDestinationOptions() throws Throwable { + DeleteDistributionListDestinationOptions deleteDistributionListDestinationOptionsModel = new DeleteDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .build(); + assertEquals(deleteDistributionListDestinationOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(deleteDistributionListDestinationOptionsModel.destinationId(), "12345678-1234-1234-1234-123456789012"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDistributionListDestinationOptionsError() throws Throwable { + new DeleteDistributionListDestinationOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptionsTest.java new file mode 100644 index 0000000000..366f95bd9c --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/DeleteNotificationPreferencesOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.DeleteNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the DeleteNotificationPreferencesOptions model. + */ +public class DeleteNotificationPreferencesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteNotificationPreferencesOptions() throws Throwable { + DeleteNotificationPreferencesOptions deleteNotificationPreferencesOptionsModel = new DeleteNotificationPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(deleteNotificationPreferencesOptionsModel.iamId(), "IBMid-1234567890"); + assertEquals(deleteNotificationPreferencesOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteNotificationPreferencesOptionsError() throws Throwable { + new DeleteNotificationPreferencesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptionsTest.java new file mode 100644 index 0000000000..1fd7a4446e --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetAcknowledgementOptionsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetAcknowledgementOptions model. + */ +public class GetAcknowledgementOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAcknowledgementOptions() throws Throwable { + GetAcknowledgementOptions getAcknowledgementOptionsModel = new GetAcknowledgementOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(getAcknowledgementOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptionsTest.java new file mode 100644 index 0000000000..01e05f18b8 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetDistributionListDestinationOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetDistributionListDestinationOptions model. + */ +public class GetDistributionListDestinationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDistributionListDestinationOptions() throws Throwable { + GetDistributionListDestinationOptions getDistributionListDestinationOptionsModel = new GetDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .build(); + assertEquals(getDistributionListDestinationOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(getDistributionListDestinationOptionsModel.destinationId(), "12345678-1234-1234-1234-123456789012"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDistributionListDestinationOptionsError() throws Throwable { + new GetDistributionListDestinationOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptionsTest.java new file mode 100644 index 0000000000..86cb902a2f --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/GetPreferencesOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.GetPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the GetPreferencesOptions model. + */ +public class GetPreferencesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPreferencesOptions() throws Throwable { + GetPreferencesOptions getPreferencesOptionsModel = new GetPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(getPreferencesOptionsModel.iamId(), "IBMid-1234567890"); + assertEquals(getPreferencesOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPreferencesOptionsError() throws Throwable { + new GetPreferencesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptionsTest.java new file mode 100644 index 0000000000..768785e48e --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListDistributionListDestinationsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListDistributionListDestinationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListDistributionListDestinationsOptions model. + */ +public class ListDistributionListDestinationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDistributionListDestinationsOptions() throws Throwable { + ListDistributionListDestinationsOptions listDistributionListDestinationsOptionsModel = new ListDistributionListDestinationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(listDistributionListDestinationsOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDistributionListDestinationsOptionsError() throws Throwable { + new ListDistributionListDestinationsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptionsTest.java new file mode 100644 index 0000000000..2f86af3185 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ListNotificationsOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ListNotificationsOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ListNotificationsOptions model. + */ +public class ListNotificationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListNotificationsOptions() throws Throwable { + ListNotificationsOptions listNotificationsOptionsModel = new ListNotificationsOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .start("3fe78a36b9aa7f26") + .limit(Long.valueOf("50")) + .build(); + assertEquals(listNotificationsOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(listNotificationsOptionsModel.start(), "3fe78a36b9aa7f26"); + assertEquals(listNotificationsOptionsModel.limit(), Long.valueOf("50")); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollectionTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollectionTest.java new file mode 100644 index 0000000000..91e1fb3731 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationCollectionTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Notification; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.NotificationCollection; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLink; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLinkWithToken; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the NotificationCollection model. + */ +public class NotificationCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotificationCollection() throws Throwable { + NotificationCollection notificationCollectionModel = new NotificationCollection(); + assertNull(notificationCollectionModel.getLimit()); + assertNull(notificationCollectionModel.getTotalCount()); + assertNull(notificationCollectionModel.getFirst()); + assertNull(notificationCollectionModel.getPrevious()); + assertNull(notificationCollectionModel.getNext()); + assertNull(notificationCollectionModel.getLast()); + assertNull(notificationCollectionModel.getNotifications()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationTest.java new file mode 100644 index 0000000000..971515f9af --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/NotificationTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.Notification; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Notification model. + */ +public class NotificationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotification() throws Throwable { + Notification notificationModel = new Notification(); + assertNull(notificationModel.getTitle()); + assertNull(notificationModel.getBody()); + assertNull(notificationModel.getId()); + assertNull(notificationModel.getCategory()); + assertNull(notificationModel.getComponentNames()); + assertNull(notificationModel.getStartTime()); + assertNull(notificationModel.isIsGlobal()); + assertNull(notificationModel.getState()); + assertNull(notificationModel.getRegions()); + assertNull(notificationModel.getCrnMasks()); + assertNull(notificationModel.getRecordId()); + assertNull(notificationModel.getSourceId()); + assertNull(notificationModel.getCompletionCode()); + assertNull(notificationModel.getEndTime()); + assertNull(notificationModel.getUpdateTime()); + assertNull(notificationModel.getSeverity()); + assertNull(notificationModel.getLuceneQuery()); + assertNull(notificationModel.getResourceLink()); + assertNull(notificationModel.getCreationTimestamp()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkTest.java new file mode 100644 index 0000000000..a7993749fd --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLink; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PaginationLink model. + */ +public class PaginationLinkTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPaginationLink() throws Throwable { + PaginationLink paginationLinkModel = new PaginationLink(); + assertNull(paginationLinkModel.getHref()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithTokenTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithTokenTest.java new file mode 100644 index 0000000000..ab0f04d6a1 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PaginationLinkWithTokenTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PaginationLinkWithToken; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PaginationLinkWithToken model. + */ +public class PaginationLinkWithTokenTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPaginationLinkWithToken() throws Throwable { + PaginationLinkWithToken paginationLinkWithTokenModel = new PaginationLinkWithToken(); + assertNull(paginationLinkWithTokenModel.getHref()); + assertNull(paginationLinkWithTokenModel.getStart()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdatesTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdatesTest.java new file mode 100644 index 0000000000..912d3571b6 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithUpdatesTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PreferenceValueWithUpdates model. + */ +public class PreferenceValueWithUpdatesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPreferenceValueWithUpdates() throws Throwable { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + assertEquals(preferenceValueWithUpdatesModel.channels(), java.util.Arrays.asList("email")); + assertEquals(preferenceValueWithUpdatesModel.updates(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(preferenceValueWithUpdatesModel); + + PreferenceValueWithUpdates preferenceValueWithUpdatesModelNew = TestUtilities.deserialize(json, PreferenceValueWithUpdates.class); + assertTrue(preferenceValueWithUpdatesModelNew instanceof PreferenceValueWithUpdates); + assertEquals(preferenceValueWithUpdatesModelNew.updates(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPreferenceValueWithUpdatesError() throws Throwable { + new PreferenceValueWithUpdates.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdatesTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdatesTest.java new file mode 100644 index 0000000000..9ee14ec003 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferenceValueWithoutUpdatesTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PreferenceValueWithoutUpdates model. + */ +public class PreferenceValueWithoutUpdatesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPreferenceValueWithoutUpdates() throws Throwable { + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + assertEquals(preferenceValueWithoutUpdatesModel.channels(), java.util.Arrays.asList("email")); + + String json = TestUtilities.serialize(preferenceValueWithoutUpdatesModel); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModelNew = TestUtilities.deserialize(json, PreferenceValueWithoutUpdates.class); + assertTrue(preferenceValueWithoutUpdatesModelNew instanceof PreferenceValueWithoutUpdates); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPreferenceValueWithoutUpdatesError() throws Throwable { + new PreferenceValueWithoutUpdates.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObjectTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObjectTest.java new file mode 100644 index 0000000000..28364d7131 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/PreferencesObjectTest.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferencesObject; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the PreferencesObject model. + */ +public class PreferencesObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPreferencesObject() throws Throwable { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + assertEquals(preferenceValueWithUpdatesModel.channels(), java.util.Arrays.asList("email")); + assertEquals(preferenceValueWithUpdatesModel.updates(), Boolean.valueOf(true)); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + assertEquals(preferenceValueWithoutUpdatesModel.channels(), java.util.Arrays.asList("email")); + + PreferencesObject preferencesObjectModel = new PreferencesObject.Builder() + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .build(); + assertEquals(preferencesObjectModel.incidentSeverity1(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.incidentSeverity2(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.incidentSeverity3(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.incidentSeverity4(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.maintenanceHigh(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.maintenanceMedium(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.maintenanceLow(), preferenceValueWithUpdatesModel); + assertEquals(preferencesObjectModel.announcementsMajor(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.announcementsMinor(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.securityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.accountNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.billingAndUsageOrder(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.billingAndUsageInvoices(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.billingAndUsagePayments(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.billingAndUsageSubscriptionsAndPromoCodes(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.billingAndUsageSpendingAlerts(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.resourceactivityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.orderingReview(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.orderingApproved(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.orderingApprovedVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.orderingApprovedServer(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.provisioningReloadComplete(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.provisioningCompleteVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(preferencesObjectModel.provisioningCompleteServer(), preferenceValueWithoutUpdatesModel); + + String json = TestUtilities.serialize(preferencesObjectModel); + + PreferencesObject preferencesObjectModelNew = TestUtilities.deserialize(json, PreferencesObject.class); + assertTrue(preferencesObjectModelNew instanceof PreferencesObject); + assertEquals(preferencesObjectModelNew.incidentSeverity1().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.incidentSeverity2().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.incidentSeverity3().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.incidentSeverity4().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.maintenanceHigh().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.maintenanceMedium().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.maintenanceLow().toString(), preferenceValueWithUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.announcementsMajor().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.announcementsMinor().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.securityNormal().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.accountNormal().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.billingAndUsageOrder().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.billingAndUsageInvoices().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.billingAndUsagePayments().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.billingAndUsageSubscriptionsAndPromoCodes().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.billingAndUsageSpendingAlerts().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.resourceactivityNormal().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.orderingReview().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.orderingApproved().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.orderingApprovedVsi().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.orderingApprovedServer().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.provisioningReloadComplete().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.provisioningCompleteVsi().toString(), preferenceValueWithoutUpdatesModel.toString()); + assertEquals(preferencesObjectModelNew.provisioningCompleteServer().toString(), preferenceValueWithoutUpdatesModel.toString()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptionsTest.java new file mode 100644 index 0000000000..b9c934871c --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationAcknowledgementOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationAcknowledgementOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ReplaceNotificationAcknowledgementOptions model. + */ +public class ReplaceNotificationAcknowledgementOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplaceNotificationAcknowledgementOptions() throws Throwable { + ReplaceNotificationAcknowledgementOptions replaceNotificationAcknowledgementOptionsModel = new ReplaceNotificationAcknowledgementOptions.Builder() + .lastAcknowledged(Long.valueOf("1772804159452")) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(replaceNotificationAcknowledgementOptionsModel.lastAcknowledged(), Long.valueOf("1772804159452")); + assertEquals(replaceNotificationAcknowledgementOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceNotificationAcknowledgementOptionsError() throws Throwable { + new ReplaceNotificationAcknowledgementOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptionsTest.java new file mode 100644 index 0000000000..c079774bab --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/ReplaceNotificationPreferencesOptionsTest.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.PreferenceValueWithoutUpdates; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.ReplaceNotificationPreferencesOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the ReplaceNotificationPreferencesOptions model. + */ +public class ReplaceNotificationPreferencesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testReplaceNotificationPreferencesOptions() throws Throwable { + PreferenceValueWithUpdates preferenceValueWithUpdatesModel = new PreferenceValueWithUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .updates(true) + .build(); + assertEquals(preferenceValueWithUpdatesModel.channels(), java.util.Arrays.asList("email")); + assertEquals(preferenceValueWithUpdatesModel.updates(), Boolean.valueOf(true)); + + PreferenceValueWithoutUpdates preferenceValueWithoutUpdatesModel = new PreferenceValueWithoutUpdates.Builder() + .channels(java.util.Arrays.asList("email")) + .build(); + assertEquals(preferenceValueWithoutUpdatesModel.channels(), java.util.Arrays.asList("email")); + + ReplaceNotificationPreferencesOptions replaceNotificationPreferencesOptionsModel = new ReplaceNotificationPreferencesOptions.Builder() + .iamId("IBMid-1234567890") + .incidentSeverity1(preferenceValueWithUpdatesModel) + .incidentSeverity2(preferenceValueWithUpdatesModel) + .incidentSeverity3(preferenceValueWithUpdatesModel) + .incidentSeverity4(preferenceValueWithUpdatesModel) + .maintenanceHigh(preferenceValueWithUpdatesModel) + .maintenanceMedium(preferenceValueWithUpdatesModel) + .maintenanceLow(preferenceValueWithUpdatesModel) + .announcementsMajor(preferenceValueWithoutUpdatesModel) + .announcementsMinor(preferenceValueWithoutUpdatesModel) + .securityNormal(preferenceValueWithoutUpdatesModel) + .accountNormal(preferenceValueWithoutUpdatesModel) + .billingAndUsageOrder(preferenceValueWithoutUpdatesModel) + .billingAndUsageInvoices(preferenceValueWithoutUpdatesModel) + .billingAndUsagePayments(preferenceValueWithoutUpdatesModel) + .billingAndUsageSubscriptionsAndPromoCodes(preferenceValueWithoutUpdatesModel) + .billingAndUsageSpendingAlerts(preferenceValueWithoutUpdatesModel) + .resourceactivityNormal(preferenceValueWithoutUpdatesModel) + .orderingReview(preferenceValueWithoutUpdatesModel) + .orderingApproved(preferenceValueWithoutUpdatesModel) + .orderingApprovedVsi(preferenceValueWithoutUpdatesModel) + .orderingApprovedServer(preferenceValueWithoutUpdatesModel) + .provisioningReloadComplete(preferenceValueWithoutUpdatesModel) + .provisioningCompleteVsi(preferenceValueWithoutUpdatesModel) + .provisioningCompleteServer(preferenceValueWithoutUpdatesModel) + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .build(); + assertEquals(replaceNotificationPreferencesOptionsModel.iamId(), "IBMid-1234567890"); + assertEquals(replaceNotificationPreferencesOptionsModel.incidentSeverity1(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.incidentSeverity2(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.incidentSeverity3(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.incidentSeverity4(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.maintenanceHigh(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.maintenanceMedium(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.maintenanceLow(), preferenceValueWithUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.announcementsMajor(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.announcementsMinor(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.securityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.accountNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.billingAndUsageOrder(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.billingAndUsageInvoices(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.billingAndUsagePayments(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.billingAndUsageSubscriptionsAndPromoCodes(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.billingAndUsageSpendingAlerts(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.resourceactivityNormal(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.orderingReview(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.orderingApproved(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.orderingApprovedVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.orderingApprovedServer(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.provisioningReloadComplete(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.provisioningCompleteVsi(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.provisioningCompleteServer(), preferenceValueWithoutUpdatesModel); + assertEquals(replaceNotificationPreferencesOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testReplaceNotificationPreferencesOptionsError() throws Throwable { + new ReplaceNotificationPreferencesOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTest.java new file mode 100644 index 0000000000..594f43a371 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the TestDestinationRequestBodyPrototype model. + */ +public class TestDestinationRequestBodyPrototypeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testTestDestinationRequestBodyPrototype() throws Throwable { + TestDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototype(); + assertNotNull(testDestinationRequestBodyPrototypeModel); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeTest.java new file mode 100644 index 0000000000..9755c1b755 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype model. + */ +public class TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype() throws Throwable { + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder() + .destinationType("event_notifications") + .notificationType("incident") + .build(); + assertEquals(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModel.destinationType(), "event_notifications"); + assertEquals(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModel.notificationType(), "incident"); + + String json = TestUtilities.serialize(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModel); + + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModelNew = TestUtilities.deserialize(json, TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.class); + assertTrue(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModelNew instanceof TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype); + assertEquals(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModelNew.destinationType(), "event_notifications"); + assertEquals(testDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeModelNew.notificationType(), "incident"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototypeError() throws Throwable { + new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBodyTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBodyTest.java new file mode 100644 index 0000000000..63c35f924e --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDestinationResponseBodyTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationResponseBody; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the TestDestinationResponseBody model. + */ +public class TestDestinationResponseBodyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTestDestinationResponseBody() throws Throwable { + TestDestinationResponseBody testDestinationResponseBodyModel = new TestDestinationResponseBody(); + assertNull(testDestinationResponseBodyModel.getMessage()); + } +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptionsTest.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptionsTest.java new file mode 100644 index 0000000000..a0c18acdc0 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/model/TestDistributionListDestinationOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.model; + +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; +import com.ibm.cloud.platform_services.platform_notifications.v1.model.TestDistributionListDestinationOptions; +import com.ibm.cloud.platform_services.platform_notifications.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the TestDistributionListDestinationOptions model. + */ +public class TestDistributionListDestinationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTestDistributionListDestinationOptions() throws Throwable { + TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype testDestinationRequestBodyPrototypeModel = new TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype.Builder() + .destinationType("event_notifications") + .notificationType("incident") + .build(); + assertEquals(testDestinationRequestBodyPrototypeModel.destinationType(), "event_notifications"); + assertEquals(testDestinationRequestBodyPrototypeModel.notificationType(), "incident"); + + TestDistributionListDestinationOptions testDistributionListDestinationOptionsModel = new TestDistributionListDestinationOptions.Builder() + .accountId("a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6") + .destinationId("12345678-1234-1234-1234-123456789012") + .testDestinationRequestBodyPrototype(testDestinationRequestBodyPrototypeModel) + .build(); + assertEquals(testDistributionListDestinationOptionsModel.accountId(), "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6"); + assertEquals(testDistributionListDestinationOptionsModel.destinationId(), "12345678-1234-1234-1234-123456789012"); + assertEquals(testDistributionListDestinationOptionsModel.testDestinationRequestBodyPrototype(), testDestinationRequestBodyPrototypeModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTestDistributionListDestinationOptionsError() throws Throwable { + new TestDistributionListDestinationOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/utils/TestUtilities.java b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/utils/TestUtilities.java new file mode 100644 index 0000000000..b937027808 --- /dev/null +++ b/modules/platform-notifications/src/test/java/com/ibm/cloud/platform_services/platform_notifications/v1/utils/TestUtilities.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2026. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.ibm.cloud.platform_services.platform_notifications.v1.utils; + +import java.util.Base64; +import java.util.Map; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.io.InputStream; +import java.io.ByteArrayInputStream; + +import okhttp3.mockwebserver.RecordedRequest; +import okhttp3.HttpUrl; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; + +/** + * A class used by the unit tests containing utility functions. + */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { put("key1", createMockStream("This is a mock file.")); } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index b627ed2235..a562fd930a 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,7 @@ modules/ibm-cloud-shell modules/open-service-broker modules/partner-management + modules/platform-notifications modules/resource-controller modules/resource-manager modules/usage-metering