From 91903b21afa5b052a84391f6c7b2a101f6c6191b Mon Sep 17 00:00:00 2001 From: Sirija Reddy Date: Mon, 20 Apr 2026 15:29:26 +0530 Subject: [PATCH] feat: Add batch DNS records Signed-off-by: Sirija Reddy --- .../networking/dns_records/v1/DnsRecords.java | 129 +++-- .../v1/model/BatchDnsRecordDetails.java | 240 ++++++++++ .../v1/model/BatchDnsRecordsOptions.java | 234 ++++++++++ .../BatchDnsRecordsRequestDeletesItem.java | 104 +++++ .../BatchDnsRecordsRequestPatchesItem.java | 316 +++++++++++++ .../model/BatchDnsRecordsRequestPutsItem.java | 332 +++++++++++++ .../v1/model/BatchDnsRecordsResponse.java | 74 +++ .../model/BatchDnsRecordsResponseResult.java | 68 +++ .../v1/model/CreateDnsRecordOptions.java | 44 +- .../v1/model/DeleteDnsRecordOptions.java | 10 +- .../v1/model/DeleteDnsrecordResp.java | 5 +- .../v1/model/DeleteDnsrecordRespResult.java | 5 +- .../v1/model/DnsrecordDetails.java | 11 +- .../dns_records/v1/model/DnsrecordInput.java | 290 ++++++++++++ .../dns_records/v1/model/DnsrecordResp.java | 5 +- .../v1/model/GetDnsRecordOptions.java | 10 +- .../v1/model/ListAllDnsRecordsOptions.java | 10 +- .../v1/model/ListDnsrecordsResp.java | 5 +- .../dns_records/v1/model/ResultInfo.java | 5 +- .../v1/model/UpdateDnsRecordOptions.java | 18 +- .../dns_records/v1/package-info.java | 3 +- .../dns_records/v1/DnsRecordsIT.java | 46 +- .../dns_records/v1/DnsRecordsTest.java | 439 +++++++++++------- .../v1/model/BatchDnsRecordDetailsTest.java | 51 ++ .../v1/model/BatchDnsRecordsOptionsTest.java | 109 +++++ ...BatchDnsRecordsRequestDeletesItemTest.java | 51 ++ ...BatchDnsRecordsRequestPatchesItemTest.java | 72 +++ .../BatchDnsRecordsRequestPutsItemTest.java | 72 +++ .../BatchDnsRecordsResponseResultTest.java | 41 ++ .../v1/model/BatchDnsRecordsResponseTest.java | 42 ++ .../v1/model/CreateDnsRecordOptionsTest.java | 8 +- .../v1/model/DeleteDnsRecordOptionsTest.java | 2 +- .../model/DeleteDnsrecordRespResultTest.java | 2 +- .../v1/model/DeleteDnsrecordRespTest.java | 2 +- .../v1/model/DnsrecordDetailsTest.java | 2 +- .../v1/model/DnsrecordInputTest.java | 69 +++ .../v1/model/DnsrecordRespTest.java | 2 +- .../v1/model/GetDnsRecordOptionsTest.java | 2 +- .../model/ListAllDnsRecordsOptionsTest.java | 10 +- .../v1/model/ListDnsrecordsRespTest.java | 2 +- .../dns_records/v1/model/ResultInfoTest.java | 2 +- .../v1/model/UpdateDnsRecordOptionsTest.java | 6 +- .../dns_records/v1/utils/TestUtilities.java | 14 +- 43 files changed, 2727 insertions(+), 237 deletions(-) create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetails.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptions.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItem.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItem.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItem.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponse.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResult.java create mode 100644 modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInput.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetailsTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptionsTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItemTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItemTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItemTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResultTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseTest.java create mode 100644 modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInputTest.java diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/DnsRecords.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/DnsRecords.java index 490b125143..3717c94314 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/DnsRecords.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/DnsRecords.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -12,13 +12,15 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.12.1-318e07c8-20200909-152230 + * IBM OpenAPI SDK Code Generator Version: 3.106.0-09823488-20250707-071701 */ package com.ibm.cloud.networking.dns_records.v1; import com.google.gson.JsonObject; import com.ibm.cloud.networking.common.SdkCommon; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsOptions; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponse; import com.ibm.cloud.networking.dns_records.v1.model.CreateDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsrecordResp; @@ -34,18 +36,25 @@ 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; /** * DNS records. * - * @version v1 + * API Version: 1.0.1 */ public class DnsRecords extends BaseService { + /** + * Default service name used when configuring the `DnsRecords` client. + */ public static final String DEFAULT_SERVICE_NAME = "dns_records"; + /** + * Default service endpoint URL. + */ public static final String DEFAULT_SERVICE_URL = "https://api.cis.cloud.ibm.com"; private String crn; @@ -56,8 +65,8 @@ public class DnsRecords extends BaseService { * Class method which constructs an instance of the `DnsRecords` client. * The default service name is used to configure the client instance. * - * @param crn Full crn of the service instance. - * @param zoneIdentifier Zone identifier (zone id). + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier Identifier of zone. * @return an instance of the `DnsRecords` client using external configuration */ public static DnsRecords newInstance(String crn, String zoneIdentifier) { @@ -68,8 +77,8 @@ public static DnsRecords newInstance(String crn, String zoneIdentifier) { * Class method which constructs an instance of the `DnsRecords` client. * The specified service name is used to configure the client instance. * - * @param crn Full crn of the service instance. - * @param zoneIdentifier Zone identifier (zone id). + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier Identifier of zone. * @param serviceName the service name to be used when configuring the client instance * @return an instance of the `DnsRecords` client using external configuration */ @@ -84,8 +93,8 @@ public static DnsRecords newInstance(String crn, String zoneIdentifier, String s * Constructs an instance of the `DnsRecords` client. * The specified service name and authenticator are used to configure the client instance. * - * @param crn Full crn of the service instance. - * @param zoneIdentifier Zone identifier (zone id). + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier Identifier of zone. * @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 */ @@ -99,7 +108,7 @@ public DnsRecords(String crn, String zoneIdentifier, String serviceName, Authent /** * Gets the crn. * - * Full crn of the service instance. + * Full url-encoded CRN of the service instance. * * @return the crn */ @@ -120,7 +129,7 @@ public void setCrn(final String crn) { /** * Gets the zoneIdentifier. * - * Zone identifier (zone id). + * Identifier of zone. * * @return the zoneIdentifier */ @@ -150,9 +159,10 @@ public ServiceCall listAllDnsRecords(ListAllDnsRecordsOption if (listAllDnsRecordsOptions == null) { listAllDnsRecordsOptions = new ListAllDnsRecordsOptions.Builder().build(); } - String[] pathSegments = { "v1", "zones", "dns_records" }; - String[] pathParameters = { this.crn, this.zoneIdentifier }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "listAllDnsRecords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -212,9 +222,10 @@ public ServiceCall createDnsRecord(CreateDnsRecordOptions createD createDnsRecordOptions = new CreateDnsRecordOptions.Builder().build(); skipBody = true; } - String[] pathSegments = { "v1", "zones", "dns_records" }; - String[] pathParameters = { this.crn, this.zoneIdentifier }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "createDnsRecord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -237,6 +248,9 @@ public ServiceCall createDnsRecord(CreateDnsRecordOptions createD if (createDnsRecordOptions.priority() != null) { contentJson.addProperty("priority", createDnsRecordOptions.priority()); } + if (createDnsRecordOptions.proxied() != null) { + contentJson.addProperty("proxied", createDnsRecordOptions.proxied()); + } if (createDnsRecordOptions.data() != null) { contentJson.add("data", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createDnsRecordOptions.data())); } @@ -269,9 +283,11 @@ public ServiceCall createDnsRecord() { public ServiceCall deleteDnsRecord(DeleteDnsRecordOptions deleteDnsRecordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(deleteDnsRecordOptions, "deleteDnsRecordOptions cannot be null"); - String[] pathSegments = { "v1", "zones", "dns_records" }; - String[] pathParameters = { this.crn, this.zoneIdentifier, deleteDnsRecordOptions.dnsrecordIdentifier() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("dnsrecord_identifier", deleteDnsRecordOptions.dnsrecordIdentifier()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records/{dnsrecord_identifier}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "deleteDnsRecord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -293,9 +309,11 @@ public ServiceCall deleteDnsRecord(DeleteDnsRecordOptions d public ServiceCall getDnsRecord(GetDnsRecordOptions getDnsRecordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(getDnsRecordOptions, "getDnsRecordOptions cannot be null"); - String[] pathSegments = { "v1", "zones", "dns_records" }; - String[] pathParameters = { this.crn, this.zoneIdentifier, getDnsRecordOptions.dnsrecordIdentifier() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("dnsrecord_identifier", getDnsRecordOptions.dnsrecordIdentifier()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records/{dnsrecord_identifier}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "getDnsRecord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -317,9 +335,11 @@ public ServiceCall getDnsRecord(GetDnsRecordOptions getDnsRecordO public ServiceCall updateDnsRecord(UpdateDnsRecordOptions updateDnsRecordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(updateDnsRecordOptions, "updateDnsRecordOptions cannot be null"); - String[] pathSegments = { "v1", "zones", "dns_records" }; - String[] pathParameters = { this.crn, this.zoneIdentifier, updateDnsRecordOptions.dnsrecordIdentifier() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("dnsrecord_identifier", updateDnsRecordOptions.dnsrecordIdentifier()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records/{dnsrecord_identifier}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "updateDnsRecord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -353,4 +373,61 @@ public ServiceCall updateDnsRecord(UpdateDnsRecordOptions updateD return createServiceCall(builder.build(), responseConverter); } + /** + * Batch DNS records. + * + * Send a Batch of DNS Record API calls to be executed together. The operations you specify within the /batch request + * body are always executed in the following order: deletes, patches, puts, posts. + * + * @param batchDnsRecordsOptions the {@link BatchDnsRecordsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link BatchDnsRecordsResponse} + */ + public ServiceCall batchDnsRecords(BatchDnsRecordsOptions batchDnsRecordsOptions) { + boolean skipBody = false; + if (batchDnsRecordsOptions == null) { + batchDnsRecordsOptions = new BatchDnsRecordsOptions.Builder().build(); + skipBody = true; + } + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/dns_records/batch", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("dns_records", "v1", "batchDnsRecords"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + if (!skipBody) { + final JsonObject contentJson = new JsonObject(); + if (batchDnsRecordsOptions.deletes() != null) { + contentJson.add("deletes", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(batchDnsRecordsOptions.deletes())); + } + if (batchDnsRecordsOptions.patches() != null) { + contentJson.add("patches", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(batchDnsRecordsOptions.patches())); + } + if (batchDnsRecordsOptions.posts() != null) { + contentJson.add("posts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(batchDnsRecordsOptions.posts())); + } + if (batchDnsRecordsOptions.puts() != null) { + contentJson.add("puts", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(batchDnsRecordsOptions.puts())); + } + builder.bodyJson(contentJson); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Batch DNS records. + * + * Send a Batch of DNS Record API calls to be executed together. The operations you specify within the /batch request + * body are always executed in the following order: deletes, patches, puts, posts. + * + * @return a {@link ServiceCall} with a result of type {@link BatchDnsRecordsResponse} + */ + public ServiceCall batchDnsRecords() { + return batchDnsRecords(null); + } + } diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetails.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetails.java new file mode 100644 index 0000000000..b95ad4c5d8 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetails.java @@ -0,0 +1,240 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.List; +import java.util.Map; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * dns record details as returned by the batch API. + */ +public class BatchDnsRecordDetails extends GenericModel { + + /** + * dns record type. + */ + public interface Type { + /** A. */ + String A = "A"; + /** AAAA. */ + String AAAA = "AAAA"; + /** CNAME. */ + String CNAME = "CNAME"; + /** NS. */ + String NS = "NS"; + /** MX. */ + String MX = "MX"; + /** TXT. */ + String TXT = "TXT"; + /** LOC. */ + String LOC = "LOC"; + /** SRV. */ + String SRV = "SRV"; + /** PTR. */ + String PTR = "PTR"; + /** CAA. */ + String CAA = "CAA"; + /** DS. */ + String DS = "DS"; + } + + protected String id; + @SerializedName("created_on") + protected String createdOn; + @SerializedName("modified_on") + protected String modifiedOn; + protected String name; + protected String type; + protected String content; + protected Boolean proxiable; + protected Boolean proxied; + protected Long ttl; + protected Long priority; + protected Map data; + protected Map settings; + protected Map meta; + protected String comment; + protected List tags; + + protected BatchDnsRecordDetails() { } + + /** + * Gets the id. + * + * dns record identifier. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the createdOn. + * + * created on. + * + * @return the createdOn + */ + public String getCreatedOn() { + return createdOn; + } + + /** + * Gets the modifiedOn. + * + * modified date. + * + * @return the modifiedOn + */ + public String getModifiedOn() { + return modifiedOn; + } + + /** + * Gets the name. + * + * dns record name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the type. + * + * dns record type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the content. + * + * dns record content. + * + * @return the content + */ + public String getContent() { + return content; + } + + /** + * Gets the proxiable. + * + * proxiable. + * + * @return the proxiable + */ + public Boolean isProxiable() { + return proxiable; + } + + /** + * Gets the proxied. + * + * proxied. + * + * @return the proxied + */ + public Boolean isProxied() { + return proxied; + } + + /** + * Gets the ttl. + * + * dns record ttl value. + * + * @return the ttl + */ + public Long getTtl() { + return ttl; + } + + /** + * Gets the priority. + * + * Relevant only to MX type records. + * + * @return the priority + */ + public Long getPriority() { + return priority; + } + + /** + * Gets the data. + * + * Data details for the DNS record. Only for LOC, SRV, CAA records. + * + * @return the data + */ + public Map getData() { + return data; + } + + /** + * Gets the settings. + * + * DNS record settings. + * + * @return the settings + */ + public Map getSettings() { + return settings; + } + + /** + * Gets the meta. + * + * DNS record metadata. + * + * @return the meta + */ + public Map getMeta() { + return meta; + } + + /** + * Gets the comment. + * + * Optional comment for the DNS record. + * + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * Gets the tags. + * + * Tags associated with the DNS record. + * + * @return the tags + */ + public List getTags() { + return tags; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptions.java new file mode 100644 index 0000000000..884a50c637 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptions.java @@ -0,0 +1,234 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The batchDnsRecords options. + */ +public class BatchDnsRecordsOptions extends GenericModel { + + protected List deletes; + protected List patches; + protected List posts; + protected List puts; + + /** + * Builder. + */ + public static class Builder { + private List deletes; + private List patches; + private List posts; + private List puts; + + /** + * Instantiates a new Builder from an existing BatchDnsRecordsOptions instance. + * + * @param batchDnsRecordsOptions the instance to initialize the Builder with + */ + private Builder(BatchDnsRecordsOptions batchDnsRecordsOptions) { + this.deletes = batchDnsRecordsOptions.deletes; + this.patches = batchDnsRecordsOptions.patches; + this.posts = batchDnsRecordsOptions.posts; + this.puts = batchDnsRecordsOptions.puts; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a BatchDnsRecordsOptions. + * + * @return the new BatchDnsRecordsOptions instance + */ + public BatchDnsRecordsOptions build() { + return new BatchDnsRecordsOptions(this); + } + + /** + * Adds a new element to deletes. + * + * @param deletes the new element to be added + * @return the BatchDnsRecordsOptions builder + */ + public Builder addDeletes(BatchDnsRecordsRequestDeletesItem deletes) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deletes, + "deletes cannot be null"); + if (this.deletes == null) { + this.deletes = new ArrayList(); + } + this.deletes.add(deletes); + return this; + } + + /** + * Adds a new element to patches. + * + * @param patches the new element to be added + * @return the BatchDnsRecordsOptions builder + */ + public Builder addPatches(BatchDnsRecordsRequestPatchesItem patches) { + com.ibm.cloud.sdk.core.util.Validator.notNull(patches, + "patches cannot be null"); + if (this.patches == null) { + this.patches = new ArrayList(); + } + this.patches.add(patches); + return this; + } + + /** + * Adds a new element to posts. + * + * @param posts the new element to be added + * @return the BatchDnsRecordsOptions builder + */ + public Builder addPosts(DnsrecordInput posts) { + com.ibm.cloud.sdk.core.util.Validator.notNull(posts, + "posts cannot be null"); + if (this.posts == null) { + this.posts = new ArrayList(); + } + this.posts.add(posts); + return this; + } + + /** + * Adds a new element to puts. + * + * @param puts the new element to be added + * @return the BatchDnsRecordsOptions builder + */ + public Builder addPuts(BatchDnsRecordsRequestPutsItem puts) { + com.ibm.cloud.sdk.core.util.Validator.notNull(puts, + "puts cannot be null"); + if (this.puts == null) { + this.puts = new ArrayList(); + } + this.puts.add(puts); + return this; + } + + /** + * Set the deletes. + * Existing deletes will be replaced. + * + * @param deletes the deletes + * @return the BatchDnsRecordsOptions builder + */ + public Builder deletes(List deletes) { + this.deletes = deletes; + return this; + } + + /** + * Set the patches. + * Existing patches will be replaced. + * + * @param patches the patches + * @return the BatchDnsRecordsOptions builder + */ + public Builder patches(List patches) { + this.patches = patches; + return this; + } + + /** + * Set the posts. + * Existing posts will be replaced. + * + * @param posts the posts + * @return the BatchDnsRecordsOptions builder + */ + public Builder posts(List posts) { + this.posts = posts; + return this; + } + + /** + * Set the puts. + * Existing puts will be replaced. + * + * @param puts the puts + * @return the BatchDnsRecordsOptions builder + */ + public Builder puts(List puts) { + this.puts = puts; + return this; + } + } + + protected BatchDnsRecordsOptions() { } + + protected BatchDnsRecordsOptions(Builder builder) { + deletes = builder.deletes; + patches = builder.patches; + posts = builder.posts; + puts = builder.puts; + } + + /** + * New builder. + * + * @return a BatchDnsRecordsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the deletes. + * + * @return the deletes + */ + public List deletes() { + return deletes; + } + + /** + * Gets the patches. + * + * @return the patches + */ + public List patches() { + return patches; + } + + /** + * Gets the posts. + * + * @return the posts + */ + public List posts() { + return posts; + } + + /** + * Gets the puts. + * + * @return the puts + */ + public List puts() { + return puts; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItem.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItem.java new file mode 100644 index 0000000000..71d6fae16a --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItem.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.networking.dns_records.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * BatchDnsRecordsRequestDeletesItem. + */ +public class BatchDnsRecordsRequestDeletesItem extends GenericModel { + + protected String id; + + /** + * Builder. + */ + public static class Builder { + private String id; + + /** + * Instantiates a new Builder from an existing BatchDnsRecordsRequestDeletesItem instance. + * + * @param batchDnsRecordsRequestDeletesItem the instance to initialize the Builder with + */ + private Builder(BatchDnsRecordsRequestDeletesItem batchDnsRecordsRequestDeletesItem) { + this.id = batchDnsRecordsRequestDeletesItem.id; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param id the id + */ + public Builder(String id) { + this.id = id; + } + + /** + * Builds a BatchDnsRecordsRequestDeletesItem. + * + * @return the new BatchDnsRecordsRequestDeletesItem instance + */ + public BatchDnsRecordsRequestDeletesItem build() { + return new BatchDnsRecordsRequestDeletesItem(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the BatchDnsRecordsRequestDeletesItem builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + } + + protected BatchDnsRecordsRequestDeletesItem() { } + + protected BatchDnsRecordsRequestDeletesItem(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.id, + "id cannot be null"); + id = builder.id; + } + + /** + * New builder. + * + * @return a BatchDnsRecordsRequestDeletesItem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * DNS record ID to delete. + * + * @return the id + */ + public String id() { + return id; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItem.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItem.java new file mode 100644 index 0000000000..f6ea2b3e3f --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItem.java @@ -0,0 +1,316 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.Map; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * BatchDnsRecordsRequestPatchesItem. + */ +public class BatchDnsRecordsRequestPatchesItem extends GenericModel { + + /** + * dns record type. + */ + public interface Type { + /** A. */ + String A = "A"; + /** AAAA. */ + String AAAA = "AAAA"; + /** CNAME. */ + String CNAME = "CNAME"; + /** NS. */ + String NS = "NS"; + /** MX. */ + String MX = "MX"; + /** TXT. */ + String TXT = "TXT"; + /** LOC. */ + String LOC = "LOC"; + /** SRV. */ + String SRV = "SRV"; + /** PTR. */ + String PTR = "PTR"; + /** CAA. */ + String CAA = "CAA"; + /** DS. */ + String DS = "DS"; + } + + protected String id; + protected String name; + protected String type; + protected Long ttl; + protected String content; + protected Long priority; + protected Boolean proxied; + protected Map data; + + /** + * Builder. + */ + public static class Builder { + private String id; + private String name; + private String type; + private Long ttl; + private String content; + private Long priority; + private Boolean proxied; + private Map data; + + /** + * Instantiates a new Builder from an existing BatchDnsRecordsRequestPatchesItem instance. + * + * @param batchDnsRecordsRequestPatchesItem the instance to initialize the Builder with + */ + private Builder(BatchDnsRecordsRequestPatchesItem batchDnsRecordsRequestPatchesItem) { + this.id = batchDnsRecordsRequestPatchesItem.id; + this.name = batchDnsRecordsRequestPatchesItem.name; + this.type = batchDnsRecordsRequestPatchesItem.type; + this.ttl = batchDnsRecordsRequestPatchesItem.ttl; + this.content = batchDnsRecordsRequestPatchesItem.content; + this.priority = batchDnsRecordsRequestPatchesItem.priority; + this.proxied = batchDnsRecordsRequestPatchesItem.proxied; + this.data = batchDnsRecordsRequestPatchesItem.data; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param id the id + */ + public Builder(String id) { + this.id = id; + } + + /** + * Builds a BatchDnsRecordsRequestPatchesItem. + * + * @return the new BatchDnsRecordsRequestPatchesItem instance + */ + public BatchDnsRecordsRequestPatchesItem build() { + return new BatchDnsRecordsRequestPatchesItem(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the ttl. + * + * @param ttl the ttl + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder ttl(long ttl) { + this.ttl = ttl; + return this; + } + + /** + * Set the content. + * + * @param content the content + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder content(String content) { + this.content = content; + return this; + } + + /** + * Set the priority. + * + * @param priority the priority + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder priority(long priority) { + this.priority = priority; + return this; + } + + /** + * Set the proxied. + * + * @param proxied the proxied + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder proxied(Boolean proxied) { + this.proxied = proxied; + return this; + } + + /** + * Set the data. + * + * @param data the data + * @return the BatchDnsRecordsRequestPatchesItem builder + */ + public Builder data(Map data) { + this.data = data; + return this; + } + } + + protected BatchDnsRecordsRequestPatchesItem() { } + + protected BatchDnsRecordsRequestPatchesItem(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.id, + "id cannot be null"); + id = builder.id; + name = builder.name; + type = builder.type; + ttl = builder.ttl; + content = builder.content; + priority = builder.priority; + proxied = builder.proxied; + data = builder.data; + } + + /** + * New builder. + * + * @return a BatchDnsRecordsRequestPatchesItem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * DNS record ID to patch. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the name. + * + * Required for all record types except SRV. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the type. + * + * dns record type. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the ttl. + * + * dns record ttl value. + * + * @return the ttl + */ + public Long ttl() { + return ttl; + } + + /** + * Gets the content. + * + * content of dns record. + * + * @return the content + */ + public String content() { + return content; + } + + /** + * Gets the priority. + * + * For MX records only. + * + * @return the priority + */ + public Long priority() { + return priority; + } + + /** + * Gets the proxied. + * + * proxied. + * + * @return the proxied + */ + public Boolean proxied() { + return proxied; + } + + /** + * Gets the data. + * + * For LOC, SRV, CAA, DS records only. + * + * @return the data + */ + public Map data() { + return data; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItem.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItem.java new file mode 100644 index 0000000000..75a5a9d9b9 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItem.java @@ -0,0 +1,332 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.Map; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * BatchDnsRecordsRequestPutsItem. + */ +public class BatchDnsRecordsRequestPutsItem extends GenericModel { + + /** + * dns record type. + */ + public interface Type { + /** A. */ + String A = "A"; + /** AAAA. */ + String AAAA = "AAAA"; + /** CNAME. */ + String CNAME = "CNAME"; + /** NS. */ + String NS = "NS"; + /** MX. */ + String MX = "MX"; + /** TXT. */ + String TXT = "TXT"; + /** LOC. */ + String LOC = "LOC"; + /** SRV. */ + String SRV = "SRV"; + /** PTR. */ + String PTR = "PTR"; + /** CAA. */ + String CAA = "CAA"; + /** DS. */ + String DS = "DS"; + } + + protected String id; + protected String name; + protected String type; + protected Long ttl; + protected String content; + protected Long priority; + protected Boolean proxied; + protected Map data; + + /** + * Builder. + */ + public static class Builder { + private String id; + private String name; + private String type; + private Long ttl; + private String content; + private Long priority; + private Boolean proxied; + private Map data; + + /** + * Instantiates a new Builder from an existing BatchDnsRecordsRequestPutsItem instance. + * + * @param batchDnsRecordsRequestPutsItem the instance to initialize the Builder with + */ + private Builder(BatchDnsRecordsRequestPutsItem batchDnsRecordsRequestPutsItem) { + this.id = batchDnsRecordsRequestPutsItem.id; + this.name = batchDnsRecordsRequestPutsItem.name; + this.type = batchDnsRecordsRequestPutsItem.type; + this.ttl = batchDnsRecordsRequestPutsItem.ttl; + this.content = batchDnsRecordsRequestPutsItem.content; + this.priority = batchDnsRecordsRequestPutsItem.priority; + this.proxied = batchDnsRecordsRequestPutsItem.proxied; + this.data = batchDnsRecordsRequestPutsItem.data; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param id the id + * @param name the name + * @param type the type + * @param ttl the ttl + * @param content the content + */ + public Builder(String id, String name, String type, Long ttl, String content) { + this.id = id; + this.name = name; + this.type = type; + this.ttl = ttl; + this.content = content; + } + + /** + * Builds a BatchDnsRecordsRequestPutsItem. + * + * @return the new BatchDnsRecordsRequestPutsItem instance + */ + public BatchDnsRecordsRequestPutsItem build() { + return new BatchDnsRecordsRequestPutsItem(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the ttl. + * + * @param ttl the ttl + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder ttl(long ttl) { + this.ttl = ttl; + return this; + } + + /** + * Set the content. + * + * @param content the content + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder content(String content) { + this.content = content; + return this; + } + + /** + * Set the priority. + * + * @param priority the priority + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder priority(long priority) { + this.priority = priority; + return this; + } + + /** + * Set the proxied. + * + * @param proxied the proxied + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder proxied(Boolean proxied) { + this.proxied = proxied; + return this; + } + + /** + * Set the data. + * + * @param data the data + * @return the BatchDnsRecordsRequestPutsItem builder + */ + public Builder data(Map data) { + this.data = data; + return this; + } + } + + protected BatchDnsRecordsRequestPutsItem() { } + + protected BatchDnsRecordsRequestPutsItem(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.id, + "id cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, + "name cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, + "type cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.ttl, + "ttl cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.content, + "content cannot be null"); + id = builder.id; + name = builder.name; + type = builder.type; + ttl = builder.ttl; + content = builder.content; + priority = builder.priority; + proxied = builder.proxied; + data = builder.data; + } + + /** + * New builder. + * + * @return a BatchDnsRecordsRequestPutsItem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * DNS record ID to update. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the name. + * + * Required for all record types except SRV. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the type. + * + * dns record type. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the ttl. + * + * dns record ttl value. + * + * @return the ttl + */ + public Long ttl() { + return ttl; + } + + /** + * Gets the content. + * + * dns record content. + * + * @return the content + */ + public String content() { + return content; + } + + /** + * Gets the priority. + * + * For MX records only. + * + * @return the priority + */ + public Long priority() { + return priority; + } + + /** + * Gets the proxied. + * + * proxied. + * + * @return the proxied + */ + public Boolean proxied() { + return proxied; + } + + /** + * Gets the data. + * + * For LOC, SRV, CAA, DS records only. + * + * @return the data + */ + public Map data() { + return data; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponse.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponse.java new file mode 100644 index 0000000000..44024277b3 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponse.java @@ -0,0 +1,74 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Batch DNS records response. + */ +public class BatchDnsRecordsResponse extends GenericModel { + + protected Boolean success; + protected List> errors; + protected List> messages; + protected BatchDnsRecordsResponseResult result; + + protected BatchDnsRecordsResponse() { } + + /** + * Gets the success. + * + * success response. + * + * @return the success + */ + public Boolean isSuccess() { + return success; + } + + /** + * Gets the errors. + * + * errors. + * + * @return the errors + */ + public List> getErrors() { + return errors; + } + + /** + * Gets the messages. + * + * messages. + * + * @return the messages + */ + public List> getMessages() { + return messages; + } + + /** + * Gets the result. + * + * @return the result + */ + public BatchDnsRecordsResponseResult getResult() { + return result; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResult.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResult.java new file mode 100644 index 0000000000..ac13bc0048 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResult.java @@ -0,0 +1,68 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * BatchDnsRecordsResponseResult. + */ +public class BatchDnsRecordsResponseResult extends GenericModel { + + protected List deletes; + protected List patches; + protected List posts; + protected List puts; + + protected BatchDnsRecordsResponseResult() { } + + /** + * Gets the deletes. + * + * @return the deletes + */ + public List getDeletes() { + return deletes; + } + + /** + * Gets the patches. + * + * @return the patches + */ + public List getPatches() { + return patches; + } + + /** + * Gets the posts. + * + * @return the posts + */ + public List getPosts() { + return posts; + } + + /** + * Gets the puts. + * + * @return the puts + */ + public List getPuts() { + return puts; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptions.java index a578398f0c..2a5ae5f04f 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptions.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.Map; @@ -41,10 +42,12 @@ public interface Type { String LOC = "LOC"; /** SRV. */ String SRV = "SRV"; - /** SPF. */ - String SPF = "SPF"; + /** PTR. */ + String PTR = "PTR"; /** CAA. */ String CAA = "CAA"; + /** DS. */ + String DS = "DS"; } protected String name; @@ -52,6 +55,7 @@ public interface Type { protected Long ttl; protected String content; protected Long priority; + protected Boolean proxied; protected Map data; /** @@ -63,14 +67,21 @@ public static class Builder { private Long ttl; private String content; private Long priority; + private Boolean proxied; private Map data; + /** + * Instantiates a new Builder from an existing CreateDnsRecordOptions instance. + * + * @param createDnsRecordOptions the instance to initialize the Builder with + */ private Builder(CreateDnsRecordOptions createDnsRecordOptions) { this.name = createDnsRecordOptions.name; this.type = createDnsRecordOptions.type; this.ttl = createDnsRecordOptions.ttl; this.content = createDnsRecordOptions.content; this.priority = createDnsRecordOptions.priority; + this.proxied = createDnsRecordOptions.proxied; this.data = createDnsRecordOptions.data; } @@ -144,6 +155,17 @@ public Builder priority(long priority) { return this; } + /** + * Set the proxied. + * + * @param proxied the proxied + * @return the CreateDnsRecordOptions builder + */ + public Builder proxied(Boolean proxied) { + this.proxied = proxied; + return this; + } + /** * Set the data. * @@ -156,12 +178,15 @@ public Builder data(Map data) { } } + protected CreateDnsRecordOptions() { } + protected CreateDnsRecordOptions(Builder builder) { name = builder.name; type = builder.type; ttl = builder.ttl; content = builder.content; priority = builder.priority; + proxied = builder.proxied; data = builder.data; } @@ -229,10 +254,21 @@ public Long priority() { return priority; } + /** + * Gets the proxied. + * + * proxied. + * + * @return the proxied + */ + public Boolean proxied() { + return proxied; + } + /** * Gets the data. * - * For LOC, SRV and CAA records only. + * For LOC, SRV, CAA, DS records only. * * @return the data */ diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptions.java index a373102171..a99bbda1e4 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptions.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; @@ -27,6 +28,11 @@ public class DeleteDnsRecordOptions extends GenericModel { public static class Builder { private String dnsrecordIdentifier; + /** + * Instantiates a new Builder from an existing DeleteDnsRecordOptions instance. + * + * @param deleteDnsRecordOptions the instance to initialize the Builder with + */ private Builder(DeleteDnsRecordOptions deleteDnsRecordOptions) { this.dnsrecordIdentifier = deleteDnsRecordOptions.dnsrecordIdentifier; } @@ -67,6 +73,8 @@ public Builder dnsrecordIdentifier(String dnsrecordIdentifier) { } } + protected DeleteDnsRecordOptions() { } + protected DeleteDnsRecordOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dnsrecordIdentifier, "dnsrecordIdentifier cannot be empty"); diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordResp.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordResp.java index 8326fe137c..7a6ea791b7 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordResp.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordResp.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.List; @@ -26,6 +27,8 @@ public class DeleteDnsrecordResp extends GenericModel { protected List> messages; protected DeleteDnsrecordRespResult result; + protected DeleteDnsrecordResp() { } + /** * Gets the success. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResult.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResult.java index 6e54f290f6..3a4186ec73 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResult.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; @@ -21,6 +22,8 @@ public class DeleteDnsrecordRespResult extends GenericModel { protected String id; + protected DeleteDnsrecordRespResult() { } + /** * Gets the id. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetails.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetails.java index 51c0ed971e..03e4ca8924 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetails.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.Map; @@ -42,10 +43,12 @@ public interface Type { String LOC = "LOC"; /** SRV. */ String SRV = "SRV"; - /** SPF. */ - String SPF = "SPF"; + /** PTR. */ + String PTR = "PTR"; /** CAA. */ String CAA = "CAA"; + /** DS. */ + String DS = "DS"; } protected String id; @@ -66,6 +69,8 @@ public interface Type { protected Long priority; protected Map data; + protected DnsrecordDetails() { } + /** * Gets the id. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInput.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInput.java new file mode 100644 index 0000000000..9e0d5b0808 --- /dev/null +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInput.java @@ -0,0 +1,290 @@ +/* + * (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.networking.dns_records.v1.model; + +import java.util.Map; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * dns record input. + */ +public class DnsrecordInput extends GenericModel { + + /** + * dns record type. + */ + public interface Type { + /** A. */ + String A = "A"; + /** AAAA. */ + String AAAA = "AAAA"; + /** CNAME. */ + String CNAME = "CNAME"; + /** NS. */ + String NS = "NS"; + /** MX. */ + String MX = "MX"; + /** TXT. */ + String TXT = "TXT"; + /** LOC. */ + String LOC = "LOC"; + /** SRV. */ + String SRV = "SRV"; + /** PTR. */ + String PTR = "PTR"; + /** CAA. */ + String CAA = "CAA"; + /** DS. */ + String DS = "DS"; + } + + protected String name; + protected String type; + protected Long ttl; + protected String content; + protected Long priority; + protected Boolean proxied; + protected Map data; + + /** + * Builder. + */ + public static class Builder { + private String name; + private String type; + private Long ttl; + private String content; + private Long priority; + private Boolean proxied; + private Map data; + + /** + * Instantiates a new Builder from an existing DnsrecordInput instance. + * + * @param dnsrecordInput the instance to initialize the Builder with + */ + private Builder(DnsrecordInput dnsrecordInput) { + this.name = dnsrecordInput.name; + this.type = dnsrecordInput.type; + this.ttl = dnsrecordInput.ttl; + this.content = dnsrecordInput.content; + this.priority = dnsrecordInput.priority; + this.proxied = dnsrecordInput.proxied; + this.data = dnsrecordInput.data; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param type the type + */ + public Builder(String type) { + this.type = type; + } + + /** + * Builds a DnsrecordInput. + * + * @return the new DnsrecordInput instance + */ + public DnsrecordInput build() { + return new DnsrecordInput(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the DnsrecordInput builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the DnsrecordInput builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the ttl. + * + * @param ttl the ttl + * @return the DnsrecordInput builder + */ + public Builder ttl(long ttl) { + this.ttl = ttl; + return this; + } + + /** + * Set the content. + * + * @param content the content + * @return the DnsrecordInput builder + */ + public Builder content(String content) { + this.content = content; + return this; + } + + /** + * Set the priority. + * + * @param priority the priority + * @return the DnsrecordInput builder + */ + public Builder priority(long priority) { + this.priority = priority; + return this; + } + + /** + * Set the proxied. + * + * @param proxied the proxied + * @return the DnsrecordInput builder + */ + public Builder proxied(Boolean proxied) { + this.proxied = proxied; + return this; + } + + /** + * Set the data. + * + * @param data the data + * @return the DnsrecordInput builder + */ + public Builder data(Map data) { + this.data = data; + return this; + } + } + + protected DnsrecordInput() { } + + protected DnsrecordInput(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.type, + "type cannot be null"); + name = builder.name; + type = builder.type; + ttl = builder.ttl; + content = builder.content; + priority = builder.priority; + proxied = builder.proxied; + data = builder.data; + } + + /** + * New builder. + * + * @return a DnsrecordInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + * Required for all record types except SRV. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the type. + * + * dns record type. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the ttl. + * + * dns record ttl value. + * + * @return the ttl + */ + public Long ttl() { + return ttl; + } + + /** + * Gets the content. + * + * dns record content. + * + * @return the content + */ + public String content() { + return content; + } + + /** + * Gets the priority. + * + * For MX records only. + * + * @return the priority + */ + public Long priority() { + return priority; + } + + /** + * Gets the proxied. + * + * proxied. + * + * @return the proxied + */ + public Boolean proxied() { + return proxied; + } + + /** + * Gets the data. + * + * For LOC, SRV, CAA, DS records only. + * + * @return the data + */ + public Map data() { + return data; + } +} + diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordResp.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordResp.java index 63258cad82..497cc40507 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordResp.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordResp.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.List; @@ -26,6 +27,8 @@ public class DnsrecordResp extends GenericModel { protected List> messages; protected DnsrecordDetails result; + protected DnsrecordResp() { } + /** * Gets the success. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptions.java index dcad518e41..cb1a70bce6 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptions.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; @@ -27,6 +28,11 @@ public class GetDnsRecordOptions extends GenericModel { public static class Builder { private String dnsrecordIdentifier; + /** + * Instantiates a new Builder from an existing GetDnsRecordOptions instance. + * + * @param getDnsRecordOptions the instance to initialize the Builder with + */ private Builder(GetDnsRecordOptions getDnsRecordOptions) { this.dnsrecordIdentifier = getDnsRecordOptions.dnsrecordIdentifier; } @@ -67,6 +73,8 @@ public Builder dnsrecordIdentifier(String dnsrecordIdentifier) { } } + protected GetDnsRecordOptions() { } + protected GetDnsRecordOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dnsrecordIdentifier, "dnsrecordIdentifier cannot be empty"); diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptions.java index 3462869fee..89e35da3de 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptions.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; @@ -77,6 +78,11 @@ public static class Builder { private String direction; private String match; + /** + * Instantiates a new Builder from an existing ListAllDnsRecordsOptions instance. + * + * @param listAllDnsRecordsOptions the instance to initialize the Builder with + */ private Builder(ListAllDnsRecordsOptions listAllDnsRecordsOptions) { this.type = listAllDnsRecordsOptions.type; this.name = listAllDnsRecordsOptions.name; @@ -192,6 +198,8 @@ public Builder match(String match) { } } + protected ListAllDnsRecordsOptions() { } + protected ListAllDnsRecordsOptions(Builder builder) { type = builder.type; name = builder.name; diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsResp.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsResp.java index d8f26e0c78..530d231f52 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsResp.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsResp.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.List; @@ -29,6 +30,8 @@ public class ListDnsrecordsResp extends GenericModel { @SerializedName("result_info") protected ResultInfo resultInfo; + protected ListDnsrecordsResp() { } + /** * Gets the success. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfo.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfo.java index f92239398f..c6a50e5ed5 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfo.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfo.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import com.google.gson.annotations.SerializedName; @@ -27,6 +28,8 @@ public class ResultInfo extends GenericModel { @SerializedName("total_count") protected Long totalCount; + protected ResultInfo() { } + /** * Gets the page. * diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptions.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptions.java index a661859811..d13848ee13 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptions.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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.networking.dns_records.v1.model; import java.util.Map; @@ -41,10 +42,12 @@ public interface Type { String LOC = "LOC"; /** SRV. */ String SRV = "SRV"; - /** SPF. */ - String SPF = "SPF"; + /** PTR. */ + String PTR = "PTR"; /** CAA. */ String CAA = "CAA"; + /** DS. */ + String DS = "DS"; } protected String dnsrecordIdentifier; @@ -69,6 +72,11 @@ public static class Builder { private Boolean proxied; private Map data; + /** + * Instantiates a new Builder from an existing UpdateDnsRecordOptions instance. + * + * @param updateDnsRecordOptions the instance to initialize the Builder with + */ private Builder(UpdateDnsRecordOptions updateDnsRecordOptions) { this.dnsrecordIdentifier = updateDnsRecordOptions.dnsrecordIdentifier; this.name = updateDnsRecordOptions.name; @@ -193,6 +201,8 @@ public Builder data(Map data) { } } + protected UpdateDnsRecordOptions() { } + protected UpdateDnsRecordOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.dnsrecordIdentifier, "dnsrecordIdentifier cannot be empty"); @@ -295,7 +305,7 @@ public Boolean proxied() { /** * Gets the data. * - * For LOC, SRV and CAA records only. + * For LOC, SRV, CAA, DS records only. * * @return the data */ diff --git a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/package-info.java b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/package-info.java index fb5f313a7d..54c97a621f 100644 --- a/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/package-info.java +++ b/modules/dns-records/src/main/java/com/ibm/cloud/networking/dns_records/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,6 +10,7 @@ * 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. */ + /** * DNS Records v1. */ diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsIT.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsIT.java index 8eac0fba69..acda43758b 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsIT.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsIT.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -13,6 +13,9 @@ package com.ibm.cloud.networking.dns_records.v1; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsOptions; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPatchesItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponse; import com.ibm.cloud.networking.dns_records.v1.model.CreateDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsrecordResp; @@ -31,6 +34,7 @@ import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.cloud.sdk.core.util.CredentialUtils; import java.io.InputStream; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -92,6 +96,8 @@ public void testCreateDnsRecord() throws Exception { .type("A") .ttl(Long.valueOf("120")) .content("1.2.3.4") + .proxied(false) + .data(Collections.singletonMap("anyKey", "anyValue")) .build(); // Invoke operation @@ -142,6 +148,7 @@ public void testUpdateDnsRecord() throws Exception { .ttl(Long.valueOf("120")) .content("1.2.3.4") .proxied(false) + .data(Collections.singletonMap("anyKey", "anyValue")) .build(); // Invoke operation @@ -159,6 +166,39 @@ public void testUpdateDnsRecord() throws Exception { } } + @Test (dependsOnMethods = "testUpdateDnsRecord") + public void testBatchDnsRecords() throws Exception { + try { + BatchDnsRecordsOptions batchDnsRecordsOptions = new BatchDnsRecordsOptions.Builder() + .patches(java.util.Arrays.asList(new BatchDnsRecordsRequestPatchesItem.Builder() + .id(identifier) + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .proxied(false) + .data(Collections.singletonMap("anyKey", "anyValue")) + .build())) + .build(); + + // Invoke operation + Response response = service.batchDnsRecords(batchDnsRecordsOptions).execute(); + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + BatchDnsRecordsResponse batchDnsRecordsRespResult = response.getResult(); + assertNotNull(batchDnsRecordsRespResult); + assertNotNull(batchDnsRecordsRespResult.getResult()); + assertNotNull(batchDnsRecordsRespResult.getResult().getPatches()); + assertFalse(batchDnsRecordsRespResult.getResult().getPatches().isEmpty()); + assertEquals(batchDnsRecordsRespResult.getResult().getPatches().get(0).getId(), identifier); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s\nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + @Test (dependsOnMethods = "testUpdateDnsRecord") public void testListAllDnsRecords() throws Exception { try { @@ -166,8 +206,8 @@ public void testListAllDnsRecords() throws Exception { .type("testString") .name("host1.test-example.com") .content("1.2.3.4") - .page(Long.valueOf("26")) - .perPage(Long.valueOf("5")) + .page(Long.valueOf("1")) + .perPage(Long.valueOf("20")) .order("type") .direction("asc") .match("any") diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsTest.java index 6e8f5d0738..3714b6abba 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/DnsRecordsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,14 +10,23 @@ * 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.networking.dns_records.v1; import com.ibm.cloud.networking.dns_records.v1.DnsRecords; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordDetails; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsOptions; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestDeletesItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPatchesItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPutsItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponse; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponseResult; import com.ibm.cloud.networking.dns_records.v1.model.CreateDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsrecordResp; import com.ibm.cloud.networking.dns_records.v1.model.DeleteDnsrecordRespResult; import com.ibm.cloud.networking.dns_records.v1.model.DnsrecordDetails; +import com.ibm.cloud.networking.dns_records.v1.model.DnsrecordInput; import com.ibm.cloud.networking.dns_records.v1.model.DnsrecordResp; import com.ibm.cloud.networking.dns_records.v1.model.GetDnsRecordOptions; import com.ibm.cloud.networking.dns_records.v1.model.ListAllDnsRecordsOptions; @@ -46,7 +55,7 @@ /** * Unit test class for the DnsRecords service. */ -public class DnsRecordsTest{ +public class DnsRecordsTest { final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); @@ -54,314 +63,418 @@ public class DnsRecordsTest{ protected MockWebServer server; protected DnsRecords dnsRecordsService; - public void constructClientService() throws Throwable { - System.setProperty("TESTSERVICE_AUTH_TYPE", "noAuth"); - final String serviceName = "testService"; - // set mock values for global params - String crn = "testString"; - String zoneIdentifier = "testString"; - - dnsRecordsService = DnsRecords.newInstance(crn, zoneIdentifier, serviceName); - String url = server.url("/").toString(); - dnsRecordsService.setServiceUrl(url); - } - - /** - * Negative Test - construct the service with a null authenticator. - */ + // Construct the service with a null authenticator (negative test) @Test(expectedExceptions = IllegalArgumentException.class) public void testConstructorWithNullAuthenticator() throws Throwable { final String serviceName = "testService"; - // set mock values for global params + // Set mock values for global params String crn = "testString"; String zoneIdentifier = "testString"; - new DnsRecords(crn, zoneIdentifier, serviceName, null); } + // Test the getter for the crn global parameter @Test public void testGetCrn() throws Throwable { - constructClientService(); assertEquals(dnsRecordsService.getCrn(), "testString"); } + // Test the getter for the zoneIdentifier global parameter @Test public void testGetZoneIdentifier() throws Throwable { - constructClientService(); assertEquals(dnsRecordsService.getZoneIdentifier(), "testString"); } + // Test the listAllDnsRecords operation with a valid options model parameter @Test public void testListAllDnsRecordsWOptions() throws Throwable { - // Schedule some responses. - String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"mapKey\": \"anyValue\"}}], \"result_info\": {\"page\": 1, \"per_page\": 20, \"count\": 1, \"total_count\": 2000}}"; - String listAllDnsRecordsPath = java.net.URLEncoder.encode("/v1/testString/zones/testString/dns_records", "UTF-8").replace("%2F", "/"); - + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}}], \"result_info\": {\"page\": 1, \"per_page\": 20, \"count\": 1, \"total_count\": 2000}}"; + String listAllDnsRecordsPath = "/v1/testString/zones/testString/dns_records"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - constructClientService(); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); // Construct an instance of the ListAllDnsRecordsOptions model ListAllDnsRecordsOptions listAllDnsRecordsOptionsModel = new ListAllDnsRecordsOptions.Builder() - .type("testString") - .name("host1.test-example.com") - .content("1.2.3.4") - .page(Long.valueOf("26")) - .perPage(Long.valueOf("5")) - .order("type") - .direction("asc") - .match("any") - .build(); - - // Invoke operation with valid options model (positive test) + .type("testString") + .name("host1.test-example.com") + .content("1.2.3.4") + .page(Long.valueOf("1")) + .perPage(Long.valueOf("20")) + .order("type") + .direction("asc") + .match("any") + .build(); + + // Invoke listAllDnsRecords() with a valid options model and verify the result Response response = dnsRecordsService.listAllDnsRecords(listAllDnsRecordsOptionsModel).execute(); assertNotNull(response); ListDnsrecordsResp responseObj = response.getResult(); assertNotNull(responseObj); - // Verify the contents of the request + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); assertEquals(request.getMethod(), "GET"); - - // Check query + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAllDnsRecordsPath); + // Verify query params Map query = TestUtilities.parseQueryString(request); assertNotNull(query); - // Get query params assertEquals(query.get("type"), "testString"); assertEquals(query.get("name"), "host1.test-example.com"); assertEquals(query.get("content"), "1.2.3.4"); - assertEquals(Long.valueOf(query.get("page")), Long.valueOf("26")); - assertEquals(Long.valueOf(query.get("per_page")), Long.valueOf("5")); + assertEquals(Long.valueOf(query.get("page")), Long.valueOf("1")); + assertEquals(Long.valueOf(query.get("per_page")), Long.valueOf("20")); assertEquals(query.get("order"), "type"); assertEquals(query.get("direction"), "asc"); assertEquals(query.get("match"), "any"); - // Check request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, listAllDnsRecordsPath); } + // Test the listAllDnsRecords operation with and without retries enabled @Test - public void testCreateDnsRecordWOptions() throws Throwable { - // Schedule some responses. - String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"mapKey\": \"anyValue\"}}}"; - String createDnsRecordPath = java.net.URLEncoder.encode("/v1/testString/zones/testString/dns_records", "UTF-8").replace("%2F", "/"); + public void testListAllDnsRecordsWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testListAllDnsRecordsWOptions(); - server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); + dnsRecordsService.disableRetries(); + testListAllDnsRecordsWOptions(); + } - constructClientService(); + // Test the createDnsRecord operation with a valid options model parameter + @Test + public void testCreateDnsRecordWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}}}"; + String createDnsRecordPath = "/v1/testString/zones/testString/dns_records"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); // Construct an instance of the CreateDnsRecordOptions model CreateDnsRecordOptions createDnsRecordOptionsModel = new CreateDnsRecordOptions.Builder() - .name("host-1.test-example.com") - .type("A") - .ttl(Long.valueOf("120")) - .content("1.2.3.4") - .priority(Long.valueOf("5")) - .data(new java.util.HashMap() { { put("foo", "testString"); } }) - .build(); - - // Invoke operation with valid options model (positive test) + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Invoke createDnsRecord() with a valid options model and verify the result Response response = dnsRecordsService.createDnsRecord(createDnsRecordOptionsModel).execute(); assertNotNull(response); DnsrecordResp responseObj = response.getResult(); assertNotNull(responseObj); - // Verify the contents of the request + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); assertEquals(request.getMethod(), "POST"); - - // Check query + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDnsRecordPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); + } - // Check request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, createDnsRecordPath); + // Test the createDnsRecord operation with and without retries enabled + @Test + public void testCreateDnsRecordWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testCreateDnsRecordWOptions(); + + dnsRecordsService.disableRetries(); + testCreateDnsRecordWOptions(); } + // Test the deleteDnsRecord operation with a valid options model parameter @Test public void testDeleteDnsRecordWOptions() throws Throwable { - // Schedule some responses. + // Register a mock response String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\"}}"; - String deleteDnsRecordPath = java.net.URLEncoder.encode("/v1/testString/zones/testString/dns_records/testString", "UTF-8").replace("%2F", "/"); - + String deleteDnsRecordPath = "/v1/testString/zones/testString/dns_records/testString"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - constructClientService(); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); // Construct an instance of the DeleteDnsRecordOptions model DeleteDnsRecordOptions deleteDnsRecordOptionsModel = new DeleteDnsRecordOptions.Builder() - .dnsrecordIdentifier("testString") - .build(); + .dnsrecordIdentifier("testString") + .build(); - // Invoke operation with valid options model (positive test) + // Invoke deleteDnsRecord() with a valid options model and verify the result Response response = dnsRecordsService.deleteDnsRecord(deleteDnsRecordOptionsModel).execute(); assertNotNull(response); DeleteDnsrecordResp responseObj = response.getResult(); assertNotNull(responseObj); - // Verify the contents of the request + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); assertEquals(request.getMethod(), "DELETE"); - - // Check query + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDnsRecordPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); + } - // Check request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, deleteDnsRecordPath); + // Test the deleteDnsRecord operation with and without retries enabled + @Test + public void testDeleteDnsRecordWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testDeleteDnsRecordWOptions(); + + dnsRecordsService.disableRetries(); + testDeleteDnsRecordWOptions(); } - // Test the deleteDnsRecord operation with null options model parameter + // Test the deleteDnsRecord operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) public void testDeleteDnsRecordNoOptions() throws Throwable { - // construct the service - constructClientService(); - server.enqueue(new MockResponse()); - - // Invoke operation with null options model (negative test) dnsRecordsService.deleteDnsRecord(null).execute(); } + // Test the getDnsRecord operation with a valid options model parameter @Test public void testGetDnsRecordWOptions() throws Throwable { - // Schedule some responses. - String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"mapKey\": \"anyValue\"}}}"; - String getDnsRecordPath = java.net.URLEncoder.encode("/v1/testString/zones/testString/dns_records/testString", "UTF-8").replace("%2F", "/"); - + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}}}"; + String getDnsRecordPath = "/v1/testString/zones/testString/dns_records/testString"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - constructClientService(); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); // Construct an instance of the GetDnsRecordOptions model GetDnsRecordOptions getDnsRecordOptionsModel = new GetDnsRecordOptions.Builder() - .dnsrecordIdentifier("testString") - .build(); + .dnsrecordIdentifier("testString") + .build(); - // Invoke operation with valid options model (positive test) + // Invoke getDnsRecord() with a valid options model and verify the result Response response = dnsRecordsService.getDnsRecord(getDnsRecordOptionsModel).execute(); assertNotNull(response); DnsrecordResp responseObj = response.getResult(); assertNotNull(responseObj); - // Verify the contents of the request + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); assertEquals(request.getMethod(), "GET"); - - // Check query + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDnsRecordPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); + } - // Check request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, getDnsRecordPath); + // Test the getDnsRecord operation with and without retries enabled + @Test + public void testGetDnsRecordWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testGetDnsRecordWOptions(); + + dnsRecordsService.disableRetries(); + testGetDnsRecordWOptions(); } - // Test the getDnsRecord operation with null options model parameter + // Test the getDnsRecord operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) public void testGetDnsRecordNoOptions() throws Throwable { - // construct the service - constructClientService(); - server.enqueue(new MockResponse()); - - // Invoke operation with null options model (negative test) dnsRecordsService.getDnsRecord(null).execute(); } + // Test the updateDnsRecord operation with a valid options model parameter @Test public void testUpdateDnsRecordWOptions() throws Throwable { - // Schedule some responses. - String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"mapKey\": \"anyValue\"}}}"; - String updateDnsRecordPath = java.net.URLEncoder.encode("/v1/testString/zones/testString/dns_records/testString", "UTF-8").replace("%2F", "/"); - + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"169.154.10.10\", \"zone_id\": \"023e105f4ecef8ad9ca31a8372d0c353\", \"zone_name\": \"test-example.com\", \"proxiable\": true, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}}}"; + String updateDnsRecordPath = "/v1/testString/zones/testString/dns_records/testString"; server.enqueue(new MockResponse() - .setHeader("Content-type", "application/json") - .setResponseCode(200) - .setBody(mockResponseBody)); - - constructClientService(); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); // Construct an instance of the UpdateDnsRecordOptions model UpdateDnsRecordOptions updateDnsRecordOptionsModel = new UpdateDnsRecordOptions.Builder() - .dnsrecordIdentifier("testString") - .name("host-1.test-example.com") - .type("A") - .ttl(Long.valueOf("120")) - .content("1.2.3.4") - .priority(Long.valueOf("5")) - .proxied(false) - .data(new java.util.HashMap() { { put("foo", "testString"); } }) - .build(); - - // Invoke operation with valid options model (positive test) + .dnsrecordIdentifier("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Invoke updateDnsRecord() with a valid options model and verify the result Response response = dnsRecordsService.updateDnsRecord(updateDnsRecordOptionsModel).execute(); assertNotNull(response); DnsrecordResp responseObj = response.getResult(); assertNotNull(responseObj); - // Verify the contents of the request + // Verify the contents of the request sent to the mock server RecordedRequest request = server.takeRequest(); assertNotNull(request); assertEquals(request.getMethod(), "PUT"); - - // Check query + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDnsRecordPath); + // Verify that there is no query string Map query = TestUtilities.parseQueryString(request); assertNull(query); + } - // Check request path - String parsedPath = TestUtilities.parseReqPath(request); - assertEquals(parsedPath, updateDnsRecordPath); + // Test the updateDnsRecord operation with and without retries enabled + @Test + public void testUpdateDnsRecordWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testUpdateDnsRecordWOptions(); + + dnsRecordsService.disableRetries(); + testUpdateDnsRecordWOptions(); } - // Test the updateDnsRecord operation with null options model parameter + // Test the updateDnsRecord operation with a null options model (negative test) @Test(expectedExceptions = IllegalArgumentException.class) public void testUpdateDnsRecordNoOptions() throws Throwable { - // construct the service - constructClientService(); - server.enqueue(new MockResponse()); - - // Invoke operation with null options model (negative test) dnsRecordsService.updateDnsRecord(null).execute(); } - /** Initialize the server */ + // Test the batchDnsRecords operation with a valid options model parameter + @Test + public void testBatchDnsRecordsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [[\"errors\"]], \"messages\": [[\"messages\"]], \"result\": {\"deletes\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"1.2.3.4\", \"proxiable\": false, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}, \"settings\": {\"anyKey\": \"anyValue\"}, \"meta\": {\"anyKey\": \"anyValue\"}, \"comment\": \"comment\", \"tags\": [\"tags\"]}], \"patches\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"1.2.3.4\", \"proxiable\": false, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}, \"settings\": {\"anyKey\": \"anyValue\"}, \"meta\": {\"anyKey\": \"anyValue\"}, \"comment\": \"comment\", \"tags\": [\"tags\"]}], \"posts\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"1.2.3.4\", \"proxiable\": false, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}, \"settings\": {\"anyKey\": \"anyValue\"}, \"meta\": {\"anyKey\": \"anyValue\"}, \"comment\": \"comment\", \"tags\": [\"tags\"]}], \"puts\": [{\"id\": \"f1aba936b94213e5b8dca0c0dbf1f9cc\", \"created_on\": \"2014-01-01T05:20:00.12345Z\", \"modified_on\": \"2014-01-01T05:20:00.12345Z\", \"name\": \"host-1.test-example.com\", \"type\": \"A\", \"content\": \"1.2.3.4\", \"proxiable\": false, \"proxied\": false, \"ttl\": 120, \"priority\": 5, \"data\": {\"anyKey\": \"anyValue\"}, \"settings\": {\"anyKey\": \"anyValue\"}, \"meta\": {\"anyKey\": \"anyValue\"}, \"comment\": \"comment\", \"tags\": [\"tags\"]}]}}"; + String batchDnsRecordsPath = "/v1/testString/zones/testString/dns_records/batch"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the BatchDnsRecordsRequestDeletesItem model + BatchDnsRecordsRequestDeletesItem batchDnsRecordsRequestDeletesItemModel = new BatchDnsRecordsRequestDeletesItem.Builder() + .id("testString") + .build(); + + // Construct an instance of the BatchDnsRecordsRequestPatchesItem model + BatchDnsRecordsRequestPatchesItem batchDnsRecordsRequestPatchesItemModel = new BatchDnsRecordsRequestPatchesItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the DnsrecordInput model + DnsrecordInput dnsrecordInputModel = new DnsrecordInput.Builder() + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the BatchDnsRecordsRequestPutsItem model + BatchDnsRecordsRequestPutsItem batchDnsRecordsRequestPutsItemModel = new BatchDnsRecordsRequestPutsItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + + // Construct an instance of the BatchDnsRecordsOptions model + BatchDnsRecordsOptions batchDnsRecordsOptionsModel = new BatchDnsRecordsOptions.Builder() + .deletes(java.util.Arrays.asList(batchDnsRecordsRequestDeletesItemModel)) + .patches(java.util.Arrays.asList(batchDnsRecordsRequestPatchesItemModel)) + .posts(java.util.Arrays.asList(dnsrecordInputModel)) + .puts(java.util.Arrays.asList(batchDnsRecordsRequestPutsItemModel)) + .build(); + + // Invoke batchDnsRecords() with a valid options model and verify the result + Response response = dnsRecordsService.batchDnsRecords(batchDnsRecordsOptionsModel).execute(); + assertNotNull(response); + BatchDnsRecordsResponse 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, batchDnsRecordsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the batchDnsRecords operation with and without retries enabled + @Test + public void testBatchDnsRecordsWRetries() throws Throwable { + dnsRecordsService.enableRetries(4, 30); + testBatchDnsRecordsWOptions(); + + dnsRecordsService.disableRetries(); + testBatchDnsRecordsWOptions(); + } + + // Perform setup needed before each test method @BeforeMethod - public void setUpMockServer() { + public void beforeEachTest() { + // Start the mock server. try { - server = new MockWebServer(); - // register handler - server.start(); - } - catch (IOException err) { - fail("Failed to instantiate mock web server"); + 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 tearDownMockServer() throws IOException { + public void afterEachTest() throws IOException { server.shutdown(); dnsRecordsService = null; } -} \ No newline at end of file + + // 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"; + // set mock values for global params + String crn = "testString"; + String zoneIdentifier = "testString"; + + dnsRecordsService = DnsRecords.newInstance(crn, zoneIdentifier, serviceName); + String url = server.url("/").toString(); + dnsRecordsService.setServiceUrl(url); + } +} diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetailsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetailsTest.java new file mode 100644 index 0000000000..f654210fa3 --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordDetailsTest.java @@ -0,0 +1,51 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordDetails; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordDetails model. + */ +public class BatchDnsRecordDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordDetails() throws Throwable { + BatchDnsRecordDetails batchDnsRecordDetailsModel = new BatchDnsRecordDetails(); + assertNull(batchDnsRecordDetailsModel.getId()); + assertNull(batchDnsRecordDetailsModel.getCreatedOn()); + assertNull(batchDnsRecordDetailsModel.getModifiedOn()); + assertNull(batchDnsRecordDetailsModel.getName()); + assertNull(batchDnsRecordDetailsModel.getType()); + assertNull(batchDnsRecordDetailsModel.getContent()); + assertNull(batchDnsRecordDetailsModel.isProxiable()); + assertNull(batchDnsRecordDetailsModel.isProxied()); + assertNull(batchDnsRecordDetailsModel.getTtl()); + assertNull(batchDnsRecordDetailsModel.getPriority()); + assertNull(batchDnsRecordDetailsModel.getData()); + assertNull(batchDnsRecordDetailsModel.getSettings()); + assertNull(batchDnsRecordDetailsModel.getMeta()); + assertNull(batchDnsRecordDetailsModel.getComment()); + assertNull(batchDnsRecordDetailsModel.getTags()); + } +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptionsTest.java new file mode 100644 index 0000000000..b45a246f02 --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsOptionsTest.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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsOptions; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestDeletesItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPatchesItem; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPutsItem; +import com.ibm.cloud.networking.dns_records.v1.model.DnsrecordInput; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsOptions model. + */ +public class BatchDnsRecordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsOptions() throws Throwable { + BatchDnsRecordsRequestDeletesItem batchDnsRecordsRequestDeletesItemModel = new BatchDnsRecordsRequestDeletesItem.Builder() + .id("testString") + .build(); + assertEquals(batchDnsRecordsRequestDeletesItemModel.id(), "testString"); + + BatchDnsRecordsRequestPatchesItem batchDnsRecordsRequestPatchesItemModel = new BatchDnsRecordsRequestPatchesItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(batchDnsRecordsRequestPatchesItemModel.id(), "testString"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.type(), "A"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPatchesItemModel.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPatchesItemModel.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPatchesItemModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + DnsrecordInput dnsrecordInputModel = new DnsrecordInput.Builder() + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(dnsrecordInputModel.name(), "host-1.test-example.com"); + assertEquals(dnsrecordInputModel.type(), "A"); + assertEquals(dnsrecordInputModel.ttl(), Long.valueOf("120")); + assertEquals(dnsrecordInputModel.content(), "1.2.3.4"); + assertEquals(dnsrecordInputModel.priority(), Long.valueOf("5")); + assertEquals(dnsrecordInputModel.proxied(), Boolean.valueOf(false)); + assertEquals(dnsrecordInputModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + BatchDnsRecordsRequestPutsItem batchDnsRecordsRequestPutsItemModel = new BatchDnsRecordsRequestPutsItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(batchDnsRecordsRequestPutsItemModel.id(), "testString"); + assertEquals(batchDnsRecordsRequestPutsItemModel.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPutsItemModel.type(), "A"); + assertEquals(batchDnsRecordsRequestPutsItemModel.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPutsItemModel.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPutsItemModel.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPutsItemModel.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPutsItemModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + BatchDnsRecordsOptions batchDnsRecordsOptionsModel = new BatchDnsRecordsOptions.Builder() + .deletes(java.util.Arrays.asList(batchDnsRecordsRequestDeletesItemModel)) + .patches(java.util.Arrays.asList(batchDnsRecordsRequestPatchesItemModel)) + .posts(java.util.Arrays.asList(dnsrecordInputModel)) + .puts(java.util.Arrays.asList(batchDnsRecordsRequestPutsItemModel)) + .build(); + assertEquals(batchDnsRecordsOptionsModel.deletes(), java.util.Arrays.asList(batchDnsRecordsRequestDeletesItemModel)); + assertEquals(batchDnsRecordsOptionsModel.patches(), java.util.Arrays.asList(batchDnsRecordsRequestPatchesItemModel)); + assertEquals(batchDnsRecordsOptionsModel.posts(), java.util.Arrays.asList(dnsrecordInputModel)); + assertEquals(batchDnsRecordsOptionsModel.puts(), java.util.Arrays.asList(batchDnsRecordsRequestPutsItemModel)); + } +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItemTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItemTest.java new file mode 100644 index 0000000000..d36d01513c --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestDeletesItemTest.java @@ -0,0 +1,51 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestDeletesItem; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsRequestDeletesItem model. + */ +public class BatchDnsRecordsRequestDeletesItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsRequestDeletesItem() throws Throwable { + BatchDnsRecordsRequestDeletesItem batchDnsRecordsRequestDeletesItemModel = new BatchDnsRecordsRequestDeletesItem.Builder() + .id("testString") + .build(); + assertEquals(batchDnsRecordsRequestDeletesItemModel.id(), "testString"); + + String json = TestUtilities.serialize(batchDnsRecordsRequestDeletesItemModel); + + BatchDnsRecordsRequestDeletesItem batchDnsRecordsRequestDeletesItemModelNew = TestUtilities.deserialize(json, BatchDnsRecordsRequestDeletesItem.class); + assertTrue(batchDnsRecordsRequestDeletesItemModelNew instanceof BatchDnsRecordsRequestDeletesItem); + assertEquals(batchDnsRecordsRequestDeletesItemModelNew.id(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBatchDnsRecordsRequestDeletesItemError() throws Throwable { + new BatchDnsRecordsRequestDeletesItem.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItemTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItemTest.java new file mode 100644 index 0000000000..e94fced22b --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPatchesItemTest.java @@ -0,0 +1,72 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPatchesItem; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsRequestPatchesItem model. + */ +public class BatchDnsRecordsRequestPatchesItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsRequestPatchesItem() throws Throwable { + BatchDnsRecordsRequestPatchesItem batchDnsRecordsRequestPatchesItemModel = new BatchDnsRecordsRequestPatchesItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(batchDnsRecordsRequestPatchesItemModel.id(), "testString"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.type(), "A"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPatchesItemModel.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPatchesItemModel.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPatchesItemModel.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPatchesItemModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(batchDnsRecordsRequestPatchesItemModel); + + BatchDnsRecordsRequestPatchesItem batchDnsRecordsRequestPatchesItemModelNew = TestUtilities.deserialize(json, BatchDnsRecordsRequestPatchesItem.class); + assertTrue(batchDnsRecordsRequestPatchesItemModelNew instanceof BatchDnsRecordsRequestPatchesItem); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.id(), "testString"); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.type(), "A"); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPatchesItemModelNew.data().toString(), java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBatchDnsRecordsRequestPatchesItemError() throws Throwable { + new BatchDnsRecordsRequestPatchesItem.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItemTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItemTest.java new file mode 100644 index 0000000000..af3573b7bd --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsRequestPutsItemTest.java @@ -0,0 +1,72 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsRequestPutsItem; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsRequestPutsItem model. + */ +public class BatchDnsRecordsRequestPutsItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsRequestPutsItem() throws Throwable { + BatchDnsRecordsRequestPutsItem batchDnsRecordsRequestPutsItemModel = new BatchDnsRecordsRequestPutsItem.Builder() + .id("testString") + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(batchDnsRecordsRequestPutsItemModel.id(), "testString"); + assertEquals(batchDnsRecordsRequestPutsItemModel.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPutsItemModel.type(), "A"); + assertEquals(batchDnsRecordsRequestPutsItemModel.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPutsItemModel.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPutsItemModel.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPutsItemModel.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPutsItemModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(batchDnsRecordsRequestPutsItemModel); + + BatchDnsRecordsRequestPutsItem batchDnsRecordsRequestPutsItemModelNew = TestUtilities.deserialize(json, BatchDnsRecordsRequestPutsItem.class); + assertTrue(batchDnsRecordsRequestPutsItemModelNew instanceof BatchDnsRecordsRequestPutsItem); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.id(), "testString"); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.name(), "host-1.test-example.com"); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.type(), "A"); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.ttl(), Long.valueOf("120")); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.content(), "1.2.3.4"); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.priority(), Long.valueOf("5")); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.proxied(), Boolean.valueOf(false)); + assertEquals(batchDnsRecordsRequestPutsItemModelNew.data().toString(), java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBatchDnsRecordsRequestPutsItemError() throws Throwable { + new BatchDnsRecordsRequestPutsItem.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResultTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResultTest.java new file mode 100644 index 0000000000..cbd279b760 --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseResultTest.java @@ -0,0 +1,41 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordDetails; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponseResult; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsResponseResult model. + */ +public class BatchDnsRecordsResponseResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsResponseResult() throws Throwable { + BatchDnsRecordsResponseResult batchDnsRecordsResponseResultModel = new BatchDnsRecordsResponseResult(); + assertNull(batchDnsRecordsResponseResultModel.getDeletes()); + assertNull(batchDnsRecordsResponseResultModel.getPatches()); + assertNull(batchDnsRecordsResponseResultModel.getPosts()); + assertNull(batchDnsRecordsResponseResultModel.getPuts()); + } +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseTest.java new file mode 100644 index 0000000000..bc74728851 --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/BatchDnsRecordsResponseTest.java @@ -0,0 +1,42 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordDetails; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponse; +import com.ibm.cloud.networking.dns_records.v1.model.BatchDnsRecordsResponseResult; +import com.ibm.cloud.networking.dns_records.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 BatchDnsRecordsResponse model. + */ +public class BatchDnsRecordsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchDnsRecordsResponse() throws Throwable { + BatchDnsRecordsResponse batchDnsRecordsResponseModel = new BatchDnsRecordsResponse(); + assertNull(batchDnsRecordsResponseModel.isSuccess()); + assertNull(batchDnsRecordsResponseModel.getErrors()); + assertNull(batchDnsRecordsResponseModel.getMessages()); + assertNull(batchDnsRecordsResponseModel.getResult()); + } +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptionsTest.java index 4d0b5c9415..379d6b92a6 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptionsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/CreateDnsRecordOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -37,13 +37,15 @@ public void testCreateDnsRecordOptions() throws Throwable { .ttl(Long.valueOf("120")) .content("1.2.3.4") .priority(Long.valueOf("5")) - .data(new java.util.HashMap() { { put("foo", "testString"); } }) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals(createDnsRecordOptionsModel.name(), "host-1.test-example.com"); assertEquals(createDnsRecordOptionsModel.type(), "A"); assertEquals(createDnsRecordOptionsModel.ttl(), Long.valueOf("120")); assertEquals(createDnsRecordOptionsModel.content(), "1.2.3.4"); assertEquals(createDnsRecordOptionsModel.priority(), Long.valueOf("5")); - assertEquals(createDnsRecordOptionsModel.data(), new java.util.HashMap() { { put("foo", "testString"); } }); + assertEquals(createDnsRecordOptionsModel.proxied(), Boolean.valueOf(false)); + assertEquals(createDnsRecordOptionsModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); } } \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptionsTest.java index c9f51cfa90..43f0ba8a96 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptionsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsRecordOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResultTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResultTest.java index 06f2d52e73..5faaf532ec 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResultTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespResultTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespTest.java index 9c2f78820a..d8f1b08106 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DeleteDnsrecordRespTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetailsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetailsTest.java index 415a854818..c996be31ac 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetailsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordDetailsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInputTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInputTest.java new file mode 100644 index 0000000000..7691cfc87d --- /dev/null +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordInputTest.java @@ -0,0 +1,69 @@ +/* + * (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.networking.dns_records.v1.model; + +import com.ibm.cloud.networking.dns_records.v1.model.DnsrecordInput; +import com.ibm.cloud.networking.dns_records.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 DnsrecordInput model. + */ +public class DnsrecordInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDnsrecordInput() throws Throwable { + DnsrecordInput dnsrecordInputModel = new DnsrecordInput.Builder() + .name("host-1.test-example.com") + .type("A") + .ttl(Long.valueOf("120")) + .content("1.2.3.4") + .priority(Long.valueOf("5")) + .proxied(false) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) + .build(); + assertEquals(dnsrecordInputModel.name(), "host-1.test-example.com"); + assertEquals(dnsrecordInputModel.type(), "A"); + assertEquals(dnsrecordInputModel.ttl(), Long.valueOf("120")); + assertEquals(dnsrecordInputModel.content(), "1.2.3.4"); + assertEquals(dnsrecordInputModel.priority(), Long.valueOf("5")); + assertEquals(dnsrecordInputModel.proxied(), Boolean.valueOf(false)); + assertEquals(dnsrecordInputModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); + + String json = TestUtilities.serialize(dnsrecordInputModel); + + DnsrecordInput dnsrecordInputModelNew = TestUtilities.deserialize(json, DnsrecordInput.class); + assertTrue(dnsrecordInputModelNew instanceof DnsrecordInput); + assertEquals(dnsrecordInputModelNew.name(), "host-1.test-example.com"); + assertEquals(dnsrecordInputModelNew.type(), "A"); + assertEquals(dnsrecordInputModelNew.ttl(), Long.valueOf("120")); + assertEquals(dnsrecordInputModelNew.content(), "1.2.3.4"); + assertEquals(dnsrecordInputModelNew.priority(), Long.valueOf("5")); + assertEquals(dnsrecordInputModelNew.proxied(), Boolean.valueOf(false)); + assertEquals(dnsrecordInputModelNew.data().toString(), java.util.Collections.singletonMap("anyKey", "anyValue").toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDnsrecordInputError() throws Throwable { + new DnsrecordInput.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordRespTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordRespTest.java index 17a465b3e3..025980c3a3 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordRespTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/DnsrecordRespTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptionsTest.java index e9542de4ed..3ee8426f69 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptionsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/GetDnsRecordOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptionsTest.java index eb43316af5..34499d6da7 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptionsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListAllDnsRecordsOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -35,8 +35,8 @@ public void testListAllDnsRecordsOptions() throws Throwable { .type("testString") .name("host1.test-example.com") .content("1.2.3.4") - .page(Long.valueOf("26")) - .perPage(Long.valueOf("5")) + .page(Long.valueOf("1")) + .perPage(Long.valueOf("20")) .order("type") .direction("asc") .match("any") @@ -44,8 +44,8 @@ public void testListAllDnsRecordsOptions() throws Throwable { assertEquals(listAllDnsRecordsOptionsModel.type(), "testString"); assertEquals(listAllDnsRecordsOptionsModel.name(), "host1.test-example.com"); assertEquals(listAllDnsRecordsOptionsModel.content(), "1.2.3.4"); - assertEquals(listAllDnsRecordsOptionsModel.page(), Long.valueOf("26")); - assertEquals(listAllDnsRecordsOptionsModel.perPage(), Long.valueOf("5")); + assertEquals(listAllDnsRecordsOptionsModel.page(), Long.valueOf("1")); + assertEquals(listAllDnsRecordsOptionsModel.perPage(), Long.valueOf("20")); assertEquals(listAllDnsRecordsOptionsModel.order(), "type"); assertEquals(listAllDnsRecordsOptionsModel.direction(), "asc"); assertEquals(listAllDnsRecordsOptionsModel.match(), "any"); diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsRespTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsRespTest.java index 4f3b624854..13e0ae8c27 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsRespTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ListDnsrecordsRespTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfoTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfoTest.java index 94548f9a73..81b7ae8f83 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfoTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/ResultInfoTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptionsTest.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptionsTest.java index 2c1a5699e5..33c1879102 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptionsTest.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/model/UpdateDnsRecordOptionsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -39,7 +39,7 @@ public void testUpdateDnsRecordOptions() throws Throwable { .content("1.2.3.4") .priority(Long.valueOf("5")) .proxied(false) - .data(new java.util.HashMap() { { put("foo", "testString"); } }) + .data(java.util.Collections.singletonMap("anyKey", "anyValue")) .build(); assertEquals(updateDnsRecordOptionsModel.dnsrecordIdentifier(), "testString"); assertEquals(updateDnsRecordOptionsModel.name(), "host-1.test-example.com"); @@ -48,7 +48,7 @@ public void testUpdateDnsRecordOptions() throws Throwable { assertEquals(updateDnsRecordOptionsModel.content(), "1.2.3.4"); assertEquals(updateDnsRecordOptionsModel.priority(), Long.valueOf("5")); assertEquals(updateDnsRecordOptionsModel.proxied(), Boolean.valueOf(false)); - assertEquals(updateDnsRecordOptionsModel.data(), new java.util.HashMap() { { put("foo", "testString"); } }); + assertEquals(updateDnsRecordOptionsModel.data(), java.util.Collections.singletonMap("anyKey", "anyValue")); } @Test(expectedExceptions = IllegalArgumentException.class) diff --git a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/utils/TestUtilities.java b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/utils/TestUtilities.java index a21f613d89..c472b57fbc 100644 --- a/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/utils/TestUtilities.java +++ b/modules/dns-records/src/test/java/com/ibm/cloud/networking/dns_records/v1/utils/TestUtilities.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2020. + * (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 @@ -10,8 +10,10 @@ * 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.networking.dns_records.v1.utils; +import java.util.Base64; import java.util.Map; import java.util.Set; import java.util.List; @@ -20,10 +22,10 @@ import java.util.HashMap; import java.io.InputStream; import java.io.ByteArrayInputStream; -import java.text.SimpleDateFormat; 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; @@ -115,15 +117,15 @@ public static List creatMockListFileWithMetadata() { return list; } - public static byte[] createMockByteArray(String bytes) { - return bytes.getBytes(); + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); } public static Date createMockDate(String date) throws Exception { - return new SimpleDateFormat("yyyy-MM-dd").parse(date); + return DateUtils.parseAsDate(date); } public static Date createMockDateTime(String date) throws Exception { - return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + return DateUtils.parseAsDateTime(date); } } \ No newline at end of file