diff --git a/modules/rulesets/pom.xml b/modules/rulesets/pom.xml new file mode 100644 index 000000000..857369792 --- /dev/null +++ b/modules/rulesets/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + + + networking + com.ibm.cloud + 99-SNAPSHOT + ../.. + + + + rulesets + + + Cloud Internet Services rulesets + jar + + + + com.ibm.cloud + sdk-core + + + + networking-common + ${project.groupId} + + + networking-common + ${project.groupId} + test-jar + tests + test + + + org.testng + testng + test + + + com.squareup.okhttp3 + mockwebserver + test + + + org.powermock + powermock-api-mockito2 + test + + + org.powermock + powermock-module-testng + test + + + + + + IBM Cloud DevX SDK Development + devxsdk@us.ibm.com + https://www.ibm.com/ + + + + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/Rulesets.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/Rulesets.java new file mode 100644 index 000000000..325ab21c7 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/Rulesets.java @@ -0,0 +1,1127 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.107.0-b68ebf7a-20250811-145645 + */ + +package com.ibm.cloud.networking.rulesets.v1; + +import com.google.gson.JsonObject; +import com.ibm.cloud.networking.rulesets.v1.model.CreateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.CreateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionByTagOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.ListRulesetsResp; +import com.ibm.cloud.networking.rulesets.v1.model.RuleResp; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetResp; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.common.SdkCommon; +import com.ibm.cloud.sdk.core.http.RequestBuilder; +import com.ibm.cloud.sdk.core.http.ResponseConverter; +import com.ibm.cloud.sdk.core.http.ServiceCall; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; +import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Rulesets Engine. + * + * API Version: 1.0.1 + */ +public class Rulesets extends BaseService { + + /** + * Default service name used when configuring the `Rulesets` client. + */ + public static final String DEFAULT_SERVICE_NAME = "rulesets"; + + /** + * Default service endpoint URL. + */ + public static final String DEFAULT_SERVICE_URL = "https://api.cis.cloud.ibm.com"; + + private String crn; + + private String zoneIdentifier; + + /** + * Class method which constructs an instance of the `Rulesets` client. + * The default service name is used to configure the client instance. + * + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier zone identifier. + * @return an instance of the `Rulesets` client using external configuration + */ + public static Rulesets newInstance(String crn, String zoneIdentifier) { + return newInstance(crn, zoneIdentifier, DEFAULT_SERVICE_NAME); + } + + /** + * Class method which constructs an instance of the `Rulesets` client. + * The specified service name is used to configure the client instance. + * + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier zone identifier. + * @param serviceName the service name to be used when configuring the client instance + * @return an instance of the `Rulesets` client using external configuration + */ + public static Rulesets newInstance(String crn, String zoneIdentifier, String serviceName) { + Authenticator authenticator = ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName); + Rulesets service = new Rulesets(crn, zoneIdentifier, serviceName, authenticator); + service.configureService(serviceName); + return service; + } + + /** + * Constructs an instance of the `Rulesets` client. + * The specified service name and authenticator are used to configure the client instance. + * + * @param crn Full url-encoded CRN of the service instance. + * @param zoneIdentifier zone identifier. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client + */ + public Rulesets(String crn, String zoneIdentifier, String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + setCrn(crn); + setZoneIdentifier(zoneIdentifier); + } + + /** + * Gets the crn. + * + * Full url-encoded CRN of the service instance. + * + * @return the crn + */ + public String getCrn() { + return this.crn; + } + + /** + * Sets the crn. + * + * @param crn the new crn + */ + public void setCrn(final String crn) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(crn, "crn cannot be empty."); + this.crn = crn; + } + + /** + * Gets the zoneIdentifier. + * + * zone identifier. + * + * @return the zoneIdentifier + */ + public String getZoneIdentifier() { + return this.zoneIdentifier; + } + + /** + * Sets the zoneIdentifier. + * + * @param zoneIdentifier the new zoneIdentifier + */ + public void setZoneIdentifier(final String zoneIdentifier) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(zoneIdentifier, "zoneIdentifier cannot be empty."); + this.zoneIdentifier = zoneIdentifier; + } + + /** + * List Instance rulesets. + * + * List all rulesets at the instance level. + * + * @param getInstanceRulesetsOptions the {@link GetInstanceRulesetsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getInstanceRulesets(GetInstanceRulesetsOptions getInstanceRulesetsOptions) { + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceRulesets"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List Instance rulesets. + * + * List all rulesets at the instance level. + * + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getInstanceRulesets() { + return getInstanceRulesets(null); + } + + /** + * Get an instance ruleset. + * + * View a specific instance ruleset. + * + * @param getInstanceRulesetOptions the {@link GetInstanceRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getInstanceRuleset(GetInstanceRulesetOptions getInstanceRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceRulesetOptions, + "getInstanceRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", getInstanceRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update an instance ruleset. + * + * Update a specific instance ruleset. + * + * @param updateInstanceRulesetOptions the {@link UpdateInstanceRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateInstanceRuleset(UpdateInstanceRulesetOptions updateInstanceRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateInstanceRulesetOptions, + "updateInstanceRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", updateInstanceRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateInstanceRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateInstanceRulesetOptions.description() != null) { + contentJson.addProperty("description", updateInstanceRulesetOptions.description()); + } + if (updateInstanceRulesetOptions.kind() != null) { + contentJson.addProperty("kind", updateInstanceRulesetOptions.kind()); + } + if (updateInstanceRulesetOptions.name() != null) { + contentJson.addProperty("name", updateInstanceRulesetOptions.name()); + } + if (updateInstanceRulesetOptions.phase() != null) { + contentJson.addProperty("phase", updateInstanceRulesetOptions.phase()); + } + if (updateInstanceRulesetOptions.rules() != null) { + contentJson.add("rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceRulesetOptions.rules())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete an instance ruleset. + * + * Delete a specific instance ruleset. + * + * @param deleteInstanceRulesetOptions the {@link DeleteInstanceRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteInstanceRuleset(DeleteInstanceRulesetOptions deleteInstanceRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteInstanceRulesetOptions, + "deleteInstanceRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", deleteInstanceRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteInstanceRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List version of an instance ruleset. + * + * List all versions of a specific instance ruleset. + * + * @param getInstanceRulesetVersionsOptions the {@link GetInstanceRulesetVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getInstanceRulesetVersions(GetInstanceRulesetVersionsOptions getInstanceRulesetVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceRulesetVersionsOptions, + "getInstanceRulesetVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", getInstanceRulesetVersionsOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceRulesetVersions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a specific version of an instance ruleset. + * + * View a specific version of a specific instance ruleset. + * + * @param getInstanceRulesetVersionOptions the {@link GetInstanceRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getInstanceRulesetVersion(GetInstanceRulesetVersionOptions getInstanceRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceRulesetVersionOptions, + "getInstanceRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", getInstanceRulesetVersionOptions.rulesetId()); + pathParamsMap.put("ruleset_version", getInstanceRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a specific version of an instance ruleset. + * + * Delete a specific version of a specific instance ruleset. + * + * @param deleteInstanceRulesetVersionOptions the {@link DeleteInstanceRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteInstanceRulesetVersion(DeleteInstanceRulesetVersionOptions deleteInstanceRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteInstanceRulesetVersionOptions, + "deleteInstanceRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", deleteInstanceRulesetVersionOptions.rulesetId()); + pathParamsMap.put("ruleset_version", deleteInstanceRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteInstanceRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get an instance entrypoint ruleset. + * + * Get the instance ruleset for the given phase's entrypoint. + * + * @param getInstanceEntrypointRulesetOptions the {@link GetInstanceEntrypointRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getInstanceEntrypointRuleset(GetInstanceEntrypointRulesetOptions getInstanceEntrypointRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceEntrypointRulesetOptions, + "getInstanceEntrypointRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_phase", getInstanceEntrypointRulesetOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/phases/{ruleset_phase}/entrypoint", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceEntrypointRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update an instance entrypoint ruleset. + * + * Updates the instance ruleset for the given phase's entry point. + * + * @param updateInstanceEntrypointRulesetOptions the {@link UpdateInstanceEntrypointRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateInstanceEntrypointRuleset(UpdateInstanceEntrypointRulesetOptions updateInstanceEntrypointRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateInstanceEntrypointRulesetOptions, + "updateInstanceEntrypointRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_phase", updateInstanceEntrypointRulesetOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/phases/{ruleset_phase}/entrypoint", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateInstanceEntrypointRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateInstanceEntrypointRulesetOptions.description() != null) { + contentJson.addProperty("description", updateInstanceEntrypointRulesetOptions.description()); + } + if (updateInstanceEntrypointRulesetOptions.kind() != null) { + contentJson.addProperty("kind", updateInstanceEntrypointRulesetOptions.kind()); + } + if (updateInstanceEntrypointRulesetOptions.name() != null) { + contentJson.addProperty("name", updateInstanceEntrypointRulesetOptions.name()); + } + if (updateInstanceEntrypointRulesetOptions.phase() != null) { + contentJson.addProperty("phase", updateInstanceEntrypointRulesetOptions.phase()); + } + if (updateInstanceEntrypointRulesetOptions.rules() != null) { + contentJson.add("rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceEntrypointRulesetOptions.rules())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List an instance entry point ruleset's versions. + * + * Lists the instance ruleset versions for the given phase's entry point. + * + * @param getInstanceEntryPointRulesetVersionsOptions the {@link GetInstanceEntryPointRulesetVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getInstanceEntryPointRulesetVersions(GetInstanceEntryPointRulesetVersionsOptions getInstanceEntryPointRulesetVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceEntryPointRulesetVersionsOptions, + "getInstanceEntryPointRulesetVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_phase", getInstanceEntryPointRulesetVersionsOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/phases/{ruleset_phase}/entrypoint/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceEntryPointRulesetVersions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get an instance entry point ruleset version. + * + * Fetches a specific version of an instance entry point ruleset. + * + * @param getInstanceEntryPointRulesetVersionOptions the {@link GetInstanceEntryPointRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getInstanceEntryPointRulesetVersion(GetInstanceEntryPointRulesetVersionOptions getInstanceEntryPointRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceEntryPointRulesetVersionOptions, + "getInstanceEntryPointRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_phase", getInstanceEntryPointRulesetVersionOptions.rulesetPhase()); + pathParamsMap.put("ruleset_version", getInstanceEntryPointRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/phases/{ruleset_phase}/entrypoint/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceEntryPointRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create an instance ruleset rule. + * + * Create an instance ruleset rule. + * + * @param createInstanceRulesetRuleOptions the {@link CreateInstanceRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall createInstanceRulesetRule(CreateInstanceRulesetRuleOptions createInstanceRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createInstanceRulesetRuleOptions, + "createInstanceRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", createInstanceRulesetRuleOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/rules", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "createInstanceRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (createInstanceRulesetRuleOptions.action() != null) { + contentJson.addProperty("action", createInstanceRulesetRuleOptions.action()); + } + if (createInstanceRulesetRuleOptions.actionParameters() != null) { + contentJson.add("action_parameters", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createInstanceRulesetRuleOptions.actionParameters())); + } + if (createInstanceRulesetRuleOptions.ratelimit() != null) { + contentJson.add("ratelimit", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createInstanceRulesetRuleOptions.ratelimit())); + } + if (createInstanceRulesetRuleOptions.description() != null) { + contentJson.addProperty("description", createInstanceRulesetRuleOptions.description()); + } + if (createInstanceRulesetRuleOptions.enabled() != null) { + contentJson.addProperty("enabled", createInstanceRulesetRuleOptions.enabled()); + } + if (createInstanceRulesetRuleOptions.expression() != null) { + contentJson.addProperty("expression", createInstanceRulesetRuleOptions.expression()); + } + if (createInstanceRulesetRuleOptions.id() != null) { + contentJson.addProperty("id", createInstanceRulesetRuleOptions.id()); + } + if (createInstanceRulesetRuleOptions.logging() != null) { + contentJson.add("logging", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createInstanceRulesetRuleOptions.logging())); + } + if (createInstanceRulesetRuleOptions.ref() != null) { + contentJson.addProperty("ref", createInstanceRulesetRuleOptions.ref()); + } + if (createInstanceRulesetRuleOptions.position() != null) { + contentJson.add("position", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createInstanceRulesetRuleOptions.position())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update an instance ruleset rule. + * + * Update an instance ruleset rule. + * + * @param updateInstanceRulesetRuleOptions the {@link UpdateInstanceRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateInstanceRulesetRule(UpdateInstanceRulesetRuleOptions updateInstanceRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateInstanceRulesetRuleOptions, + "updateInstanceRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", updateInstanceRulesetRuleOptions.rulesetId()); + pathParamsMap.put("rule_id", updateInstanceRulesetRuleOptions.ruleId()); + RequestBuilder builder = RequestBuilder.patch(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/rules/{rule_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateInstanceRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateInstanceRulesetRuleOptions.action() != null) { + contentJson.addProperty("action", updateInstanceRulesetRuleOptions.action()); + } + if (updateInstanceRulesetRuleOptions.actionParameters() != null) { + contentJson.add("action_parameters", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceRulesetRuleOptions.actionParameters())); + } + if (updateInstanceRulesetRuleOptions.ratelimit() != null) { + contentJson.add("ratelimit", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceRulesetRuleOptions.ratelimit())); + } + if (updateInstanceRulesetRuleOptions.description() != null) { + contentJson.addProperty("description", updateInstanceRulesetRuleOptions.description()); + } + if (updateInstanceRulesetRuleOptions.enabled() != null) { + contentJson.addProperty("enabled", updateInstanceRulesetRuleOptions.enabled()); + } + if (updateInstanceRulesetRuleOptions.expression() != null) { + contentJson.addProperty("expression", updateInstanceRulesetRuleOptions.expression()); + } + if (updateInstanceRulesetRuleOptions.id() != null) { + contentJson.addProperty("id", updateInstanceRulesetRuleOptions.id()); + } + if (updateInstanceRulesetRuleOptions.logging() != null) { + contentJson.add("logging", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceRulesetRuleOptions.logging())); + } + if (updateInstanceRulesetRuleOptions.ref() != null) { + contentJson.addProperty("ref", updateInstanceRulesetRuleOptions.ref()); + } + if (updateInstanceRulesetRuleOptions.position() != null) { + contentJson.add("position", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateInstanceRulesetRuleOptions.position())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete an instance ruleset rule. + * + * Delete an instance ruleset rule. + * + * @param deleteInstanceRulesetRuleOptions the {@link DeleteInstanceRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RuleResp} + */ + public ServiceCall deleteInstanceRulesetRule(DeleteInstanceRulesetRuleOptions deleteInstanceRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteInstanceRulesetRuleOptions, + "deleteInstanceRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", deleteInstanceRulesetRuleOptions.rulesetId()); + pathParamsMap.put("rule_id", deleteInstanceRulesetRuleOptions.ruleId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/rules/{rule_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteInstanceRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List an instance ruleset verion's rules by tag. + * + * Lists rules by tag for a specific version of an instance ruleset. + * + * @param getInstanceRulesetVersionByTagOptions the {@link GetInstanceRulesetVersionByTagOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getInstanceRulesetVersionByTag(GetInstanceRulesetVersionByTagOptions getInstanceRulesetVersionByTagOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getInstanceRulesetVersionByTagOptions, + "getInstanceRulesetVersionByTagOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("ruleset_id", getInstanceRulesetVersionByTagOptions.rulesetId()); + pathParamsMap.put("ruleset_version", getInstanceRulesetVersionByTagOptions.rulesetVersion()); + pathParamsMap.put("rule_tag", getInstanceRulesetVersionByTagOptions.ruleTag()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/rulesets/{ruleset_id}/versions/{ruleset_version}/by_tag/{rule_tag}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getInstanceRulesetVersionByTag"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List zone rulesets. + * + * List all rulesets at the zone level. + * + * @param getZoneRulesetsOptions the {@link GetZoneRulesetsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getZoneRulesets(GetZoneRulesetsOptions getZoneRulesetsOptions) { + 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}/rulesets", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneRulesets"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List zone rulesets. + * + * List all rulesets at the zone level. + * + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getZoneRulesets() { + return getZoneRulesets(null); + } + + /** + * Get a zone ruleset. + * + * View a specific zone ruleset. + * + * @param getZoneRulesetOptions the {@link GetZoneRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getZoneRuleset(GetZoneRulesetOptions getZoneRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneRulesetOptions, + "getZoneRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", getZoneRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a zone ruleset. + * + * Update a specific zone ruleset. + * + * @param updateZoneRulesetOptions the {@link UpdateZoneRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateZoneRuleset(UpdateZoneRulesetOptions updateZoneRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateZoneRulesetOptions, + "updateZoneRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", updateZoneRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateZoneRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateZoneRulesetOptions.description() != null) { + contentJson.addProperty("description", updateZoneRulesetOptions.description()); + } + if (updateZoneRulesetOptions.kind() != null) { + contentJson.addProperty("kind", updateZoneRulesetOptions.kind()); + } + if (updateZoneRulesetOptions.name() != null) { + contentJson.addProperty("name", updateZoneRulesetOptions.name()); + } + if (updateZoneRulesetOptions.phase() != null) { + contentJson.addProperty("phase", updateZoneRulesetOptions.phase()); + } + if (updateZoneRulesetOptions.rules() != null) { + contentJson.add("rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneRulesetOptions.rules())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a zone ruleset. + * + * Delete a specific zone ruleset. + * + * @param deleteZoneRulesetOptions the {@link DeleteZoneRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteZoneRuleset(DeleteZoneRulesetOptions deleteZoneRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteZoneRulesetOptions, + "deleteZoneRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", deleteZoneRulesetOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteZoneRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List version of a zone ruleset. + * + * List all versions of a specific zone ruleset. + * + * @param getZoneRulesetVersionsOptions the {@link GetZoneRulesetVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getZoneRulesetVersions(GetZoneRulesetVersionsOptions getZoneRulesetVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneRulesetVersionsOptions, + "getZoneRulesetVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", getZoneRulesetVersionsOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneRulesetVersions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a specific version of a zone ruleset. + * + * View a specific version of a specific zone ruleset. + * + * @param getZoneRulesetVersionOptions the {@link GetZoneRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getZoneRulesetVersion(GetZoneRulesetVersionOptions getZoneRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneRulesetVersionOptions, + "getZoneRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", getZoneRulesetVersionOptions.rulesetId()); + pathParamsMap.put("ruleset_version", getZoneRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a specific version of a zone ruleset. + * + * Delete a specific version of a specific zone ruleset. + * + * @param deleteZoneRulesetVersionOptions the {@link DeleteZoneRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a void result + */ + public ServiceCall deleteZoneRulesetVersion(DeleteZoneRulesetVersionOptions deleteZoneRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteZoneRulesetVersionOptions, + "deleteZoneRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", deleteZoneRulesetVersionOptions.rulesetId()); + pathParamsMap.put("ruleset_version", deleteZoneRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteZoneRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a zone entrypoint ruleset. + * + * Get the zone ruleset for the given phase's entrypoint. + * + * @param getZoneEntrypointRulesetOptions the {@link GetZoneEntrypointRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getZoneEntrypointRuleset(GetZoneEntrypointRulesetOptions getZoneEntrypointRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneEntrypointRulesetOptions, + "getZoneEntrypointRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_phase", getZoneEntrypointRulesetOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/phases/{ruleset_phase}/entrypoint", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneEntrypointRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a zone entrypoint ruleset. + * + * Updates the instance ruleset for the given phase's entry point. + * + * @param updateZoneEntrypointRulesetOptions the {@link UpdateZoneEntrypointRulesetOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateZoneEntrypointRuleset(UpdateZoneEntrypointRulesetOptions updateZoneEntrypointRulesetOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateZoneEntrypointRulesetOptions, + "updateZoneEntrypointRulesetOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_phase", updateZoneEntrypointRulesetOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.put(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/phases/{ruleset_phase}/entrypoint", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateZoneEntrypointRuleset"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateZoneEntrypointRulesetOptions.description() != null) { + contentJson.addProperty("description", updateZoneEntrypointRulesetOptions.description()); + } + if (updateZoneEntrypointRulesetOptions.kind() != null) { + contentJson.addProperty("kind", updateZoneEntrypointRulesetOptions.kind()); + } + if (updateZoneEntrypointRulesetOptions.name() != null) { + contentJson.addProperty("name", updateZoneEntrypointRulesetOptions.name()); + } + if (updateZoneEntrypointRulesetOptions.phase() != null) { + contentJson.addProperty("phase", updateZoneEntrypointRulesetOptions.phase()); + } + if (updateZoneEntrypointRulesetOptions.rules() != null) { + contentJson.add("rules", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneEntrypointRulesetOptions.rules())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List a zone entry point ruleset's versions. + * + * Lists the zone ruleset versions for the given phase's entry point. + * + * @param getZoneEntryPointRulesetVersionsOptions the {@link GetZoneEntryPointRulesetVersionsOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link ListRulesetsResp} + */ + public ServiceCall getZoneEntryPointRulesetVersions(GetZoneEntryPointRulesetVersionsOptions getZoneEntryPointRulesetVersionsOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneEntryPointRulesetVersionsOptions, + "getZoneEntryPointRulesetVersionsOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_phase", getZoneEntryPointRulesetVersionsOptions.rulesetPhase()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/phases/{ruleset_phase}/entrypoint/versions", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneEntryPointRulesetVersions"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a zone entry point ruleset version. + * + * Fetches a specific version of a zone entry point ruleset. + * + * @param getZoneEntryPointRulesetVersionOptions the {@link GetZoneEntryPointRulesetVersionOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall getZoneEntryPointRulesetVersion(GetZoneEntryPointRulesetVersionOptions getZoneEntryPointRulesetVersionOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(getZoneEntryPointRulesetVersionOptions, + "getZoneEntryPointRulesetVersionOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_phase", getZoneEntryPointRulesetVersionOptions.rulesetPhase()); + pathParamsMap.put("ruleset_version", getZoneEntryPointRulesetVersionOptions.rulesetVersion()); + RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/phases/{ruleset_phase}/entrypoint/versions/{ruleset_version}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "getZoneEntryPointRulesetVersion"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create a zone ruleset rule. + * + * Create a zone ruleset rule. + * + * @param createZoneRulesetRuleOptions the {@link CreateZoneRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall createZoneRulesetRule(CreateZoneRulesetRuleOptions createZoneRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(createZoneRulesetRuleOptions, + "createZoneRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", createZoneRulesetRuleOptions.rulesetId()); + RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/rules", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "createZoneRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (createZoneRulesetRuleOptions.action() != null) { + contentJson.addProperty("action", createZoneRulesetRuleOptions.action()); + } + if (createZoneRulesetRuleOptions.actionParameters() != null) { + contentJson.add("action_parameters", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createZoneRulesetRuleOptions.actionParameters())); + } + if (createZoneRulesetRuleOptions.ratelimit() != null) { + contentJson.add("ratelimit", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createZoneRulesetRuleOptions.ratelimit())); + } + if (createZoneRulesetRuleOptions.description() != null) { + contentJson.addProperty("description", createZoneRulesetRuleOptions.description()); + } + if (createZoneRulesetRuleOptions.enabled() != null) { + contentJson.addProperty("enabled", createZoneRulesetRuleOptions.enabled()); + } + if (createZoneRulesetRuleOptions.expression() != null) { + contentJson.addProperty("expression", createZoneRulesetRuleOptions.expression()); + } + if (createZoneRulesetRuleOptions.id() != null) { + contentJson.addProperty("id", createZoneRulesetRuleOptions.id()); + } + if (createZoneRulesetRuleOptions.logging() != null) { + contentJson.add("logging", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createZoneRulesetRuleOptions.logging())); + } + if (createZoneRulesetRuleOptions.ref() != null) { + contentJson.addProperty("ref", createZoneRulesetRuleOptions.ref()); + } + if (createZoneRulesetRuleOptions.position() != null) { + contentJson.add("position", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(createZoneRulesetRuleOptions.position())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a zone ruleset rule. + * + * Update a zone ruleset rule. + * + * @param updateZoneRulesetRuleOptions the {@link UpdateZoneRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RulesetResp} + */ + public ServiceCall updateZoneRulesetRule(UpdateZoneRulesetRuleOptions updateZoneRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(updateZoneRulesetRuleOptions, + "updateZoneRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", updateZoneRulesetRuleOptions.rulesetId()); + pathParamsMap.put("rule_id", updateZoneRulesetRuleOptions.ruleId()); + RequestBuilder builder = RequestBuilder.patch(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/rules/{rule_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "updateZoneRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + if (updateZoneRulesetRuleOptions.action() != null) { + contentJson.addProperty("action", updateZoneRulesetRuleOptions.action()); + } + if (updateZoneRulesetRuleOptions.actionParameters() != null) { + contentJson.add("action_parameters", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneRulesetRuleOptions.actionParameters())); + } + if (updateZoneRulesetRuleOptions.ratelimit() != null) { + contentJson.add("ratelimit", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneRulesetRuleOptions.ratelimit())); + } + if (updateZoneRulesetRuleOptions.description() != null) { + contentJson.addProperty("description", updateZoneRulesetRuleOptions.description()); + } + if (updateZoneRulesetRuleOptions.enabled() != null) { + contentJson.addProperty("enabled", updateZoneRulesetRuleOptions.enabled()); + } + if (updateZoneRulesetRuleOptions.expression() != null) { + contentJson.addProperty("expression", updateZoneRulesetRuleOptions.expression()); + } + if (updateZoneRulesetRuleOptions.id() != null) { + contentJson.addProperty("id", updateZoneRulesetRuleOptions.id()); + } + if (updateZoneRulesetRuleOptions.logging() != null) { + contentJson.add("logging", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneRulesetRuleOptions.logging())); + } + if (updateZoneRulesetRuleOptions.ref() != null) { + contentJson.addProperty("ref", updateZoneRulesetRuleOptions.ref()); + } + if (updateZoneRulesetRuleOptions.position() != null) { + contentJson.add("position", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson().toJsonTree(updateZoneRulesetRuleOptions.position())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a zone ruleset rule. + * + * Delete an instance ruleset rule. + * + * @param deleteZoneRulesetRuleOptions the {@link DeleteZoneRulesetRuleOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link RuleResp} + */ + public ServiceCall deleteZoneRulesetRule(DeleteZoneRulesetRuleOptions deleteZoneRulesetRuleOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(deleteZoneRulesetRuleOptions, + "deleteZoneRulesetRuleOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("crn", this.crn); + pathParamsMap.put("zone_identifier", this.zoneIdentifier); + pathParamsMap.put("ruleset_id", deleteZoneRulesetRuleOptions.rulesetId()); + pathParamsMap.put("rule_id", deleteZoneRulesetRuleOptions.ruleId()); + RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/{crn}/zones/{zone_identifier}/rulesets/{ruleset_id}/rules/{rule_id}", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("rulesets", "v1", "deleteZoneRulesetRule"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken() { }.getType()); + return createServiceCall(builder.build(), responseConverter); + } + +} diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParameters.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParameters.java new file mode 100644 index 000000000..175bb2eab --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParameters.java @@ -0,0 +1,325 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * ActionParameters. + */ +public class ActionParameters extends GenericModel { + + protected String id; + protected Overrides overrides; + protected String version; + protected String ruleset; + protected List rulesets; + protected List phases; + protected List products; + protected ActionParametersResponse response; + + /** + * Builder. + */ + public static class Builder { + private String id; + private Overrides overrides; + private String version; + private String ruleset; + private List rulesets; + private List phases; + private List products; + private ActionParametersResponse response; + + /** + * Instantiates a new Builder from an existing ActionParameters instance. + * + * @param actionParameters the instance to initialize the Builder with + */ + private Builder(ActionParameters actionParameters) { + this.id = actionParameters.id; + this.overrides = actionParameters.overrides; + this.version = actionParameters.version; + this.ruleset = actionParameters.ruleset; + this.rulesets = actionParameters.rulesets; + this.phases = actionParameters.phases; + this.products = actionParameters.products; + this.response = actionParameters.response; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a ActionParameters. + * + * @return the new ActionParameters instance + */ + public ActionParameters build() { + return new ActionParameters(this); + } + + /** + * Adds a new element to rulesets. + * + * @param rulesets the new element to be added + * @return the ActionParameters builder + */ + public Builder addRulesets(String rulesets) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rulesets, + "rulesets cannot be null"); + if (this.rulesets == null) { + this.rulesets = new ArrayList(); + } + this.rulesets.add(rulesets); + return this; + } + + /** + * Adds a new element to phases. + * + * @param phases the new element to be added + * @return the ActionParameters builder + */ + public Builder addPhases(String phases) { + com.ibm.cloud.sdk.core.util.Validator.notNull(phases, + "phases cannot be null"); + if (this.phases == null) { + this.phases = new ArrayList(); + } + this.phases.add(phases); + return this; + } + + /** + * Adds a new element to products. + * + * @param products the new element to be added + * @return the ActionParameters builder + */ + public Builder addProducts(String products) { + com.ibm.cloud.sdk.core.util.Validator.notNull(products, + "products cannot be null"); + if (this.products == null) { + this.products = new ArrayList(); + } + this.products.add(products); + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the ActionParameters builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the overrides. + * + * @param overrides the overrides + * @return the ActionParameters builder + */ + public Builder overrides(Overrides overrides) { + this.overrides = overrides; + return this; + } + + /** + * Set the version. + * + * @param version the version + * @return the ActionParameters builder + */ + public Builder version(String version) { + this.version = version; + return this; + } + + /** + * Set the ruleset. + * + * @param ruleset the ruleset + * @return the ActionParameters builder + */ + public Builder ruleset(String ruleset) { + this.ruleset = ruleset; + return this; + } + + /** + * Set the rulesets. + * Existing rulesets will be replaced. + * + * @param rulesets the rulesets + * @return the ActionParameters builder + */ + public Builder rulesets(List rulesets) { + this.rulesets = rulesets; + return this; + } + + /** + * Set the phases. + * Existing phases will be replaced. + * + * @param phases the phases + * @return the ActionParameters builder + */ + public Builder phases(List phases) { + this.phases = phases; + return this; + } + + /** + * Set the products. + * Existing products will be replaced. + * + * @param products the products + * @return the ActionParameters builder + */ + public Builder products(List products) { + this.products = products; + return this; + } + + /** + * Set the response. + * + * @param response the response + * @return the ActionParameters builder + */ + public Builder response(ActionParametersResponse response) { + this.response = response; + return this; + } + } + + protected ActionParameters() { } + + protected ActionParameters(Builder builder) { + id = builder.id; + overrides = builder.overrides; + version = builder.version; + ruleset = builder.ruleset; + rulesets = builder.rulesets; + phases = builder.phases; + products = builder.products; + response = builder.response; + } + + /** + * New builder. + * + * @return a ActionParameters builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * unique ID of the ruleset. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the overrides. + * + * @return the overrides + */ + public Overrides overrides() { + return overrides; + } + + /** + * Gets the version. + * + * The version of the ruleset. Use "latest" to get the latest version. + * + * @return the version + */ + public String version() { + return version; + } + + /** + * Gets the ruleset. + * + * Ruleset ID of the ruleset to apply action to. Use "current" to apply to the current ruleset. + * + * @return the ruleset + */ + public String ruleset() { + return ruleset; + } + + /** + * Gets the rulesets. + * + * List of ruleset ids to apply action to. Use "current" to apply to the current ruleset. + * + * @return the rulesets + */ + public List rulesets() { + return rulesets; + } + + /** + * Gets the phases. + * + * Skips the execution of one or more phases. + * + * @return the phases + */ + public List phases() { + return phases; + } + + /** + * Gets the products. + * + * Skips specific security products that are not based on the Ruleset Engine. + * + * @return the products + */ + public List products() { + return products; + } + + /** + * Gets the response. + * + * @return the response + */ + public ActionParametersResponse response() { + return response; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponse.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponse.java new file mode 100644 index 000000000..9620108b0 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponse.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * ActionParametersResponse. + */ +public class ActionParametersResponse extends GenericModel { + + protected String content; + @SerializedName("content_type") + protected String contentType; + @SerializedName("status_code") + protected Long statusCode; + + /** + * Builder. + */ + public static class Builder { + private String content; + private String contentType; + private Long statusCode; + + /** + * Instantiates a new Builder from an existing ActionParametersResponse instance. + * + * @param actionParametersResponse the instance to initialize the Builder with + */ + private Builder(ActionParametersResponse actionParametersResponse) { + this.content = actionParametersResponse.content; + this.contentType = actionParametersResponse.contentType; + this.statusCode = actionParametersResponse.statusCode; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param content the content + * @param contentType the contentType + * @param statusCode the statusCode + */ + public Builder(String content, String contentType, Long statusCode) { + this.content = content; + this.contentType = contentType; + this.statusCode = statusCode; + } + + /** + * Builds a ActionParametersResponse. + * + * @return the new ActionParametersResponse instance + */ + public ActionParametersResponse build() { + return new ActionParametersResponse(this); + } + + /** + * Set the content. + * + * @param content the content + * @return the ActionParametersResponse builder + */ + public Builder content(String content) { + this.content = content; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the ActionParametersResponse builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the statusCode. + * + * @param statusCode the statusCode + * @return the ActionParametersResponse builder + */ + public Builder statusCode(long statusCode) { + this.statusCode = statusCode; + return this; + } + } + + protected ActionParametersResponse() { } + + protected ActionParametersResponse(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.content, + "content cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.contentType, + "contentType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.statusCode, + "statusCode cannot be null"); + content = builder.content; + contentType = builder.contentType; + statusCode = builder.statusCode; + } + + /** + * New builder. + * + * @return a ActionParametersResponse builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the content. + * + * the content to return. + * + * @return the content + */ + public String content() { + return content; + } + + /** + * Gets the contentType. + * + * @return the contentType + */ + public String contentType() { + return contentType; + } + + /** + * Gets the statusCode. + * + * The status code to return. + * + * @return the statusCode + */ + public Long statusCode() { + return statusCode; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverride.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverride.java new file mode 100644 index 000000000..2aa7e6763 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverride.java @@ -0,0 +1,143 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * CategoriesOverride. + */ +public class CategoriesOverride extends GenericModel { + + protected String category; + protected Boolean enabled; + protected String action; + + /** + * Builder. + */ + public static class Builder { + private String category; + private Boolean enabled; + private String action; + + /** + * Instantiates a new Builder from an existing CategoriesOverride instance. + * + * @param categoriesOverride the instance to initialize the Builder with + */ + private Builder(CategoriesOverride categoriesOverride) { + this.category = categoriesOverride.category; + this.enabled = categoriesOverride.enabled; + this.action = categoriesOverride.action; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a CategoriesOverride. + * + * @return the new CategoriesOverride instance + */ + public CategoriesOverride build() { + return new CategoriesOverride(this); + } + + /** + * Set the category. + * + * @param category the category + * @return the CategoriesOverride builder + */ + public Builder category(String category) { + this.category = category; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the CategoriesOverride builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the CategoriesOverride builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + } + + protected CategoriesOverride() { } + + protected CategoriesOverride(Builder builder) { + category = builder.category; + enabled = builder.enabled; + action = builder.action; + } + + /** + * New builder. + * + * @return a CategoriesOverride builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the category. + * + * The category tag name to override. + * + * @return the category + */ + public String category() { + return category; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptions.java new file mode 100644 index 000000000..a2d0b1d4f --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptions.java @@ -0,0 +1,350 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createInstanceRulesetRule options. + */ +public class CreateInstanceRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String action; + protected ActionParameters actionParameters; + protected Ratelimit ratelimit; + protected String description; + protected Boolean enabled; + protected String expression; + protected String id; + protected Logging logging; + protected String ref; + protected Position position; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String action; + private ActionParameters actionParameters; + private Ratelimit ratelimit; + private String description; + private Boolean enabled; + private String expression; + private String id; + private Logging logging; + private String ref; + private Position position; + + /** + * Instantiates a new Builder from an existing CreateInstanceRulesetRuleOptions instance. + * + * @param createInstanceRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(CreateInstanceRulesetRuleOptions createInstanceRulesetRuleOptions) { + this.rulesetId = createInstanceRulesetRuleOptions.rulesetId; + this.action = createInstanceRulesetRuleOptions.action; + this.actionParameters = createInstanceRulesetRuleOptions.actionParameters; + this.ratelimit = createInstanceRulesetRuleOptions.ratelimit; + this.description = createInstanceRulesetRuleOptions.description; + this.enabled = createInstanceRulesetRuleOptions.enabled; + this.expression = createInstanceRulesetRuleOptions.expression; + this.id = createInstanceRulesetRuleOptions.id; + this.logging = createInstanceRulesetRuleOptions.logging; + this.ref = createInstanceRulesetRuleOptions.ref; + this.position = createInstanceRulesetRuleOptions.position; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a CreateInstanceRulesetRuleOptions. + * + * @return the new CreateInstanceRulesetRuleOptions instance + */ + public CreateInstanceRulesetRuleOptions build() { + return new CreateInstanceRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the actionParameters. + * + * @param actionParameters the actionParameters + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder actionParameters(ActionParameters actionParameters) { + this.actionParameters = actionParameters; + return this; + } + + /** + * Set the ratelimit. + * + * @param ratelimit the ratelimit + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder ratelimit(Ratelimit ratelimit) { + this.ratelimit = ratelimit; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the expression. + * + * @param expression the expression + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the logging. + * + * @param logging the logging + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder logging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Set the ref. + * + * @param ref the ref + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder ref(String ref) { + this.ref = ref; + return this; + } + + /** + * Set the position. + * + * @param position the position + * @return the CreateInstanceRulesetRuleOptions builder + */ + public Builder position(Position position) { + this.position = position; + return this; + } + } + + protected CreateInstanceRulesetRuleOptions() { } + + protected CreateInstanceRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + action = builder.action; + actionParameters = builder.actionParameters; + ratelimit = builder.ratelimit; + description = builder.description; + enabled = builder.enabled; + expression = builder.expression; + id = builder.id; + logging = builder.logging; + ref = builder.ref; + position = builder.position; + } + + /** + * New builder. + * + * @return a CreateInstanceRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters actionParameters() { + return actionParameters; + } + + /** + * Gets the ratelimit. + * + * @return the ratelimit + */ + public Ratelimit ratelimit() { + return ratelimit; + } + + /** + * Gets the description. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String expression() { + return expression; + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging logging() { + return logging; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String ref() { + return ref; + } + + /** + * Gets the position. + * + * @return the position + */ + public Position position() { + return position; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptions.java new file mode 100644 index 000000000..43312527d --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptions.java @@ -0,0 +1,350 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The createZoneRulesetRule options. + */ +public class CreateZoneRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String action; + protected ActionParameters actionParameters; + protected Ratelimit ratelimit; + protected String description; + protected Boolean enabled; + protected String expression; + protected String id; + protected Logging logging; + protected String ref; + protected Position position; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String action; + private ActionParameters actionParameters; + private Ratelimit ratelimit; + private String description; + private Boolean enabled; + private String expression; + private String id; + private Logging logging; + private String ref; + private Position position; + + /** + * Instantiates a new Builder from an existing CreateZoneRulesetRuleOptions instance. + * + * @param createZoneRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(CreateZoneRulesetRuleOptions createZoneRulesetRuleOptions) { + this.rulesetId = createZoneRulesetRuleOptions.rulesetId; + this.action = createZoneRulesetRuleOptions.action; + this.actionParameters = createZoneRulesetRuleOptions.actionParameters; + this.ratelimit = createZoneRulesetRuleOptions.ratelimit; + this.description = createZoneRulesetRuleOptions.description; + this.enabled = createZoneRulesetRuleOptions.enabled; + this.expression = createZoneRulesetRuleOptions.expression; + this.id = createZoneRulesetRuleOptions.id; + this.logging = createZoneRulesetRuleOptions.logging; + this.ref = createZoneRulesetRuleOptions.ref; + this.position = createZoneRulesetRuleOptions.position; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a CreateZoneRulesetRuleOptions. + * + * @return the new CreateZoneRulesetRuleOptions instance + */ + public CreateZoneRulesetRuleOptions build() { + return new CreateZoneRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the actionParameters. + * + * @param actionParameters the actionParameters + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder actionParameters(ActionParameters actionParameters) { + this.actionParameters = actionParameters; + return this; + } + + /** + * Set the ratelimit. + * + * @param ratelimit the ratelimit + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder ratelimit(Ratelimit ratelimit) { + this.ratelimit = ratelimit; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the expression. + * + * @param expression the expression + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the logging. + * + * @param logging the logging + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder logging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Set the ref. + * + * @param ref the ref + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder ref(String ref) { + this.ref = ref; + return this; + } + + /** + * Set the position. + * + * @param position the position + * @return the CreateZoneRulesetRuleOptions builder + */ + public Builder position(Position position) { + this.position = position; + return this; + } + } + + protected CreateZoneRulesetRuleOptions() { } + + protected CreateZoneRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + action = builder.action; + actionParameters = builder.actionParameters; + ratelimit = builder.ratelimit; + description = builder.description; + enabled = builder.enabled; + expression = builder.expression; + id = builder.id; + logging = builder.logging; + ref = builder.ref; + position = builder.position; + } + + /** + * New builder. + * + * @return a CreateZoneRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters actionParameters() { + return actionParameters; + } + + /** + * Gets the ratelimit. + * + * @return the ratelimit + */ + public Ratelimit ratelimit() { + return ratelimit; + } + + /** + * Gets the description. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String expression() { + return expression; + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging logging() { + return logging; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String ref() { + return ref; + } + + /** + * Gets the position. + * + * @return the position + */ + public Position position() { + return position; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptions.java new file mode 100644 index 000000000..cee100736 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteInstanceRuleset options. + */ +public class DeleteInstanceRulesetOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing DeleteInstanceRulesetOptions instance. + * + * @param deleteInstanceRulesetOptions the instance to initialize the Builder with + */ + private Builder(DeleteInstanceRulesetOptions deleteInstanceRulesetOptions) { + this.rulesetId = deleteInstanceRulesetOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a DeleteInstanceRulesetOptions. + * + * @return the new DeleteInstanceRulesetOptions instance + */ + public DeleteInstanceRulesetOptions build() { + return new DeleteInstanceRulesetOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteInstanceRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected DeleteInstanceRulesetOptions() { } + + protected DeleteInstanceRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a DeleteInstanceRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptions.java new file mode 100644 index 000000000..bbda212d2 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteInstanceRulesetRule options. + */ +public class DeleteInstanceRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String ruleId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String ruleId; + + /** + * Instantiates a new Builder from an existing DeleteInstanceRulesetRuleOptions instance. + * + * @param deleteInstanceRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(DeleteInstanceRulesetRuleOptions deleteInstanceRulesetRuleOptions) { + this.rulesetId = deleteInstanceRulesetRuleOptions.rulesetId; + this.ruleId = deleteInstanceRulesetRuleOptions.ruleId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param ruleId the ruleId + */ + public Builder(String rulesetId, String ruleId) { + this.rulesetId = rulesetId; + this.ruleId = ruleId; + } + + /** + * Builds a DeleteInstanceRulesetRuleOptions. + * + * @return the new DeleteInstanceRulesetRuleOptions instance + */ + public DeleteInstanceRulesetRuleOptions build() { + return new DeleteInstanceRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteInstanceRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the ruleId. + * + * @param ruleId the ruleId + * @return the DeleteInstanceRulesetRuleOptions builder + */ + public Builder ruleId(String ruleId) { + this.ruleId = ruleId; + return this; + } + } + + protected DeleteInstanceRulesetRuleOptions() { } + + protected DeleteInstanceRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.ruleId, + "ruleId cannot be empty"); + rulesetId = builder.rulesetId; + ruleId = builder.ruleId; + } + + /** + * New builder. + * + * @return a DeleteInstanceRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the ruleId. + * + * ID of a specific rule. + * + * @return the ruleId + */ + public String ruleId() { + return ruleId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptions.java new file mode 100644 index 000000000..16bbace86 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteInstanceRulesetVersion options. + */ +public class DeleteInstanceRulesetVersionOptions extends GenericModel { + + protected String rulesetId; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing DeleteInstanceRulesetVersionOptions instance. + * + * @param deleteInstanceRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(DeleteInstanceRulesetVersionOptions deleteInstanceRulesetVersionOptions) { + this.rulesetId = deleteInstanceRulesetVersionOptions.rulesetId; + this.rulesetVersion = deleteInstanceRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetId, String rulesetVersion) { + this.rulesetId = rulesetId; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a DeleteInstanceRulesetVersionOptions. + * + * @return the new DeleteInstanceRulesetVersionOptions instance + */ + public DeleteInstanceRulesetVersionOptions build() { + return new DeleteInstanceRulesetVersionOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteInstanceRulesetVersionOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the DeleteInstanceRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected DeleteInstanceRulesetVersionOptions() { } + + protected DeleteInstanceRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetId = builder.rulesetId; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a DeleteInstanceRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptions.java new file mode 100644 index 000000000..f645710f3 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteZoneRuleset options. + */ +public class DeleteZoneRulesetOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing DeleteZoneRulesetOptions instance. + * + * @param deleteZoneRulesetOptions the instance to initialize the Builder with + */ + private Builder(DeleteZoneRulesetOptions deleteZoneRulesetOptions) { + this.rulesetId = deleteZoneRulesetOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a DeleteZoneRulesetOptions. + * + * @return the new DeleteZoneRulesetOptions instance + */ + public DeleteZoneRulesetOptions build() { + return new DeleteZoneRulesetOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteZoneRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected DeleteZoneRulesetOptions() { } + + protected DeleteZoneRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a DeleteZoneRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptions.java new file mode 100644 index 000000000..af7e82a7c --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteZoneRulesetRule options. + */ +public class DeleteZoneRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String ruleId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String ruleId; + + /** + * Instantiates a new Builder from an existing DeleteZoneRulesetRuleOptions instance. + * + * @param deleteZoneRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(DeleteZoneRulesetRuleOptions deleteZoneRulesetRuleOptions) { + this.rulesetId = deleteZoneRulesetRuleOptions.rulesetId; + this.ruleId = deleteZoneRulesetRuleOptions.ruleId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param ruleId the ruleId + */ + public Builder(String rulesetId, String ruleId) { + this.rulesetId = rulesetId; + this.ruleId = ruleId; + } + + /** + * Builds a DeleteZoneRulesetRuleOptions. + * + * @return the new DeleteZoneRulesetRuleOptions instance + */ + public DeleteZoneRulesetRuleOptions build() { + return new DeleteZoneRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteZoneRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the ruleId. + * + * @param ruleId the ruleId + * @return the DeleteZoneRulesetRuleOptions builder + */ + public Builder ruleId(String ruleId) { + this.ruleId = ruleId; + return this; + } + } + + protected DeleteZoneRulesetRuleOptions() { } + + protected DeleteZoneRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.ruleId, + "ruleId cannot be empty"); + rulesetId = builder.rulesetId; + ruleId = builder.ruleId; + } + + /** + * New builder. + * + * @return a DeleteZoneRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the ruleId. + * + * ID of a specific rule. + * + * @return the ruleId + */ + public String ruleId() { + return ruleId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptions.java new file mode 100644 index 000000000..3ec1aacf7 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The deleteZoneRulesetVersion options. + */ +public class DeleteZoneRulesetVersionOptions extends GenericModel { + + protected String rulesetId; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing DeleteZoneRulesetVersionOptions instance. + * + * @param deleteZoneRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(DeleteZoneRulesetVersionOptions deleteZoneRulesetVersionOptions) { + this.rulesetId = deleteZoneRulesetVersionOptions.rulesetId; + this.rulesetVersion = deleteZoneRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetId, String rulesetVersion) { + this.rulesetId = rulesetId; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a DeleteZoneRulesetVersionOptions. + * + * @return the new DeleteZoneRulesetVersionOptions instance + */ + public DeleteZoneRulesetVersionOptions build() { + return new DeleteZoneRulesetVersionOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the DeleteZoneRulesetVersionOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the DeleteZoneRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected DeleteZoneRulesetVersionOptions() { } + + protected DeleteZoneRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetId = builder.rulesetId; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a DeleteZoneRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptions.java new file mode 100644 index 000000000..557bf2772 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptions.java @@ -0,0 +1,180 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceEntryPointRulesetVersion options. + */ +public class GetInstanceEntryPointRulesetVersionOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing GetInstanceEntryPointRulesetVersionOptions instance. + * + * @param getInstanceEntryPointRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceEntryPointRulesetVersionOptions getInstanceEntryPointRulesetVersionOptions) { + this.rulesetPhase = getInstanceEntryPointRulesetVersionOptions.rulesetPhase; + this.rulesetVersion = getInstanceEntryPointRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetPhase, String rulesetVersion) { + this.rulesetPhase = rulesetPhase; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a GetInstanceEntryPointRulesetVersionOptions. + * + * @return the new GetInstanceEntryPointRulesetVersionOptions instance + */ + public GetInstanceEntryPointRulesetVersionOptions build() { + return new GetInstanceEntryPointRulesetVersionOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetInstanceEntryPointRulesetVersionOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the GetInstanceEntryPointRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected GetInstanceEntryPointRulesetVersionOptions() { } + + protected GetInstanceEntryPointRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetPhase = builder.rulesetPhase; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a GetInstanceEntryPointRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptions.java new file mode 100644 index 000000000..0e422744f --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptions.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceEntryPointRulesetVersions options. + */ +public class GetInstanceEntryPointRulesetVersionsOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + + /** + * Instantiates a new Builder from an existing GetInstanceEntryPointRulesetVersionsOptions instance. + * + * @param getInstanceEntryPointRulesetVersionsOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceEntryPointRulesetVersionsOptions getInstanceEntryPointRulesetVersionsOptions) { + this.rulesetPhase = getInstanceEntryPointRulesetVersionsOptions.rulesetPhase; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a GetInstanceEntryPointRulesetVersionsOptions. + * + * @return the new GetInstanceEntryPointRulesetVersionsOptions instance + */ + public GetInstanceEntryPointRulesetVersionsOptions build() { + return new GetInstanceEntryPointRulesetVersionsOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetInstanceEntryPointRulesetVersionsOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + } + + protected GetInstanceEntryPointRulesetVersionsOptions() { } + + protected GetInstanceEntryPointRulesetVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + } + + /** + * New builder. + * + * @return a GetInstanceEntryPointRulesetVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptions.java new file mode 100644 index 000000000..4d95466af --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptions.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceEntrypointRuleset options. + */ +public class GetInstanceEntrypointRulesetOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + + /** + * Instantiates a new Builder from an existing GetInstanceEntrypointRulesetOptions instance. + * + * @param getInstanceEntrypointRulesetOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceEntrypointRulesetOptions getInstanceEntrypointRulesetOptions) { + this.rulesetPhase = getInstanceEntrypointRulesetOptions.rulesetPhase; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a GetInstanceEntrypointRulesetOptions. + * + * @return the new GetInstanceEntrypointRulesetOptions instance + */ + public GetInstanceEntrypointRulesetOptions build() { + return new GetInstanceEntrypointRulesetOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetInstanceEntrypointRulesetOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + } + + protected GetInstanceEntrypointRulesetOptions() { } + + protected GetInstanceEntrypointRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + } + + /** + * New builder. + * + * @return a GetInstanceEntrypointRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptions.java new file mode 100644 index 000000000..510c419a6 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceRuleset options. + */ +public class GetInstanceRulesetOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing GetInstanceRulesetOptions instance. + * + * @param getInstanceRulesetOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceRulesetOptions getInstanceRulesetOptions) { + this.rulesetId = getInstanceRulesetOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a GetInstanceRulesetOptions. + * + * @return the new GetInstanceRulesetOptions instance + */ + public GetInstanceRulesetOptions build() { + return new GetInstanceRulesetOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetInstanceRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected GetInstanceRulesetOptions() { } + + protected GetInstanceRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a GetInstanceRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptions.java new file mode 100644 index 000000000..d31792caa --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptions.java @@ -0,0 +1,164 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceRulesetVersionByTag options. + */ +public class GetInstanceRulesetVersionByTagOptions extends GenericModel { + + protected String rulesetId; + protected String rulesetVersion; + protected String ruleTag; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String rulesetVersion; + private String ruleTag; + + /** + * Instantiates a new Builder from an existing GetInstanceRulesetVersionByTagOptions instance. + * + * @param getInstanceRulesetVersionByTagOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceRulesetVersionByTagOptions getInstanceRulesetVersionByTagOptions) { + this.rulesetId = getInstanceRulesetVersionByTagOptions.rulesetId; + this.rulesetVersion = getInstanceRulesetVersionByTagOptions.rulesetVersion; + this.ruleTag = getInstanceRulesetVersionByTagOptions.ruleTag; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param rulesetVersion the rulesetVersion + * @param ruleTag the ruleTag + */ + public Builder(String rulesetId, String rulesetVersion, String ruleTag) { + this.rulesetId = rulesetId; + this.rulesetVersion = rulesetVersion; + this.ruleTag = ruleTag; + } + + /** + * Builds a GetInstanceRulesetVersionByTagOptions. + * + * @return the new GetInstanceRulesetVersionByTagOptions instance + */ + public GetInstanceRulesetVersionByTagOptions build() { + return new GetInstanceRulesetVersionByTagOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetInstanceRulesetVersionByTagOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the GetInstanceRulesetVersionByTagOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + + /** + * Set the ruleTag. + * + * @param ruleTag the ruleTag + * @return the GetInstanceRulesetVersionByTagOptions builder + */ + public Builder ruleTag(String ruleTag) { + this.ruleTag = ruleTag; + return this; + } + } + + protected GetInstanceRulesetVersionByTagOptions() { } + + protected GetInstanceRulesetVersionByTagOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.ruleTag, + "ruleTag cannot be empty"); + rulesetId = builder.rulesetId; + rulesetVersion = builder.rulesetVersion; + ruleTag = builder.ruleTag; + } + + /** + * New builder. + * + * @return a GetInstanceRulesetVersionByTagOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } + + /** + * Gets the ruleTag. + * + * A category of the rule. + * + * @return the ruleTag + */ + public String ruleTag() { + return ruleTag; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptions.java new file mode 100644 index 000000000..853e3813a --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceRulesetVersion options. + */ +public class GetInstanceRulesetVersionOptions extends GenericModel { + + protected String rulesetId; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing GetInstanceRulesetVersionOptions instance. + * + * @param getInstanceRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceRulesetVersionOptions getInstanceRulesetVersionOptions) { + this.rulesetId = getInstanceRulesetVersionOptions.rulesetId; + this.rulesetVersion = getInstanceRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetId, String rulesetVersion) { + this.rulesetId = rulesetId; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a GetInstanceRulesetVersionOptions. + * + * @return the new GetInstanceRulesetVersionOptions instance + */ + public GetInstanceRulesetVersionOptions build() { + return new GetInstanceRulesetVersionOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetInstanceRulesetVersionOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the GetInstanceRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected GetInstanceRulesetVersionOptions() { } + + protected GetInstanceRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetId = builder.rulesetId; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a GetInstanceRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptions.java new file mode 100644 index 000000000..7081b3ed4 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceRulesetVersions options. + */ +public class GetInstanceRulesetVersionsOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing GetInstanceRulesetVersionsOptions instance. + * + * @param getInstanceRulesetVersionsOptions the instance to initialize the Builder with + */ + private Builder(GetInstanceRulesetVersionsOptions getInstanceRulesetVersionsOptions) { + this.rulesetId = getInstanceRulesetVersionsOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a GetInstanceRulesetVersionsOptions. + * + * @return the new GetInstanceRulesetVersionsOptions instance + */ + public GetInstanceRulesetVersionsOptions build() { + return new GetInstanceRulesetVersionsOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetInstanceRulesetVersionsOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected GetInstanceRulesetVersionsOptions() { } + + protected GetInstanceRulesetVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a GetInstanceRulesetVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptions.java new file mode 100644 index 000000000..52fc2d401 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptions.java @@ -0,0 +1,29 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getInstanceRulesets options. + */ +public class GetInstanceRulesetsOptions extends GenericModel { + + /** + * Construct a new instance of GetInstanceRulesetsOptions. + */ + public GetInstanceRulesetsOptions() { + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptions.java new file mode 100644 index 000000000..eec09ab07 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptions.java @@ -0,0 +1,180 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneEntryPointRulesetVersion options. + */ +public class GetZoneEntryPointRulesetVersionOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing GetZoneEntryPointRulesetVersionOptions instance. + * + * @param getZoneEntryPointRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(GetZoneEntryPointRulesetVersionOptions getZoneEntryPointRulesetVersionOptions) { + this.rulesetPhase = getZoneEntryPointRulesetVersionOptions.rulesetPhase; + this.rulesetVersion = getZoneEntryPointRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetPhase, String rulesetVersion) { + this.rulesetPhase = rulesetPhase; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a GetZoneEntryPointRulesetVersionOptions. + * + * @return the new GetZoneEntryPointRulesetVersionOptions instance + */ + public GetZoneEntryPointRulesetVersionOptions build() { + return new GetZoneEntryPointRulesetVersionOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetZoneEntryPointRulesetVersionOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the GetZoneEntryPointRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected GetZoneEntryPointRulesetVersionOptions() { } + + protected GetZoneEntryPointRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetPhase = builder.rulesetPhase; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a GetZoneEntryPointRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptions.java new file mode 100644 index 000000000..c9dc6314f --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptions.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneEntryPointRulesetVersions options. + */ +public class GetZoneEntryPointRulesetVersionsOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + + /** + * Instantiates a new Builder from an existing GetZoneEntryPointRulesetVersionsOptions instance. + * + * @param getZoneEntryPointRulesetVersionsOptions the instance to initialize the Builder with + */ + private Builder(GetZoneEntryPointRulesetVersionsOptions getZoneEntryPointRulesetVersionsOptions) { + this.rulesetPhase = getZoneEntryPointRulesetVersionsOptions.rulesetPhase; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a GetZoneEntryPointRulesetVersionsOptions. + * + * @return the new GetZoneEntryPointRulesetVersionsOptions instance + */ + public GetZoneEntryPointRulesetVersionsOptions build() { + return new GetZoneEntryPointRulesetVersionsOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetZoneEntryPointRulesetVersionsOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + } + + protected GetZoneEntryPointRulesetVersionsOptions() { } + + protected GetZoneEntryPointRulesetVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + } + + /** + * New builder. + * + * @return a GetZoneEntryPointRulesetVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptions.java new file mode 100644 index 000000000..11a0fbd15 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptions.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneEntrypointRuleset options. + */ +public class GetZoneEntrypointRulesetOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + + /** + * Instantiates a new Builder from an existing GetZoneEntrypointRulesetOptions instance. + * + * @param getZoneEntrypointRulesetOptions the instance to initialize the Builder with + */ + private Builder(GetZoneEntrypointRulesetOptions getZoneEntrypointRulesetOptions) { + this.rulesetPhase = getZoneEntrypointRulesetOptions.rulesetPhase; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a GetZoneEntrypointRulesetOptions. + * + * @return the new GetZoneEntrypointRulesetOptions instance + */ + public GetZoneEntrypointRulesetOptions build() { + return new GetZoneEntrypointRulesetOptions(this); + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the GetZoneEntrypointRulesetOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + } + + protected GetZoneEntrypointRulesetOptions() { } + + protected GetZoneEntrypointRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + } + + /** + * New builder. + * + * @return a GetZoneEntrypointRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptions.java new file mode 100644 index 000000000..e7ba6d3d9 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneRuleset options. + */ +public class GetZoneRulesetOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing GetZoneRulesetOptions instance. + * + * @param getZoneRulesetOptions the instance to initialize the Builder with + */ + private Builder(GetZoneRulesetOptions getZoneRulesetOptions) { + this.rulesetId = getZoneRulesetOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a GetZoneRulesetOptions. + * + * @return the new GetZoneRulesetOptions instance + */ + public GetZoneRulesetOptions build() { + return new GetZoneRulesetOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetZoneRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected GetZoneRulesetOptions() { } + + protected GetZoneRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a GetZoneRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptions.java new file mode 100644 index 000000000..b4c1da3c8 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptions.java @@ -0,0 +1,134 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneRulesetVersion options. + */ +public class GetZoneRulesetVersionOptions extends GenericModel { + + protected String rulesetId; + protected String rulesetVersion; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String rulesetVersion; + + /** + * Instantiates a new Builder from an existing GetZoneRulesetVersionOptions instance. + * + * @param getZoneRulesetVersionOptions the instance to initialize the Builder with + */ + private Builder(GetZoneRulesetVersionOptions getZoneRulesetVersionOptions) { + this.rulesetId = getZoneRulesetVersionOptions.rulesetId; + this.rulesetVersion = getZoneRulesetVersionOptions.rulesetVersion; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param rulesetVersion the rulesetVersion + */ + public Builder(String rulesetId, String rulesetVersion) { + this.rulesetId = rulesetId; + this.rulesetVersion = rulesetVersion; + } + + /** + * Builds a GetZoneRulesetVersionOptions. + * + * @return the new GetZoneRulesetVersionOptions instance + */ + public GetZoneRulesetVersionOptions build() { + return new GetZoneRulesetVersionOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetZoneRulesetVersionOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the rulesetVersion. + * + * @param rulesetVersion the rulesetVersion + * @return the GetZoneRulesetVersionOptions builder + */ + public Builder rulesetVersion(String rulesetVersion) { + this.rulesetVersion = rulesetVersion; + return this; + } + } + + protected GetZoneRulesetVersionOptions() { } + + protected GetZoneRulesetVersionOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetVersion, + "rulesetVersion cannot be empty"); + rulesetId = builder.rulesetId; + rulesetVersion = builder.rulesetVersion; + } + + /** + * New builder. + * + * @return a GetZoneRulesetVersionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the rulesetVersion. + * + * The version of the ruleset. + * + * @return the rulesetVersion + */ + public String rulesetVersion() { + return rulesetVersion; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptions.java new file mode 100644 index 000000000..75f631f00 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptions.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneRulesetVersions options. + */ +public class GetZoneRulesetVersionsOptions extends GenericModel { + + protected String rulesetId; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + + /** + * Instantiates a new Builder from an existing GetZoneRulesetVersionsOptions instance. + * + * @param getZoneRulesetVersionsOptions the instance to initialize the Builder with + */ + private Builder(GetZoneRulesetVersionsOptions getZoneRulesetVersionsOptions) { + this.rulesetId = getZoneRulesetVersionsOptions.rulesetId; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a GetZoneRulesetVersionsOptions. + * + * @return the new GetZoneRulesetVersionsOptions instance + */ + public GetZoneRulesetVersionsOptions build() { + return new GetZoneRulesetVersionsOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the GetZoneRulesetVersionsOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + } + + protected GetZoneRulesetVersionsOptions() { } + + protected GetZoneRulesetVersionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + } + + /** + * New builder. + * + * @return a GetZoneRulesetVersionsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptions.java new file mode 100644 index 000000000..f6a988692 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptions.java @@ -0,0 +1,29 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The getZoneRulesets options. + */ +public class GetZoneRulesetsOptions extends GenericModel { + + /** + * Construct a new instance of GetZoneRulesetsOptions. + */ + public GetZoneRulesetsOptions() { + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsResp.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsResp.java new file mode 100644 index 000000000..0edb624f9 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsResp.java @@ -0,0 +1,76 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * List rulesets response. + */ +public class ListRulesetsResp extends GenericModel { + + protected Boolean success; + protected List errors; + protected List messages; + protected List result; + + protected ListRulesetsResp() { } + + /** + * Gets the success. + * + * Was operation successful. + * + * @return the success + */ + public Boolean isSuccess() { + return success; + } + + /** + * Gets the errors. + * + * Array of errors encountered. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Gets the messages. + * + * Array of messages returned. + * + * @return the messages + */ + public List getMessages() { + return messages; + } + + /** + * Gets the result. + * + * Container for response information. + * + * @return the result + */ + public List getResult() { + return result; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRuleset.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRuleset.java new file mode 100644 index 000000000..c62819725 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRuleset.java @@ -0,0 +1,167 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * ListedRuleset. + */ +public class ListedRuleset extends GenericModel { + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String description; + protected String id; + protected String kind; + @SerializedName("last_updated") + protected String lastUpdated; + protected String name; + protected String phase; + protected String version; + + protected ListedRuleset() { } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the id. + * + * unique ID of the ruleset. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String getKind() { + return kind; + } + + /** + * Gets the lastUpdated. + * + * The timestamp of when the resource was last modified. + * + * @return the lastUpdated + */ + public String getLastUpdated() { + return lastUpdated; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String getPhase() { + return phase; + } + + /** + * Gets the version. + * + * The version of the ruleset. + * + * @return the version + */ + public String getVersion() { + return version; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Logging.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Logging.java new file mode 100644 index 000000000..d535d2a86 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Logging.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Logging. + */ +public class Logging extends GenericModel { + + protected Boolean enabled; + + /** + * Builder. + */ + public static class Builder { + private Boolean enabled; + + /** + * Instantiates a new Builder from an existing Logging instance. + * + * @param logging the instance to initialize the Builder with + */ + private Builder(Logging logging) { + this.enabled = logging.enabled; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param enabled the enabled + */ + public Builder(Boolean enabled) { + this.enabled = enabled; + } + + /** + * Builds a Logging. + * + * @return the new Logging instance + */ + public Logging build() { + return new Logging(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the Logging builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + } + + protected Logging() { } + + protected Logging(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.enabled, + "enabled cannot be null"); + enabled = builder.enabled; + } + + /** + * New builder. + * + * @return a Logging builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Message.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Message.java new file mode 100644 index 000000000..9b98dc501 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Message.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Message. + */ +public class Message extends GenericModel { + + protected Long code; + protected String message; + protected MessageSource source; + + protected Message() { } + + /** + * Gets the code. + * + * A unique code for this message. + * + * @return the code + */ + public Long getCode() { + return code; + } + + /** + * Gets the message. + * + * A text description of this message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Gets the source. + * + * The source of this message. + * + * @return the source + */ + public MessageSource getSource() { + return source; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSource.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSource.java new file mode 100644 index 000000000..31617c6c5 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSource.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The source of this message. + */ +public class MessageSource extends GenericModel { + + protected String pointer; + + protected MessageSource() { } + + /** + * Gets the pointer. + * + * A JSON pointer to the field that is the source of the message. + * + * @return the pointer + */ + public String getPointer() { + return pointer; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Overrides.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Overrides.java new file mode 100644 index 000000000..9533e5018 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Overrides.java @@ -0,0 +1,242 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Overrides. + */ +public class Overrides extends GenericModel { + + /** + * The sensitivity level of the rule. + */ + public interface SensitivityLevel { + /** high. */ + String HIGH = "high"; + /** medium. */ + String MEDIUM = "medium"; + /** low. */ + String LOW = "low"; + } + + protected String action; + protected Boolean enabled; + @SerializedName("sensitivity_level") + protected String sensitivityLevel; + protected List rules; + protected List categories; + + /** + * Builder. + */ + public static class Builder { + private String action; + private Boolean enabled; + private String sensitivityLevel; + private List rules; + private List categories; + + /** + * Instantiates a new Builder from an existing Overrides instance. + * + * @param overrides the instance to initialize the Builder with + */ + private Builder(Overrides overrides) { + this.action = overrides.action; + this.enabled = overrides.enabled; + this.sensitivityLevel = overrides.sensitivityLevel; + this.rules = overrides.rules; + this.categories = overrides.categories; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Overrides. + * + * @return the new Overrides instance + */ + public Overrides build() { + return new Overrides(this); + } + + /** + * Adds a new element to rules. + * + * @param rules the new element to be added + * @return the Overrides builder + */ + public Builder addRules(RulesOverride rules) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rules, + "rules cannot be null"); + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rules); + return this; + } + + /** + * Adds a new element to categories. + * + * @param categories the new element to be added + * @return the Overrides builder + */ + public Builder addCategories(CategoriesOverride categories) { + com.ibm.cloud.sdk.core.util.Validator.notNull(categories, + "categories cannot be null"); + if (this.categories == null) { + this.categories = new ArrayList(); + } + this.categories.add(categories); + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the Overrides builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the Overrides builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the sensitivityLevel. + * + * @param sensitivityLevel the sensitivityLevel + * @return the Overrides builder + */ + public Builder sensitivityLevel(String sensitivityLevel) { + this.sensitivityLevel = sensitivityLevel; + return this; + } + + /** + * Set the rules. + * Existing rules will be replaced. + * + * @param rules the rules + * @return the Overrides builder + */ + public Builder rules(List rules) { + this.rules = rules; + return this; + } + + /** + * Set the categories. + * Existing categories will be replaced. + * + * @param categories the categories + * @return the Overrides builder + */ + public Builder categories(List categories) { + this.categories = categories; + return this; + } + } + + protected Overrides() { } + + protected Overrides(Builder builder) { + action = builder.action; + enabled = builder.enabled; + sensitivityLevel = builder.sensitivityLevel; + rules = builder.rules; + categories = builder.categories; + } + + /** + * New builder. + * + * @return a Overrides builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the sensitivityLevel. + * + * The sensitivity level of the rule. + * + * @return the sensitivityLevel + */ + public String sensitivityLevel() { + return sensitivityLevel; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List rules() { + return rules; + } + + /** + * Gets the categories. + * + * @return the categories + */ + public List categories() { + return categories; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Position.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Position.java new file mode 100644 index 000000000..9674168f6 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Position.java @@ -0,0 +1,145 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Position. + */ +public class Position extends GenericModel { + + protected String before; + protected String after; + protected Long index; + + /** + * Builder. + */ + public static class Builder { + private String before; + private String after; + private Long index; + + /** + * Instantiates a new Builder from an existing Position instance. + * + * @param position the instance to initialize the Builder with + */ + private Builder(Position position) { + this.before = position.before; + this.after = position.after; + this.index = position.index; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Position. + * + * @return the new Position instance + */ + public Position build() { + return new Position(this); + } + + /** + * Set the before. + * + * @param before the before + * @return the Position builder + */ + public Builder before(String before) { + this.before = before; + return this; + } + + /** + * Set the after. + * + * @param after the after + * @return the Position builder + */ + public Builder after(String after) { + this.after = after; + return this; + } + + /** + * Set the index. + * + * @param index the index + * @return the Position builder + */ + public Builder index(long index) { + this.index = index; + return this; + } + } + + protected Position() { } + + protected Position(Builder builder) { + before = builder.before; + after = builder.after; + index = builder.index; + } + + /** + * New builder. + * + * @return a Position builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the before. + * + * The rule ID to place this rule before. + * + * @return the before + */ + public String before() { + return before; + } + + /** + * Gets the after. + * + * The rule ID to place this rule after. + * + * @return the after + */ + public String after() { + return after; + } + + /** + * Gets the index. + * + * The index to place this rule at. + * + * @return the index + */ + public Long index() { + return index; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Ratelimit.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Ratelimit.java new file mode 100644 index 000000000..1c410afd8 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/Ratelimit.java @@ -0,0 +1,222 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Ratelimit. + */ +public class Ratelimit extends GenericModel { + + protected List characteristics; + @SerializedName("counting_expression") + protected String countingExpression; + @SerializedName("mitigation_timeout") + protected Long mitigationTimeout; + protected Long period; + @SerializedName("requests_per_period") + protected Long requestsPerPeriod; + + /** + * Builder. + */ + public static class Builder { + private List characteristics; + private String countingExpression; + private Long mitigationTimeout; + private Long period; + private Long requestsPerPeriod; + + /** + * Instantiates a new Builder from an existing Ratelimit instance. + * + * @param ratelimit the instance to initialize the Builder with + */ + private Builder(Ratelimit ratelimit) { + this.characteristics = ratelimit.characteristics; + this.countingExpression = ratelimit.countingExpression; + this.mitigationTimeout = ratelimit.mitigationTimeout; + this.period = ratelimit.period; + this.requestsPerPeriod = ratelimit.requestsPerPeriod; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a Ratelimit. + * + * @return the new Ratelimit instance + */ + public Ratelimit build() { + return new Ratelimit(this); + } + + /** + * Adds a new element to characteristics. + * + * @param characteristics the new element to be added + * @return the Ratelimit builder + */ + public Builder addCharacteristics(String characteristics) { + com.ibm.cloud.sdk.core.util.Validator.notNull(characteristics, + "characteristics cannot be null"); + if (this.characteristics == null) { + this.characteristics = new ArrayList(); + } + this.characteristics.add(characteristics); + return this; + } + + /** + * Set the characteristics. + * Existing characteristics will be replaced. + * + * @param characteristics the characteristics + * @return the Ratelimit builder + */ + public Builder characteristics(List characteristics) { + this.characteristics = characteristics; + return this; + } + + /** + * Set the countingExpression. + * + * @param countingExpression the countingExpression + * @return the Ratelimit builder + */ + public Builder countingExpression(String countingExpression) { + this.countingExpression = countingExpression; + return this; + } + + /** + * Set the mitigationTimeout. + * + * @param mitigationTimeout the mitigationTimeout + * @return the Ratelimit builder + */ + public Builder mitigationTimeout(long mitigationTimeout) { + this.mitigationTimeout = mitigationTimeout; + return this; + } + + /** + * Set the period. + * + * @param period the period + * @return the Ratelimit builder + */ + public Builder period(long period) { + this.period = period; + return this; + } + + /** + * Set the requestsPerPeriod. + * + * @param requestsPerPeriod the requestsPerPeriod + * @return the Ratelimit builder + */ + public Builder requestsPerPeriod(long requestsPerPeriod) { + this.requestsPerPeriod = requestsPerPeriod; + return this; + } + } + + protected Ratelimit() { } + + protected Ratelimit(Builder builder) { + characteristics = builder.characteristics; + countingExpression = builder.countingExpression; + mitigationTimeout = builder.mitigationTimeout; + period = builder.period; + requestsPerPeriod = builder.requestsPerPeriod; + } + + /** + * New builder. + * + * @return a Ratelimit builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the characteristics. + * + * The set of parameters that define how rate for this rule is tracked. + * + * @return the characteristics + */ + public List characteristics() { + return characteristics; + } + + /** + * Gets the countingExpression. + * + * Expression that specifies the criteria you are matching traffic on. + * + * @return the countingExpression + */ + public String countingExpression() { + return countingExpression; + } + + /** + * Gets the mitigationTimeout. + * + * Once the rate is reached, the rate limiting rule blocks further requests for the period of time defined in this + * field. + * + * @return the mitigationTimeout + */ + public Long mitigationTimeout() { + return mitigationTimeout; + } + + /** + * Gets the period. + * + * The period of time to consider (in seconds) when evaluating the rate. + * + * @return the period + */ + public Long period() { + return period; + } + + /** + * Gets the requestsPerPeriod. + * + * The number of requests over the period of time that will trigger the rate limiting rule. + * + * @return the requestsPerPeriod + */ + public Long requestsPerPeriod() { + return requestsPerPeriod; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreate.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreate.java new file mode 100644 index 000000000..9e1aefb59 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreate.java @@ -0,0 +1,330 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * RuleCreate. + */ +public class RuleCreate extends GenericModel { + + protected String action; + @SerializedName("action_parameters") + protected ActionParameters actionParameters; + protected Ratelimit ratelimit; + protected String description; + protected Boolean enabled; + protected String expression; + protected String id; + protected Logging logging; + protected String ref; + protected Position position; + + /** + * Builder. + */ + public static class Builder { + private String action; + private ActionParameters actionParameters; + private Ratelimit ratelimit; + private String description; + private Boolean enabled; + private String expression; + private String id; + private Logging logging; + private String ref; + private Position position; + + /** + * Instantiates a new Builder from an existing RuleCreate instance. + * + * @param ruleCreate the instance to initialize the Builder with + */ + private Builder(RuleCreate ruleCreate) { + this.action = ruleCreate.action; + this.actionParameters = ruleCreate.actionParameters; + this.ratelimit = ruleCreate.ratelimit; + this.description = ruleCreate.description; + this.enabled = ruleCreate.enabled; + this.expression = ruleCreate.expression; + this.id = ruleCreate.id; + this.logging = ruleCreate.logging; + this.ref = ruleCreate.ref; + this.position = ruleCreate.position; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param action the action + * @param expression the expression + */ + public Builder(String action, String expression) { + this.action = action; + this.expression = expression; + } + + /** + * Builds a RuleCreate. + * + * @return the new RuleCreate instance + */ + public RuleCreate build() { + return new RuleCreate(this); + } + + /** + * Set the action. + * + * @param action the action + * @return the RuleCreate builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the actionParameters. + * + * @param actionParameters the actionParameters + * @return the RuleCreate builder + */ + public Builder actionParameters(ActionParameters actionParameters) { + this.actionParameters = actionParameters; + return this; + } + + /** + * Set the ratelimit. + * + * @param ratelimit the ratelimit + * @return the RuleCreate builder + */ + public Builder ratelimit(Ratelimit ratelimit) { + this.ratelimit = ratelimit; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuleCreate builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the RuleCreate builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the expression. + * + * @param expression the expression + * @return the RuleCreate builder + */ + public Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the RuleCreate builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the logging. + * + * @param logging the logging + * @return the RuleCreate builder + */ + public Builder logging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Set the ref. + * + * @param ref the ref + * @return the RuleCreate builder + */ + public Builder ref(String ref) { + this.ref = ref; + return this; + } + + /** + * Set the position. + * + * @param position the position + * @return the RuleCreate builder + */ + public Builder position(Position position) { + this.position = position; + return this; + } + } + + protected RuleCreate() { } + + protected RuleCreate(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.action, + "action cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.expression, + "expression cannot be null"); + action = builder.action; + actionParameters = builder.actionParameters; + ratelimit = builder.ratelimit; + description = builder.description; + enabled = builder.enabled; + expression = builder.expression; + id = builder.id; + logging = builder.logging; + ref = builder.ref; + position = builder.position; + } + + /** + * New builder. + * + * @return a RuleCreate builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters actionParameters() { + return actionParameters; + } + + /** + * Gets the ratelimit. + * + * @return the ratelimit + */ + public Ratelimit ratelimit() { + return ratelimit; + } + + /** + * Gets the description. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String expression() { + return expression; + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging logging() { + return logging; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String ref() { + return ref; + } + + /** + * Gets the position. + * + * @return the position + */ + public Position position() { + return position; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetails.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetails.java new file mode 100644 index 000000000..3fcb86c7c --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetails.java @@ -0,0 +1,159 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * RuleDetails. + */ +public class RuleDetails extends GenericModel { + + protected String id; + protected String version; + protected String action; + @SerializedName("action_parameters") + protected ActionParameters actionParameters; + protected List categories; + protected Boolean enabled; + protected String description; + protected String expression; + protected String ref; + protected Logging logging; + @SerializedName("last_updated") + protected String lastUpdated; + + protected RuleDetails() { } + + /** + * Gets the id. + * + * unique ID of rule. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the version. + * + * The version of the rule. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String getAction() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters getActionParameters() { + return actionParameters; + } + + /** + * Gets the categories. + * + * List of categories for the rule. + * + * @return the categories + */ + public List getCategories() { + return categories; + } + + /** + * Gets the enabled. + * + * Is the rule enabled. + * + * @return the enabled + */ + public Boolean isEnabled() { + return enabled; + } + + /** + * Gets the description. + * + * description of the rule. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String getExpression() { + return expression; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String getRef() { + return ref; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging getLogging() { + return logging; + } + + /** + * Gets the lastUpdated. + * + * The timestamp of when the resource was last modified. + * + * @return the lastUpdated + */ + public String getLastUpdated() { + return lastUpdated; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleResp.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleResp.java new file mode 100644 index 000000000..7e88639ff --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RuleResp.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * List rules response. + */ +public class RuleResp extends GenericModel { + + protected Boolean success; + protected List errors; + protected List messages; + protected RuleDetails result; + + protected RuleResp() { } + + /** + * Gets the success. + * + * Was operation successful. + * + * @return the success + */ + public Boolean isSuccess() { + return success; + } + + /** + * Gets the errors. + * + * Array of errors encountered. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Gets the messages. + * + * Array of messages returned. + * + * @return the messages + */ + public List getMessages() { + return messages; + } + + /** + * Gets the result. + * + * @return the result + */ + public RuleDetails getResult() { + return result; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverride.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverride.java new file mode 100644 index 000000000..bbf2d981f --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverride.java @@ -0,0 +1,208 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * RulesOverride. + */ +public class RulesOverride extends GenericModel { + + /** + * The sensitivity level of the rule. + */ + public interface SensitivityLevel { + /** high. */ + String HIGH = "high"; + /** medium. */ + String MEDIUM = "medium"; + /** low. */ + String LOW = "low"; + } + + protected String id; + protected Boolean enabled; + protected String action; + @SerializedName("sensitivity_level") + protected String sensitivityLevel; + @SerializedName("score_threshold") + protected Long scoreThreshold; + + /** + * Builder. + */ + public static class Builder { + private String id; + private Boolean enabled; + private String action; + private String sensitivityLevel; + private Long scoreThreshold; + + /** + * Instantiates a new Builder from an existing RulesOverride instance. + * + * @param rulesOverride the instance to initialize the Builder with + */ + private Builder(RulesOverride rulesOverride) { + this.id = rulesOverride.id; + this.enabled = rulesOverride.enabled; + this.action = rulesOverride.action; + this.sensitivityLevel = rulesOverride.sensitivityLevel; + this.scoreThreshold = rulesOverride.scoreThreshold; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a RulesOverride. + * + * @return the new RulesOverride instance + */ + public RulesOverride build() { + return new RulesOverride(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the RulesOverride builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the RulesOverride builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the RulesOverride builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the sensitivityLevel. + * + * @param sensitivityLevel the sensitivityLevel + * @return the RulesOverride builder + */ + public Builder sensitivityLevel(String sensitivityLevel) { + this.sensitivityLevel = sensitivityLevel; + return this; + } + + /** + * Set the scoreThreshold. + * + * @param scoreThreshold the scoreThreshold + * @return the RulesOverride builder + */ + public Builder scoreThreshold(long scoreThreshold) { + this.scoreThreshold = scoreThreshold; + return this; + } + } + + protected RulesOverride() { } + + protected RulesOverride(Builder builder) { + id = builder.id; + enabled = builder.enabled; + action = builder.action; + sensitivityLevel = builder.sensitivityLevel; + scoreThreshold = builder.scoreThreshold; + } + + /** + * New builder. + * + * @return a RulesOverride builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the sensitivityLevel. + * + * The sensitivity level of the rule. + * + * @return the sensitivityLevel + */ + public String sensitivityLevel() { + return sensitivityLevel; + } + + /** + * Gets the scoreThreshold. + * + * The score threshold of the rule. + * + * @return the scoreThreshold + */ + public Long scoreThreshold() { + return scoreThreshold; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetails.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetails.java new file mode 100644 index 000000000..e0386b833 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetails.java @@ -0,0 +1,179 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * RulesetDetails. + */ +public class RulesetDetails extends GenericModel { + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String description; + protected String id; + protected String kind; + @SerializedName("last_updated") + protected String lastUpdated; + protected String name; + protected String phase; + protected String version; + protected List rules; + + protected RulesetDetails() { } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the id. + * + * unique ID of the ruleset. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String getKind() { + return kind; + } + + /** + * Gets the lastUpdated. + * + * The timestamp of when the resource was last modified. + * + * @return the lastUpdated + */ + public String getLastUpdated() { + return lastUpdated; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String getPhase() { + return phase; + } + + /** + * Gets the version. + * + * The version of the ruleset. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List getRules() { + return rules; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetResp.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetResp.java new file mode 100644 index 000000000..b385e9b8a --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetResp.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * Ruleset response. + */ +public class RulesetResp extends GenericModel { + + protected Boolean success; + protected List errors; + protected List messages; + protected RulesetDetails result; + + protected RulesetResp() { } + + /** + * Gets the success. + * + * Was operation successful. + * + * @return the success + */ + public Boolean isSuccess() { + return success; + } + + /** + * Gets the errors. + * + * Array of errors encountered. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Gets the messages. + * + * Array of messages returned. + * + * @return the messages + */ + public List getMessages() { + return messages; + } + + /** + * Gets the result. + * + * @return the result + */ + public RulesetDetails getResult() { + return result; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptions.java new file mode 100644 index 000000000..1bce99c35 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptions.java @@ -0,0 +1,353 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateInstanceEntrypointRuleset options. + */ +public class UpdateInstanceEntrypointRulesetOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + protected String description; + protected String kind; + protected String name; + protected String phase; + protected List rules; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + private String description; + private String kind; + private String name; + private String phase; + private List rules; + + /** + * Instantiates a new Builder from an existing UpdateInstanceEntrypointRulesetOptions instance. + * + * @param updateInstanceEntrypointRulesetOptions the instance to initialize the Builder with + */ + private Builder(UpdateInstanceEntrypointRulesetOptions updateInstanceEntrypointRulesetOptions) { + this.rulesetPhase = updateInstanceEntrypointRulesetOptions.rulesetPhase; + this.description = updateInstanceEntrypointRulesetOptions.description; + this.kind = updateInstanceEntrypointRulesetOptions.kind; + this.name = updateInstanceEntrypointRulesetOptions.name; + this.phase = updateInstanceEntrypointRulesetOptions.phase; + this.rules = updateInstanceEntrypointRulesetOptions.rules; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a UpdateInstanceEntrypointRulesetOptions. + * + * @return the new UpdateInstanceEntrypointRulesetOptions instance + */ + public UpdateInstanceEntrypointRulesetOptions build() { + return new UpdateInstanceEntrypointRulesetOptions(this); + } + + /** + * Adds a new element to rules. + * + * @param rules the new element to be added + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder addRules(RuleCreate rules) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rules, + "rules cannot be null"); + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rules); + return this; + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the kind. + * + * @param kind the kind + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the phase. + * + * @param phase the phase + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder phase(String phase) { + this.phase = phase; + return this; + } + + /** + * Set the rules. + * Existing rules will be replaced. + * + * @param rules the rules + * @return the UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder rules(List rules) { + this.rules = rules; + return this; + } + } + + protected UpdateInstanceEntrypointRulesetOptions() { } + + protected UpdateInstanceEntrypointRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + description = builder.description; + kind = builder.kind; + name = builder.name; + phase = builder.phase; + rules = builder.rules; + } + + /** + * New builder. + * + * @return a UpdateInstanceEntrypointRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String kind() { + return kind; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String phase() { + return phase; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List rules() { + return rules; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptions.java new file mode 100644 index 000000000..d2bb91f36 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptions.java @@ -0,0 +1,307 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateInstanceRuleset options. + */ +public class UpdateInstanceRulesetOptions extends GenericModel { + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetId; + protected String description; + protected String kind; + protected String name; + protected String phase; + protected List rules; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String description; + private String kind; + private String name; + private String phase; + private List rules; + + /** + * Instantiates a new Builder from an existing UpdateInstanceRulesetOptions instance. + * + * @param updateInstanceRulesetOptions the instance to initialize the Builder with + */ + private Builder(UpdateInstanceRulesetOptions updateInstanceRulesetOptions) { + this.rulesetId = updateInstanceRulesetOptions.rulesetId; + this.description = updateInstanceRulesetOptions.description; + this.kind = updateInstanceRulesetOptions.kind; + this.name = updateInstanceRulesetOptions.name; + this.phase = updateInstanceRulesetOptions.phase; + this.rules = updateInstanceRulesetOptions.rules; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a UpdateInstanceRulesetOptions. + * + * @return the new UpdateInstanceRulesetOptions instance + */ + public UpdateInstanceRulesetOptions build() { + return new UpdateInstanceRulesetOptions(this); + } + + /** + * Adds a new element to rules. + * + * @param rules the new element to be added + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder addRules(RuleCreate rules) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rules, + "rules cannot be null"); + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rules); + return this; + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the kind. + * + * @param kind the kind + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the phase. + * + * @param phase the phase + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder phase(String phase) { + this.phase = phase; + return this; + } + + /** + * Set the rules. + * Existing rules will be replaced. + * + * @param rules the rules + * @return the UpdateInstanceRulesetOptions builder + */ + public Builder rules(List rules) { + this.rules = rules; + return this; + } + } + + protected UpdateInstanceRulesetOptions() { } + + protected UpdateInstanceRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + description = builder.description; + kind = builder.kind; + name = builder.name; + phase = builder.phase; + rules = builder.rules; + } + + /** + * New builder. + * + * @return a UpdateInstanceRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String kind() { + return kind; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String phase() { + return phase; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List rules() { + return rules; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptions.java new file mode 100644 index 000000000..41700c2a6 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptions.java @@ -0,0 +1,380 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateInstanceRulesetRule options. + */ +public class UpdateInstanceRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String ruleId; + protected String action; + protected ActionParameters actionParameters; + protected Ratelimit ratelimit; + protected String description; + protected Boolean enabled; + protected String expression; + protected String id; + protected Logging logging; + protected String ref; + protected Position position; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String ruleId; + private String action; + private ActionParameters actionParameters; + private Ratelimit ratelimit; + private String description; + private Boolean enabled; + private String expression; + private String id; + private Logging logging; + private String ref; + private Position position; + + /** + * Instantiates a new Builder from an existing UpdateInstanceRulesetRuleOptions instance. + * + * @param updateInstanceRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(UpdateInstanceRulesetRuleOptions updateInstanceRulesetRuleOptions) { + this.rulesetId = updateInstanceRulesetRuleOptions.rulesetId; + this.ruleId = updateInstanceRulesetRuleOptions.ruleId; + this.action = updateInstanceRulesetRuleOptions.action; + this.actionParameters = updateInstanceRulesetRuleOptions.actionParameters; + this.ratelimit = updateInstanceRulesetRuleOptions.ratelimit; + this.description = updateInstanceRulesetRuleOptions.description; + this.enabled = updateInstanceRulesetRuleOptions.enabled; + this.expression = updateInstanceRulesetRuleOptions.expression; + this.id = updateInstanceRulesetRuleOptions.id; + this.logging = updateInstanceRulesetRuleOptions.logging; + this.ref = updateInstanceRulesetRuleOptions.ref; + this.position = updateInstanceRulesetRuleOptions.position; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param ruleId the ruleId + */ + public Builder(String rulesetId, String ruleId) { + this.rulesetId = rulesetId; + this.ruleId = ruleId; + } + + /** + * Builds a UpdateInstanceRulesetRuleOptions. + * + * @return the new UpdateInstanceRulesetRuleOptions instance + */ + public UpdateInstanceRulesetRuleOptions build() { + return new UpdateInstanceRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the ruleId. + * + * @param ruleId the ruleId + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder ruleId(String ruleId) { + this.ruleId = ruleId; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the actionParameters. + * + * @param actionParameters the actionParameters + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder actionParameters(ActionParameters actionParameters) { + this.actionParameters = actionParameters; + return this; + } + + /** + * Set the ratelimit. + * + * @param ratelimit the ratelimit + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder ratelimit(Ratelimit ratelimit) { + this.ratelimit = ratelimit; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the expression. + * + * @param expression the expression + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the logging. + * + * @param logging the logging + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder logging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Set the ref. + * + * @param ref the ref + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder ref(String ref) { + this.ref = ref; + return this; + } + + /** + * Set the position. + * + * @param position the position + * @return the UpdateInstanceRulesetRuleOptions builder + */ + public Builder position(Position position) { + this.position = position; + return this; + } + } + + protected UpdateInstanceRulesetRuleOptions() { } + + protected UpdateInstanceRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.ruleId, + "ruleId cannot be empty"); + rulesetId = builder.rulesetId; + ruleId = builder.ruleId; + action = builder.action; + actionParameters = builder.actionParameters; + ratelimit = builder.ratelimit; + description = builder.description; + enabled = builder.enabled; + expression = builder.expression; + id = builder.id; + logging = builder.logging; + ref = builder.ref; + position = builder.position; + } + + /** + * New builder. + * + * @return a UpdateInstanceRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the ruleId. + * + * ID of a specific rule. + * + * @return the ruleId + */ + public String ruleId() { + return ruleId; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters actionParameters() { + return actionParameters; + } + + /** + * Gets the ratelimit. + * + * @return the ratelimit + */ + public Ratelimit ratelimit() { + return ratelimit; + } + + /** + * Gets the description. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String expression() { + return expression; + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging logging() { + return logging; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String ref() { + return ref; + } + + /** + * Gets the position. + * + * @return the position + */ + public Position position() { + return position; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptions.java new file mode 100644 index 000000000..533b6c20c --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptions.java @@ -0,0 +1,353 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateZoneEntrypointRuleset options. + */ +public class UpdateZoneEntrypointRulesetOptions extends GenericModel { + + /** + * The phase of the ruleset. + */ + public interface RulesetPhase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetPhase; + protected String description; + protected String kind; + protected String name; + protected String phase; + protected List rules; + + /** + * Builder. + */ + public static class Builder { + private String rulesetPhase; + private String description; + private String kind; + private String name; + private String phase; + private List rules; + + /** + * Instantiates a new Builder from an existing UpdateZoneEntrypointRulesetOptions instance. + * + * @param updateZoneEntrypointRulesetOptions the instance to initialize the Builder with + */ + private Builder(UpdateZoneEntrypointRulesetOptions updateZoneEntrypointRulesetOptions) { + this.rulesetPhase = updateZoneEntrypointRulesetOptions.rulesetPhase; + this.description = updateZoneEntrypointRulesetOptions.description; + this.kind = updateZoneEntrypointRulesetOptions.kind; + this.name = updateZoneEntrypointRulesetOptions.name; + this.phase = updateZoneEntrypointRulesetOptions.phase; + this.rules = updateZoneEntrypointRulesetOptions.rules; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetPhase the rulesetPhase + */ + public Builder(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + } + + /** + * Builds a UpdateZoneEntrypointRulesetOptions. + * + * @return the new UpdateZoneEntrypointRulesetOptions instance + */ + public UpdateZoneEntrypointRulesetOptions build() { + return new UpdateZoneEntrypointRulesetOptions(this); + } + + /** + * Adds a new element to rules. + * + * @param rules the new element to be added + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder addRules(RuleCreate rules) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rules, + "rules cannot be null"); + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rules); + return this; + } + + /** + * Set the rulesetPhase. + * + * @param rulesetPhase the rulesetPhase + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder rulesetPhase(String rulesetPhase) { + this.rulesetPhase = rulesetPhase; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the kind. + * + * @param kind the kind + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the phase. + * + * @param phase the phase + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder phase(String phase) { + this.phase = phase; + return this; + } + + /** + * Set the rules. + * Existing rules will be replaced. + * + * @param rules the rules + * @return the UpdateZoneEntrypointRulesetOptions builder + */ + public Builder rules(List rules) { + this.rules = rules; + return this; + } + } + + protected UpdateZoneEntrypointRulesetOptions() { } + + protected UpdateZoneEntrypointRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetPhase, + "rulesetPhase cannot be empty"); + rulesetPhase = builder.rulesetPhase; + description = builder.description; + kind = builder.kind; + name = builder.name; + phase = builder.phase; + rules = builder.rules; + } + + /** + * New builder. + * + * @return a UpdateZoneEntrypointRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetPhase. + * + * The phase of the ruleset. + * + * @return the rulesetPhase + */ + public String rulesetPhase() { + return rulesetPhase; + } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String kind() { + return kind; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String phase() { + return phase; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List rules() { + return rules; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptions.java new file mode 100644 index 000000000..147fae6d6 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptions.java @@ -0,0 +1,307 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateZoneRuleset options. + */ +public class UpdateZoneRulesetOptions extends GenericModel { + + public interface Kind { + /** managed. */ + String MANAGED = "managed"; + /** custom. */ + String CUSTOM = "custom"; + /** root. */ + String ROOT = "root"; + /** zone. */ + String ZONE = "zone"; + } + + /** + * The phase of the ruleset. + */ + public interface Phase { + /** ddos_l4. */ + String DDOS_L4 = "ddos_l4"; + /** ddos_l7. */ + String DDOS_L7 = "ddos_l7"; + /** http_config_settings. */ + String HTTP_CONFIG_SETTINGS = "http_config_settings"; + /** http_custom_errors. */ + String HTTP_CUSTOM_ERRORS = "http_custom_errors"; + /** http_log_custom_fields. */ + String HTTP_LOG_CUSTOM_FIELDS = "http_log_custom_fields"; + /** http_ratelimit. */ + String HTTP_RATELIMIT = "http_ratelimit"; + /** http_request_cache_settings. */ + String HTTP_REQUEST_CACHE_SETTINGS = "http_request_cache_settings"; + /** http_request_dynamic_redirect. */ + String HTTP_REQUEST_DYNAMIC_REDIRECT = "http_request_dynamic_redirect"; + /** http_request_firewall_custom. */ + String HTTP_REQUEST_FIREWALL_CUSTOM = "http_request_firewall_custom"; + /** http_request_firewall_managed. */ + String HTTP_REQUEST_FIREWALL_MANAGED = "http_request_firewall_managed"; + /** http_request_late_transform. */ + String HTTP_REQUEST_LATE_TRANSFORM = "http_request_late_transform"; + /** http_request_origin. */ + String HTTP_REQUEST_ORIGIN = "http_request_origin"; + /** http_request_redirect. */ + String HTTP_REQUEST_REDIRECT = "http_request_redirect"; + /** http_request_sanitize. */ + String HTTP_REQUEST_SANITIZE = "http_request_sanitize"; + /** http_request_sbfm. */ + String HTTP_REQUEST_SBFM = "http_request_sbfm"; + /** http_request_select_configuration. */ + String HTTP_REQUEST_SELECT_CONFIGURATION = "http_request_select_configuration"; + /** http_request_transform. */ + String HTTP_REQUEST_TRANSFORM = "http_request_transform"; + /** http_response_compression. */ + String HTTP_RESPONSE_COMPRESSION = "http_response_compression"; + /** http_response_firewall_managed. */ + String HTTP_RESPONSE_FIREWALL_MANAGED = "http_response_firewall_managed"; + /** http_response_headers_transform. */ + String HTTP_RESPONSE_HEADERS_TRANSFORM = "http_response_headers_transform"; + } + + protected String rulesetId; + protected String description; + protected String kind; + protected String name; + protected String phase; + protected List rules; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String description; + private String kind; + private String name; + private String phase; + private List rules; + + /** + * Instantiates a new Builder from an existing UpdateZoneRulesetOptions instance. + * + * @param updateZoneRulesetOptions the instance to initialize the Builder with + */ + private Builder(UpdateZoneRulesetOptions updateZoneRulesetOptions) { + this.rulesetId = updateZoneRulesetOptions.rulesetId; + this.description = updateZoneRulesetOptions.description; + this.kind = updateZoneRulesetOptions.kind; + this.name = updateZoneRulesetOptions.name; + this.phase = updateZoneRulesetOptions.phase; + this.rules = updateZoneRulesetOptions.rules; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + */ + public Builder(String rulesetId) { + this.rulesetId = rulesetId; + } + + /** + * Builds a UpdateZoneRulesetOptions. + * + * @return the new UpdateZoneRulesetOptions instance + */ + public UpdateZoneRulesetOptions build() { + return new UpdateZoneRulesetOptions(this); + } + + /** + * Adds a new element to rules. + * + * @param rules the new element to be added + * @return the UpdateZoneRulesetOptions builder + */ + public Builder addRules(RuleCreate rules) { + com.ibm.cloud.sdk.core.util.Validator.notNull(rules, + "rules cannot be null"); + if (this.rules == null) { + this.rules = new ArrayList(); + } + this.rules.add(rules); + return this; + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the UpdateZoneRulesetOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateZoneRulesetOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the kind. + * + * @param kind the kind + * @return the UpdateZoneRulesetOptions builder + */ + public Builder kind(String kind) { + this.kind = kind; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateZoneRulesetOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the phase. + * + * @param phase the phase + * @return the UpdateZoneRulesetOptions builder + */ + public Builder phase(String phase) { + this.phase = phase; + return this; + } + + /** + * Set the rules. + * Existing rules will be replaced. + * + * @param rules the rules + * @return the UpdateZoneRulesetOptions builder + */ + public Builder rules(List rules) { + this.rules = rules; + return this; + } + } + + protected UpdateZoneRulesetOptions() { } + + protected UpdateZoneRulesetOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + rulesetId = builder.rulesetId; + description = builder.description; + kind = builder.kind; + name = builder.name; + phase = builder.phase; + rules = builder.rules; + } + + /** + * New builder. + * + * @return a UpdateZoneRulesetOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the description. + * + * description of the ruleset. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the kind. + * + * @return the kind + */ + public String kind() { + return kind; + } + + /** + * Gets the name. + * + * human readable name of the ruleset. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the phase. + * + * The phase of the ruleset. + * + * @return the phase + */ + public String phase() { + return phase; + } + + /** + * Gets the rules. + * + * @return the rules + */ + public List rules() { + return rules; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptions.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptions.java new file mode 100644 index 000000000..0dbda8b55 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptions.java @@ -0,0 +1,380 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * The updateZoneRulesetRule options. + */ +public class UpdateZoneRulesetRuleOptions extends GenericModel { + + protected String rulesetId; + protected String ruleId; + protected String action; + protected ActionParameters actionParameters; + protected Ratelimit ratelimit; + protected String description; + protected Boolean enabled; + protected String expression; + protected String id; + protected Logging logging; + protected String ref; + protected Position position; + + /** + * Builder. + */ + public static class Builder { + private String rulesetId; + private String ruleId; + private String action; + private ActionParameters actionParameters; + private Ratelimit ratelimit; + private String description; + private Boolean enabled; + private String expression; + private String id; + private Logging logging; + private String ref; + private Position position; + + /** + * Instantiates a new Builder from an existing UpdateZoneRulesetRuleOptions instance. + * + * @param updateZoneRulesetRuleOptions the instance to initialize the Builder with + */ + private Builder(UpdateZoneRulesetRuleOptions updateZoneRulesetRuleOptions) { + this.rulesetId = updateZoneRulesetRuleOptions.rulesetId; + this.ruleId = updateZoneRulesetRuleOptions.ruleId; + this.action = updateZoneRulesetRuleOptions.action; + this.actionParameters = updateZoneRulesetRuleOptions.actionParameters; + this.ratelimit = updateZoneRulesetRuleOptions.ratelimit; + this.description = updateZoneRulesetRuleOptions.description; + this.enabled = updateZoneRulesetRuleOptions.enabled; + this.expression = updateZoneRulesetRuleOptions.expression; + this.id = updateZoneRulesetRuleOptions.id; + this.logging = updateZoneRulesetRuleOptions.logging; + this.ref = updateZoneRulesetRuleOptions.ref; + this.position = updateZoneRulesetRuleOptions.position; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param rulesetId the rulesetId + * @param ruleId the ruleId + */ + public Builder(String rulesetId, String ruleId) { + this.rulesetId = rulesetId; + this.ruleId = ruleId; + } + + /** + * Builds a UpdateZoneRulesetRuleOptions. + * + * @return the new UpdateZoneRulesetRuleOptions instance + */ + public UpdateZoneRulesetRuleOptions build() { + return new UpdateZoneRulesetRuleOptions(this); + } + + /** + * Set the rulesetId. + * + * @param rulesetId the rulesetId + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder rulesetId(String rulesetId) { + this.rulesetId = rulesetId; + return this; + } + + /** + * Set the ruleId. + * + * @param ruleId the ruleId + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder ruleId(String ruleId) { + this.ruleId = ruleId; + return this; + } + + /** + * Set the action. + * + * @param action the action + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder action(String action) { + this.action = action; + return this; + } + + /** + * Set the actionParameters. + * + * @param actionParameters the actionParameters + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder actionParameters(ActionParameters actionParameters) { + this.actionParameters = actionParameters; + return this; + } + + /** + * Set the ratelimit. + * + * @param ratelimit the ratelimit + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder ratelimit(Ratelimit ratelimit) { + this.ratelimit = ratelimit; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the expression. + * + * @param expression the expression + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder expression(String expression) { + this.expression = expression; + return this; + } + + /** + * Set the id. + * + * @param id the id + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * Set the logging. + * + * @param logging the logging + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder logging(Logging logging) { + this.logging = logging; + return this; + } + + /** + * Set the ref. + * + * @param ref the ref + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder ref(String ref) { + this.ref = ref; + return this; + } + + /** + * Set the position. + * + * @param position the position + * @return the UpdateZoneRulesetRuleOptions builder + */ + public Builder position(Position position) { + this.position = position; + return this; + } + } + + protected UpdateZoneRulesetRuleOptions() { } + + protected UpdateZoneRulesetRuleOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.rulesetId, + "rulesetId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.ruleId, + "ruleId cannot be empty"); + rulesetId = builder.rulesetId; + ruleId = builder.ruleId; + action = builder.action; + actionParameters = builder.actionParameters; + ratelimit = builder.ratelimit; + description = builder.description; + enabled = builder.enabled; + expression = builder.expression; + id = builder.id; + logging = builder.logging; + ref = builder.ref; + position = builder.position; + } + + /** + * New builder. + * + * @return a UpdateZoneRulesetRuleOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the rulesetId. + * + * ID of a specific ruleset. + * + * @return the rulesetId + */ + public String rulesetId() { + return rulesetId; + } + + /** + * Gets the ruleId. + * + * ID of a specific rule. + * + * @return the ruleId + */ + public String ruleId() { + return ruleId; + } + + /** + * Gets the action. + * + * What happens when theres a match for the rule expression. + * + * @return the action + */ + public String action() { + return action; + } + + /** + * Gets the actionParameters. + * + * @return the actionParameters + */ + public ActionParameters actionParameters() { + return actionParameters; + } + + /** + * Gets the ratelimit. + * + * @return the ratelimit + */ + public Ratelimit ratelimit() { + return ratelimit; + } + + /** + * Gets the description. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * Gets the enabled. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the expression. + * + * The expression defining which traffic will match the rule. + * + * @return the expression + */ + public String expression() { + return expression; + } + + /** + * Gets the id. + * + * @return the id + */ + public String id() { + return id; + } + + /** + * Gets the logging. + * + * @return the logging + */ + public Logging logging() { + return logging; + } + + /** + * Gets the ref. + * + * The reference of the rule (the rule ID by default). + * + * @return the ref + */ + public String ref() { + return ref; + } + + /** + * Gets the position. + * + * @return the position + */ + public Position position() { + return position; + } +} + diff --git a/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/package-info.java b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/package-info.java new file mode 100644 index 000000000..086965e81 --- /dev/null +++ b/modules/rulesets/src/main/java/com/ibm/cloud/networking/rulesets/v1/package-info.java @@ -0,0 +1,17 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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. + */ + +/** + * Rulesets v1. + */ +package com.ibm.cloud.networking.rulesets.v1; diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsIT.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsIT.java new file mode 100644 index 000000000..d88c33198 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsIT.java @@ -0,0 +1,996 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.fail; + +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.IntStream; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.CreateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.CreateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionByTagOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.ListRulesetsResp; +import com.ibm.cloud.networking.rulesets.v1.model.ListedRuleset; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RuleResp; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetResp; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneEntrypointRulesetOptions.RulesetPhase; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.utils.TestUtilities; +import com.ibm.cloud.networking.test.SdkIntegrationTestBase; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.CredentialUtils; + +/** + * Integration test class for the Rulesets service. + */ +public class RulesetsIT extends SdkIntegrationTestBase { + public Rulesets service = null; + public static Map config = null; + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + // service config variables + String crn; + String zoneIdentifier; + + // placeholder variables + // will be used to store the data fetched in one test, so that it can be used in + // other test + List rulesets; + RulesetDetails ruleset; + RulesetDetails updatedRuleset; + List rulesetVersions; + RulesetDetails specificRuleset; + Map entrypointRuleset; + Map updatedEntrypointRuleset; + Map> entrypointRulesetVersions; + Map specificEntrypointRulesetVersion; + int firstCustomRulesetIndex = -1; + + /** + * This method provides our config filename to the base class. + */ + public String getConfigFilename() { + return "../../rulesets_v1.env"; + } + + @BeforeClass + public void constructService() { + // Ask super if we should skip the tests. + if (skipTests()) { + return; + } + + // Load up our test-specific config properties. + config = CredentialUtils.getServiceProperties(Rulesets.DEFAULT_SERVICE_NAME); + crn = config.get("CRN"); + zoneIdentifier = config.get("ZONE_ID"); + + service = Rulesets.newInstance(crn, zoneIdentifier); + assertNotNull(service); + assertNotNull(service.getServiceUrl()); + + assertNotNull(config); + assertFalse(config.isEmpty()); + assertEquals(service.getServiceUrl(), config.get("URL")); + + service.enableRetries(4, 30); + + System.out.println("Setup complete."); + } + + /* INSTANCE RULESETS TESTS */ + + /* + * 1. list rulesets ✅ + * 2. get a ruleset ✅ + * 3. update a ruleset ✅ + * 4. list versions of a ruleset ✅ + * 5. get a specific version of a ruleset✅ + * 6. get a entrypoint ruleset ✅ + * 7. get versions of entrypoint ruleset ✅ + * 8. get specific entrypoint ruleset version ✅ + * 9. get specific ruleset version by tag ✅ + * 10. update/create entrypoint ruleset ✅ + * 11. create a rule in ruleset ✅ + * 12. update a rule in ruleset ✅ + * 13. delete a rule in ruleset ✅ + * 14. delete a specifig version of ruleset ✅ + * + */ + + // 1. List/Get rulesets + @Test + public void testGetInstanceRulesets() throws Exception { + try { + GetInstanceRulesetsOptions getInstanceRulesetsOptions = new GetInstanceRulesetsOptions(); + + // invoke service + Response response = service.getInstanceRulesets(getInstanceRulesetsOptions).execute(); + + // validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + ListRulesetsResp listRulesetsRespResult = response.getResult(); + assertNotNull(listRulesetsRespResult); + + rulesets = listRulesetsRespResult.getResult(); + // System.out.println("rulesets list ===> " + rulesets); + System.out.println("1. list/get rulesets ✅"); + + // find a first custom ruleset + // required to update the particular ruleset, because we only can update + // custom ruleset and not managed + + firstCustomRulesetIndex = IntStream.range(0, rulesets.size()) + .filter(i -> ("http_request_firewall_custom".equalsIgnoreCase(rulesets.get(i).getPhase()) + && "custom".equalsIgnoreCase(rulesets.get(i).getKind()))) + .findFirst() + .orElse(-1); + + System.out.println("first CustomRuleset Index => " + firstCustomRulesetIndex); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 2. get a rulset + @Test(dependsOnMethods = { "testGetInstanceRulesets" }) + public void testGetInstanceRuleset() throws Exception { + try { + GetInstanceRulesetOptions getInstanceRulesetOptions = new GetInstanceRulesetOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .build(); + + // Invoke operation + Response response = service.getInstanceRuleset(getInstanceRulesetOptions).execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetRespResult = response.getResult(); + assertNotNull(rulesetRespResult); + + ruleset = rulesetRespResult.getResult(); + // System.out.println("ruleset ===> " + ruleset); + System.out.println("2. get a ruleset ✅"); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 3. update a ruleset + @Test(dependsOnMethods = { "testGetInstanceRulesets" }) + public void testUpdateInstanceRuleset() throws Exception { + try { + + UpdateInstanceRulesetOptions options = new UpdateInstanceRulesetOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .description("updated description!") + .build(); + + // Invoke operation + Response response = service.updateInstanceRuleset(options).execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetRespResult = response.getResult(); + assertNotNull(rulesetRespResult); + + updatedRuleset = rulesetRespResult.getResult(); + // System.out.println("test testEntrypointRuleset ===> " + updatedRuleset); + + System.out.println("3. update a ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 4. list versions of a ruleset + @Test(dependsOnMethods = { "testGetInstanceRulesets" }) + public void testGetInstanceRulesetVersions() throws Exception { + try { + + GetInstanceRulesetVersionsOptions options = new GetInstanceRulesetVersionsOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .build(); + + // Invoke operation + Response response = service.getInstanceRulesetVersions(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + ListRulesetsResp listRulesetsRespResult = response.getResult(); + assertNotNull(listRulesetsRespResult); + + rulesetVersions = listRulesetsRespResult.getResult(); + // System.out + // .println("list ruleset versions for ruleset_id " + rulesets.get(0).getId() + + // " ====> " + rulesetVersions); + + System.out.println("4. list ruleset versions ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 5. get a specifig version of a ruleset + @Test(dependsOnMethods = { "testGetInstanceRulesetVersions" }) + public void testGetInstanceRulesetVersion() throws Exception { + try { + + String rulesetId = rulesets.get(firstCustomRulesetIndex).getId(); + String rulesetVersion = rulesetVersions.get(0).getVersion(); + GetInstanceRulesetVersionOptions options = new GetInstanceRulesetVersionOptions.Builder() + .rulesetId(rulesetId) + .rulesetVersion(rulesetVersion) + .build(); + + // Invoke operation + Response response = service.getInstanceRulesetVersion(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetResp = response.getResult(); + assertNotNull(rulesetResp); + + specificRuleset = rulesetResp.getResult(); + // System.out.println("get a " + rulesetVersion + " version of ruleset " + + // rulesetId + " ====> " + specificRuleset); + + System.out.println("5. get a specific ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 6. get entrypoint rulesets + @Test + public void testGetInstanceEntryPointRulesets() throws Exception { + + try { + GetInstanceEntrypointRulesetOptions options = new GetInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .build(); + + Response response = service.getInstanceEntrypointRuleset(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + entrypointRuleset = new HashMap<>(); + entrypointRuleset.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset ===> " + entrypointRuleset); + System.out.println("6. get entrypoint rulesets ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 7. get versions of entrypoint ruleset + @Test + public void testGetInstanceEntryPointRulesetVersions() throws Exception { + try { + GetInstanceEntryPointRulesetVersionsOptions options = new GetInstanceEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .build(); + + Response response = service.getInstanceEntryPointRulesetVersions(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + entrypointRulesetVersions = new HashMap<>(); + entrypointRulesetVersions.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset ===> " + entrypointRulesetVersions); + System.out.println("7. get entrypoint ruleset versions ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 8. get specific entrypoint ruleset version + @Test(dependsOnMethods = { "testGetInstanceEntryPointRulesetVersions" }) + public void testGetInstanceEntryPointRulesetVersion() throws Exception { + try { + GetInstanceEntryPointRulesetVersionOptions options = new GetInstanceEntryPointRulesetVersionOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .rulesetVersion(entrypointRulesetVersions.get(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM).get(0).getVersion()) + .build(); + + Response response = service.getInstanceEntryPointRulesetVersion(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + specificEntrypointRulesetVersion = new HashMap<>(); + specificEntrypointRulesetVersion.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset version ===> " + + // specificEntrypointRulesetVersion); + System.out.println("8. get a specific entrypoint ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 9. get specific ruleset version by tag + @Test(dependsOnMethods = { "testGetInstanceRulesets" }) + public void testGetInstanceEntryPointRulesetVersionByTag() throws Exception { + try { + + ListedRuleset selectedRuleset = rulesets.get(0); + + GetInstanceRulesetVersionByTagOptions options = new GetInstanceRulesetVersionByTagOptions.Builder() + .rulesetId(selectedRuleset.getId()) + .rulesetVersion(selectedRuleset.getVersion()) + .ruleTag("wordpress") + .build(); + + Response response = service.getInstanceRulesetVersionByTag(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("entrypoint ruleset version by tag ===> " + + // response.getResult()); + System.out.println("9. get a specific entrypoint ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 10. update/create entrypoint ruleset + @Test(dependsOnMethods = { "testGetInstanceRulesets", + "testGetInstanceEntryPointRulesetVersion", + "testGetInstanceRuleset" }) + public void testUpdateInstanceEntrypointRuleset() throws Exception { + try { + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id(ruleset.getId()) + .build(); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("execute") + .actionParameters(actionParametersModel) + .expression("cf.zone.plan eq \"ENT\"") + .build(); + + UpdateInstanceEntrypointRulesetOptions opitons = new UpdateInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .rules(Arrays.asList(ruleCreateModel)) + .build(); + + Response response = service.updateInstanceEntrypointRuleset(opitons).execute(); + + // System.out.println("updated entrypoint ruleset ===> " + + // response.getResult()); + updatedEntrypointRuleset = new HashMap<>(); + updatedEntrypointRuleset.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + System.out.println("10. update a entrypoint ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 11. create a rule in ruleset + @Test(dependsOnMethods = { + "testGetInstanceRulesets", "testGetInstanceRuleset" }) + public void testCreateInstanceRulesetRule() throws Exception { + + try { + + CreateInstanceRulesetRuleOptions options = new CreateInstanceRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .expression("not http.request.uri.path matches \"^/api/.*$\"") + .action("log") + .description("log not /api") + .build(); + + Response response = service.createInstanceRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("new rule in ruleset ===> " + response.getResult()); + ruleset = response.getResult().getResult(); + System.out.println("11. create a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 12. update a rule in ruleset + @Test(dependsOnMethods = { + "testGetInstanceRulesets", "testGetInstanceRuleset", "testCreateInstanceRulesetRule" + }) + public void testUpdateInstanceRulesetRule() throws Exception { + + try { + + UpdateInstanceRulesetRuleOptions options = new UpdateInstanceRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .ruleId(ruleset.getRules().get(0).getId()) + .expression("not http.request.uri.path matches \"^/newapi/.*$\"") + .action("log") + .description("log not /newapi") + .build(); + + Response response = service.updateInstanceRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("updated rule in ruleset ===> " + response.getResult()); + ruleset = response.getResult().getResult(); + System.out.println("12. update a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 13. delete a rule in ruleset + @Test(dependsOnMethods = { + "testGetInstanceRulesets", "testGetInstanceRuleset", "testCreateInstanceRulesetRule", + "testUpdateInstanceRulesetRule" + }) + public void testDeleteInstanceRulesetRule() throws Exception { + + try { + + DeleteInstanceRulesetRuleOptions options = new DeleteInstanceRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .ruleId(ruleset.getRules().get(0).getId()) + .build(); + + Response response = service.deleteInstanceRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("updated rule in ruleset ===> " + response.getResult()); + System.out.println("13. delete a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 14. delete a specifig version of a ruleset + @Test(dependsOnMethods = { "testDeleteInstanceRulesetRule" }) + public void testDeleteInstanceRulesetVersion() throws Exception { + try { + + String rulesetId = ruleset.getId(); + String rulesetVersion = String.valueOf(Integer.parseInt(ruleset.getVersion()) - 1); + + DeleteInstanceRulesetVersionOptions options = new DeleteInstanceRulesetVersionOptions.Builder() + .rulesetId(rulesetId) + .rulesetVersion(rulesetVersion) + .build(); + + // Invoke operation + Response response = service.deleteInstanceRulesetVersion(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + + System.out.println("14. delete a specific ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // /* ZONE RULESET TESTS */ + + /* + * 1. list rulesets + * 2. get a ruleset + * 3. update a ruleset + * 4. list versions of a ruleset + * 5. get a specific version of a ruleset + * 6. get a entrypoint ruleset + * 7. get versions of entrypoint ruleset + * 8. get specific entrypoint ruleset version + * 9. update/create entrypoint ruleset + * 10. create a rule in ruleset + * 11. update a rule in ruleset + * 12. delete a rule in ruleset + * 13. delete a specifig version of ruleset + * + */ + + // 1. list rulesets + @Test(dependsOnMethods = { "testDeleteInstanceRulesetVersion" }) + public void testGetZoneRulesets() throws Exception { + try { + + GetZoneRulesetsOptions options = new GetZoneRulesetsOptions(); + + // invoke service + Response response = service.getZoneRulesets(options).execute(); + + // validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + ListRulesetsResp listRulesetsRespResult = response.getResult(); + assertNotNull(listRulesetsRespResult); + + rulesets = listRulesetsRespResult.getResult(); + // System.out.println("rulesets list ===> " + rulesets); + System.out.println("1. list/get rulesets ✅"); + + // find a first custom ruleset + // required to update the particular ruleset, because we only can update + // custom ruleset and not managed + + firstCustomRulesetIndex = IntStream.range(0, rulesets.size()) + .filter(i -> ("http_request_firewall_custom".equalsIgnoreCase(rulesets.get(i).getPhase()) + && "zone".equalsIgnoreCase(rulesets.get(i).getKind()))) + .findFirst() + .orElse(-1); + + System.out.println("first CustomRuleset Index => " + firstCustomRulesetIndex); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 2. get a rulset + @Test(dependsOnMethods = { "testGetZoneRulesets" }) + public void testGetZoneRuleset() throws Exception { + try { + + GetZoneRulesetOptions options = new GetZoneRulesetOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .build(); + + // Invoke operation + Response response = service.getZoneRuleset(options).execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetRespResult = response.getResult(); + assertNotNull(rulesetRespResult); + + ruleset = rulesetRespResult.getResult(); + // System.out.println("ruleset ===> " + ruleset); + System.out.println("2. get a ruleset ✅"); + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 3. update a ruleset + @Test(dependsOnMethods = { "testGetZoneRulesets" }) + public void testUpdateZoneRuleset() throws Exception { + try { + + UpdateZoneRulesetOptions options = new UpdateZoneRulesetOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .description("updated description!") + .build(); + + // Invoke operation + Response response = service.updateZoneRuleset(options).execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetRespResult = response.getResult(); + assertNotNull(rulesetRespResult); + + updatedRuleset = rulesetRespResult.getResult(); + // System.out.println("test testEntrypointRuleset ===> " + updatedRuleset); + + System.out.println("3. update a ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 4. list versions of a ruleset + @Test(dependsOnMethods = { "testGetZoneRulesets" }) + public void testGetZoneRulesetVersions() throws Exception { + try { + + GetZoneRulesetVersionsOptions options = new GetZoneRulesetVersionsOptions.Builder() + .rulesetId(rulesets.get(firstCustomRulesetIndex).getId()) + .build(); + + // Invoke operation + Response response = service.getZoneRulesetVersions(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + ListRulesetsResp listRulesetsRespResult = response.getResult(); + assertNotNull(listRulesetsRespResult); + + rulesetVersions = listRulesetsRespResult.getResult(); + // System.out + // .println("list ruleset versions for ruleset_id " + rulesets.get(0).getId() + + // " ====> " + rulesetVersions); + + System.out.println("4. list ruleset versions ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 5. get a specifig version of a ruleset + @Test(dependsOnMethods = { "testGetZoneRulesetVersions" }) + public void testGetZoneRulesetVersion() throws Exception { + try { + + String rulesetId = rulesets.get(firstCustomRulesetIndex).getId(); + String rulesetVersion = rulesetVersions.get(0).getVersion(); + GetZoneRulesetVersionOptions options = new GetZoneRulesetVersionOptions.Builder() + .rulesetId(rulesetId) + .rulesetVersion(rulesetVersion) + .build(); + + // Invoke operation + Response response = service.getZoneRulesetVersion(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + RulesetResp rulesetResp = response.getResult(); + assertNotNull(rulesetResp); + + specificRuleset = rulesetResp.getResult(); + // System.out.println("get a " + rulesetVersion + " version of ruleset " + + // rulesetId + " ====> " + specificRuleset); + + System.out.println("5. get a specific ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 6. get entrypoint rulesets + @Test(dependsOnMethods = { "testGetInstanceEntryPointRulesets" }) + public void testGetZoneEntryPointRulesets() throws Exception { + + try { + + GetZoneEntrypointRulesetOptions options = new GetZoneEntrypointRulesetOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .build(); + + Response response = service.getZoneEntrypointRuleset(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + entrypointRuleset = new HashMap<>(); + entrypointRuleset.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset ===> " + entrypointRuleset); + System.out.println("6. get entrypoint rulesets ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 7. get versions of entrypoint ruleset + @Test(dependsOnMethods = { "testGetInstanceEntryPointRulesetVersions" }) + public void testGetZoneEntryPointRulesetVersions() throws Exception { + try { + GetZoneEntryPointRulesetVersionsOptions options = new GetZoneEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .build(); + + Response response = service.getZoneEntryPointRulesetVersions(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + entrypointRulesetVersions = new HashMap<>(); + entrypointRulesetVersions.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset ===> " + entrypointRulesetVersions); + System.out.println("7. get entrypoint ruleset versions ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 8. get specific entrypoint ruleset version + @Test(dependsOnMethods = { "testGetZoneEntryPointRulesetVersions" }) + public void testGetZoneEntryPointRulesetVersion() throws Exception { + try { + GetZoneEntryPointRulesetVersionOptions options = new GetZoneEntryPointRulesetVersionOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .rulesetVersion(entrypointRulesetVersions.get(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM).get(0).getVersion()) + .build(); + + Response response = service.getZoneEntryPointRulesetVersion(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + specificEntrypointRulesetVersion = new HashMap<>(); + specificEntrypointRulesetVersion.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + // System.out.println("entrypoint ruleset version ===> " + + // specificEntrypointRulesetVersion); + System.out.println("8. get a specific entrypoint ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 9. update/create entrypoint ruleset + @Test(dependsOnMethods = { "testGetZoneRulesets", + "testGetZoneEntryPointRulesetVersion", + "testGetZoneRuleset", "testDeleteZoneRulesetRule" }) + public void testUpdateZoneEntrypointRuleset() throws Exception { + try { + + UpdateZoneEntrypointRulesetOptions opitons = new UpdateZoneEntrypointRulesetOptions.Builder() + .rulesetPhase(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM) + .description("updated entrypoint ruleset description!") + .build(); + + Response response = service.updateZoneEntrypointRuleset(opitons).execute(); + + // System.out.println("updated entrypoint ruleset ===> " + + // response.getResult()); + updatedEntrypointRuleset = new HashMap<>(); + updatedEntrypointRuleset.put(RulesetPhase.HTTP_REQUEST_FIREWALL_CUSTOM, response.getResult().getResult()); + + System.out.println("9. update a entrypoint ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + // 10. create a rule in ruleset + @Test(dependsOnMethods = { + "testGetZoneRulesets", "testGetZoneRuleset" }) + public void testCreateZoneRulesetRule() throws Exception { + + try { + + CreateZoneRulesetRuleOptions options = new CreateZoneRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .expression("not http.request.uri.path matches \"^/api/.*$\"") + .action("log") + .description("log not /api") + .build(); + + Response response = service.createZoneRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("new rule in ruleset ===> " + response.getResult()); + ruleset = response.getResult().getResult(); + System.out.println("10. create a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 11. update a rule in ruleset + @Test(dependsOnMethods = { + "testGetZoneRulesets", "testGetZoneRuleset", "testCreateZoneRulesetRule" + }) + public void testUpdateZoneRulesetRule() throws Exception { + + try { + + UpdateZoneRulesetRuleOptions options = new UpdateZoneRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .ruleId(ruleset.getRules().get(0).getId()) + .expression("not http.request.uri.path matches \"^/newapi/.*$\"") + .action("log") + .description("log not /newapi") + .build(); + + Response response = service.updateZoneRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("updated rule in ruleset ===> " + response.getResult()); + ruleset = response.getResult().getResult(); + System.out.println("11. update a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 12. delete a rule in ruleset + @Test(dependsOnMethods = { + "testGetZoneRulesets", "testGetZoneRuleset", "testCreateZoneRulesetRule", "testUpdateZoneRulesetRule" + }) + public void testDeleteZoneRulesetRule() throws Exception { + + try { + + DeleteZoneRulesetRuleOptions options = new DeleteZoneRulesetRuleOptions.Builder() + .rulesetId(ruleset.getId()) + .ruleId(ruleset.getRules().get(0).getId()) + .build(); + + Response response = service.deleteZoneRulesetRule(options).execute(); + + assertNotNull(response); + assertEquals(response.getStatusCode(), 200); + + // System.out.println("updated rule in ruleset ===> " + response.getResult()); + System.out.println("12. delete a rule in ruleset ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + + } + + // 13. delete a specifig version of a ruleset + @Test(dependsOnMethods = { "testDeleteZoneRulesetRule" }) + public void testDeleteZoneRulesetVersion() throws Exception { + try { + + String rulesetId = ruleset.getId(); + String rulesetVersion = String.valueOf(Integer.parseInt(ruleset.getVersion()) - 1); + + DeleteZoneRulesetVersionOptions options = new DeleteZoneRulesetVersionOptions.Builder() + .rulesetId(rulesetId) + .rulesetVersion(rulesetVersion) + .build(); + + // Invoke operation + Response response = service.deleteZoneRulesetVersion(options) + .execute(); + + // Validate response + assertNotNull(response); + assertEquals(response.getStatusCode(), 204); + + System.out.println("13. delete a specific ruleset version ✅"); + + } catch (ServiceResponseException e) { + fail(String.format("Service returned status code %d: %s%nError details: %s", + e.getStatusCode(), e.getMessage(), e.getDebuggingInfo())); + } + } + + @AfterClass + public void tearDown() { + + // cleanup those 2 dummy rulesets + System.out.println("Clean up complete."); + } +} diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsTest.java new file mode 100644 index 000000000..6dee2a9b5 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/RulesetsTest.java @@ -0,0 +1,2255 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1; + +import com.ibm.cloud.networking.rulesets.v1.Rulesets; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.CreateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.CreateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionByTagOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetsOptions; +import com.ibm.cloud.networking.rulesets.v1.model.ListRulesetsResp; +import com.ibm.cloud.networking.rulesets.v1.model.ListedRuleset; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Message; +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RuleDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RuleResp; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetResp; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.utils.TestUtilities; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/** + * Unit test class for the Rulesets service. + */ +public class RulesetsTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Rulesets rulesetsService; + + // 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 + String crn = "testString"; + String zoneIdentifier = "testString"; + new Rulesets(crn, zoneIdentifier, serviceName, null); + } + + + // Test the getter for the crn global parameter + @Test + public void testGetCrn() throws Throwable { + assertEquals(rulesetsService.getCrn(), "testString"); + } + + + // Test the getter for the zoneIdentifier global parameter + @Test + public void testGetZoneIdentifier() throws Throwable { + assertEquals(rulesetsService.getZoneIdentifier(), "testString"); + } + + // Test the getInstanceRulesets operation with a valid options model parameter + @Test + public void testGetInstanceRulesetsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getInstanceRulesetsPath = "/v1/testString/rulesets"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceRulesetsOptions model + GetInstanceRulesetsOptions getInstanceRulesetsOptionsModel = new GetInstanceRulesetsOptions(); + + // Invoke getInstanceRulesets() with a valid options model and verify the result + Response response = rulesetsService.getInstanceRulesets(getInstanceRulesetsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceRulesetsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceRulesets operation with and without retries enabled + @Test + public void testGetInstanceRulesetsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceRulesetsWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceRulesetsWOptions(); + } + + // Test the getInstanceRuleset operation with a valid options model parameter + @Test + public void testGetInstanceRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getInstanceRulesetPath = "/v1/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceRulesetOptions model + GetInstanceRulesetOptions getInstanceRulesetOptionsModel = new GetInstanceRulesetOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke getInstanceRuleset() with a valid options model and verify the result + Response response = rulesetsService.getInstanceRuleset(getInstanceRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceRuleset operation with and without retries enabled + @Test + public void testGetInstanceRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceRulesetWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceRulesetWOptions(); + } + + // Test the getInstanceRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceRuleset(null).execute(); + } + + // Test the updateInstanceRuleset operation with a valid options model parameter + @Test + public void testUpdateInstanceRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateInstanceRulesetPath = "/v1/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the RuleCreate model + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Construct an instance of the UpdateInstanceRulesetOptions model + UpdateInstanceRulesetOptions updateInstanceRulesetOptionsModel = new UpdateInstanceRulesetOptions.Builder() + .rulesetId("testString") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + + // Invoke updateInstanceRuleset() with a valid options model and verify the result + Response response = rulesetsService.updateInstanceRuleset(updateInstanceRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateInstanceRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateInstanceRuleset operation with and without retries enabled + @Test + public void testUpdateInstanceRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateInstanceRulesetWOptions(); + + rulesetsService.disableRetries(); + testUpdateInstanceRulesetWOptions(); + } + + // Test the updateInstanceRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateInstanceRuleset(null).execute(); + } + + // Test the deleteInstanceRuleset operation with a valid options model parameter + @Test + public void testDeleteInstanceRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteInstanceRulesetPath = "/v1/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteInstanceRulesetOptions model + DeleteInstanceRulesetOptions deleteInstanceRulesetOptionsModel = new DeleteInstanceRulesetOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke deleteInstanceRuleset() with a valid options model and verify the result + Response response = rulesetsService.deleteInstanceRuleset(deleteInstanceRulesetOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteInstanceRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteInstanceRuleset operation with and without retries enabled + @Test + public void testDeleteInstanceRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteInstanceRulesetWOptions(); + + rulesetsService.disableRetries(); + testDeleteInstanceRulesetWOptions(); + } + + // Test the deleteInstanceRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteInstanceRuleset(null).execute(); + } + + // Test the getInstanceRulesetVersions operation with a valid options model parameter + @Test + public void testGetInstanceRulesetVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getInstanceRulesetVersionsPath = "/v1/testString/rulesets/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceRulesetVersionsOptions model + GetInstanceRulesetVersionsOptions getInstanceRulesetVersionsOptionsModel = new GetInstanceRulesetVersionsOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke getInstanceRulesetVersions() with a valid options model and verify the result + Response response = rulesetsService.getInstanceRulesetVersions(getInstanceRulesetVersionsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceRulesetVersionsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceRulesetVersions operation with and without retries enabled + @Test + public void testGetInstanceRulesetVersionsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceRulesetVersionsWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceRulesetVersionsWOptions(); + } + + // Test the getInstanceRulesetVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceRulesetVersions(null).execute(); + } + + // Test the getInstanceRulesetVersion operation with a valid options model parameter + @Test + public void testGetInstanceRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getInstanceRulesetVersionPath = "/v1/testString/rulesets/testString/versions/1"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceRulesetVersionOptions model + GetInstanceRulesetVersionOptions getInstanceRulesetVersionOptionsModel = new GetInstanceRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + + // Invoke getInstanceRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.getInstanceRulesetVersion(getInstanceRulesetVersionOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceRulesetVersion operation with and without retries enabled + @Test + public void testGetInstanceRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceRulesetVersionWOptions(); + } + + // Test the getInstanceRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceRulesetVersion(null).execute(); + } + + // Test the deleteInstanceRulesetVersion operation with a valid options model parameter + @Test + public void testDeleteInstanceRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteInstanceRulesetVersionPath = "/v1/testString/rulesets/testString/versions/1"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteInstanceRulesetVersionOptions model + DeleteInstanceRulesetVersionOptions deleteInstanceRulesetVersionOptionsModel = new DeleteInstanceRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + + // Invoke deleteInstanceRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.deleteInstanceRulesetVersion(deleteInstanceRulesetVersionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteInstanceRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteInstanceRulesetVersion operation with and without retries enabled + @Test + public void testDeleteInstanceRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteInstanceRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testDeleteInstanceRulesetVersionWOptions(); + } + + // Test the deleteInstanceRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteInstanceRulesetVersion(null).execute(); + } + + // Test the getInstanceEntrypointRuleset operation with a valid options model parameter + @Test + public void testGetInstanceEntrypointRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getInstanceEntrypointRulesetPath = "/v1/testString/rulesets/phases/ddos_l4/entrypoint"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceEntrypointRulesetOptions model + GetInstanceEntrypointRulesetOptions getInstanceEntrypointRulesetOptionsModel = new GetInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + + // Invoke getInstanceEntrypointRuleset() with a valid options model and verify the result + Response response = rulesetsService.getInstanceEntrypointRuleset(getInstanceEntrypointRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceEntrypointRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceEntrypointRuleset operation with and without retries enabled + @Test + public void testGetInstanceEntrypointRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceEntrypointRulesetWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceEntrypointRulesetWOptions(); + } + + // Test the getInstanceEntrypointRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntrypointRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceEntrypointRuleset(null).execute(); + } + + // Test the updateInstanceEntrypointRuleset operation with a valid options model parameter + @Test + public void testUpdateInstanceEntrypointRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateInstanceEntrypointRulesetPath = "/v1/testString/rulesets/phases/ddos_l4/entrypoint"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the RuleCreate model + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Construct an instance of the UpdateInstanceEntrypointRulesetOptions model + UpdateInstanceEntrypointRulesetOptions updateInstanceEntrypointRulesetOptionsModel = new UpdateInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + + // Invoke updateInstanceEntrypointRuleset() with a valid options model and verify the result + Response response = rulesetsService.updateInstanceEntrypointRuleset(updateInstanceEntrypointRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateInstanceEntrypointRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateInstanceEntrypointRuleset operation with and without retries enabled + @Test + public void testUpdateInstanceEntrypointRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateInstanceEntrypointRulesetWOptions(); + + rulesetsService.disableRetries(); + testUpdateInstanceEntrypointRulesetWOptions(); + } + + // Test the updateInstanceEntrypointRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceEntrypointRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateInstanceEntrypointRuleset(null).execute(); + } + + // Test the getInstanceEntryPointRulesetVersions operation with a valid options model parameter + @Test + public void testGetInstanceEntryPointRulesetVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getInstanceEntryPointRulesetVersionsPath = "/v1/testString/rulesets/phases/ddos_l4/entrypoint/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceEntryPointRulesetVersionsOptions model + GetInstanceEntryPointRulesetVersionsOptions getInstanceEntryPointRulesetVersionsOptionsModel = new GetInstanceEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + + // Invoke getInstanceEntryPointRulesetVersions() with a valid options model and verify the result + Response response = rulesetsService.getInstanceEntryPointRulesetVersions(getInstanceEntryPointRulesetVersionsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceEntryPointRulesetVersionsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceEntryPointRulesetVersions operation with and without retries enabled + @Test + public void testGetInstanceEntryPointRulesetVersionsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceEntryPointRulesetVersionsWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceEntryPointRulesetVersionsWOptions(); + } + + // Test the getInstanceEntryPointRulesetVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntryPointRulesetVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceEntryPointRulesetVersions(null).execute(); + } + + // Test the getInstanceEntryPointRulesetVersion operation with a valid options model parameter + @Test + public void testGetInstanceEntryPointRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getInstanceEntryPointRulesetVersionPath = "/v1/testString/rulesets/phases/ddos_l4/entrypoint/versions/1"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceEntryPointRulesetVersionOptions model + GetInstanceEntryPointRulesetVersionOptions getInstanceEntryPointRulesetVersionOptionsModel = new GetInstanceEntryPointRulesetVersionOptions.Builder() + .rulesetPhase("ddos_l4") + .rulesetVersion("1") + .build(); + + // Invoke getInstanceEntryPointRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.getInstanceEntryPointRulesetVersion(getInstanceEntryPointRulesetVersionOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceEntryPointRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceEntryPointRulesetVersion operation with and without retries enabled + @Test + public void testGetInstanceEntryPointRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceEntryPointRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceEntryPointRulesetVersionWOptions(); + } + + // Test the getInstanceEntryPointRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntryPointRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceEntryPointRulesetVersion(null).execute(); + } + + // Test the createInstanceRulesetRule operation with a valid options model parameter + @Test + public void testCreateInstanceRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String createInstanceRulesetRulePath = "/v1/testString/rulesets/testString/rules"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the CreateInstanceRulesetRuleOptions model + CreateInstanceRulesetRuleOptions createInstanceRulesetRuleOptionsModel = new CreateInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Invoke createInstanceRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.createInstanceRulesetRule(createInstanceRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RulesetResp 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, createInstanceRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createInstanceRulesetRule operation with and without retries enabled + @Test + public void testCreateInstanceRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testCreateInstanceRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testCreateInstanceRulesetRuleWOptions(); + } + + // Test the createInstanceRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateInstanceRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.createInstanceRulesetRule(null).execute(); + } + + // Test the updateInstanceRulesetRule operation with a valid options model parameter + @Test + public void testUpdateInstanceRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateInstanceRulesetRulePath = "/v1/testString/rulesets/testString/rules/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the UpdateInstanceRulesetRuleOptions model + UpdateInstanceRulesetRuleOptions updateInstanceRulesetRuleOptionsModel = new UpdateInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Invoke updateInstanceRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.updateInstanceRulesetRule(updateInstanceRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RulesetResp 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(), "PATCH"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateInstanceRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateInstanceRulesetRule operation with and without retries enabled + @Test + public void testUpdateInstanceRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateInstanceRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testUpdateInstanceRulesetRuleWOptions(); + } + + // Test the updateInstanceRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateInstanceRulesetRule(null).execute(); + } + + // Test the deleteInstanceRulesetRule operation with a valid options model parameter + @Test + public void testDeleteInstanceRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}}"; + String deleteInstanceRulesetRulePath = "/v1/testString/rulesets/testString/rules/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteInstanceRulesetRuleOptions model + DeleteInstanceRulesetRuleOptions deleteInstanceRulesetRuleOptionsModel = new DeleteInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .build(); + + // Invoke deleteInstanceRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.deleteInstanceRulesetRule(deleteInstanceRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RuleResp 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(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteInstanceRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteInstanceRulesetRule operation with and without retries enabled + @Test + public void testDeleteInstanceRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteInstanceRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testDeleteInstanceRulesetRuleWOptions(); + } + + // Test the deleteInstanceRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteInstanceRulesetRule(null).execute(); + } + + // Test the getInstanceRulesetVersionByTag operation with a valid options model parameter + @Test + public void testGetInstanceRulesetVersionByTagWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getInstanceRulesetVersionByTagPath = "/v1/testString/rulesets/testString/versions/1/by_tag/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetInstanceRulesetVersionByTagOptions model + GetInstanceRulesetVersionByTagOptions getInstanceRulesetVersionByTagOptionsModel = new GetInstanceRulesetVersionByTagOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .ruleTag("testString") + .build(); + + // Invoke getInstanceRulesetVersionByTag() with a valid options model and verify the result + Response response = rulesetsService.getInstanceRulesetVersionByTag(getInstanceRulesetVersionByTagOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getInstanceRulesetVersionByTagPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getInstanceRulesetVersionByTag operation with and without retries enabled + @Test + public void testGetInstanceRulesetVersionByTagWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetInstanceRulesetVersionByTagWOptions(); + + rulesetsService.disableRetries(); + testGetInstanceRulesetVersionByTagWOptions(); + } + + // Test the getInstanceRulesetVersionByTag operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionByTagNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getInstanceRulesetVersionByTag(null).execute(); + } + + // Test the getZoneRulesets operation with a valid options model parameter + @Test + public void testGetZoneRulesetsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getZoneRulesetsPath = "/v1/testString/zones/testString/rulesets"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneRulesetsOptions model + GetZoneRulesetsOptions getZoneRulesetsOptionsModel = new GetZoneRulesetsOptions(); + + // Invoke getZoneRulesets() with a valid options model and verify the result + Response response = rulesetsService.getZoneRulesets(getZoneRulesetsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneRulesetsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneRulesets operation with and without retries enabled + @Test + public void testGetZoneRulesetsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneRulesetsWOptions(); + + rulesetsService.disableRetries(); + testGetZoneRulesetsWOptions(); + } + + // Test the getZoneRuleset operation with a valid options model parameter + @Test + public void testGetZoneRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getZoneRulesetPath = "/v1/testString/zones/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneRulesetOptions model + GetZoneRulesetOptions getZoneRulesetOptionsModel = new GetZoneRulesetOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke getZoneRuleset() with a valid options model and verify the result + Response response = rulesetsService.getZoneRuleset(getZoneRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneRuleset operation with and without retries enabled + @Test + public void testGetZoneRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneRulesetWOptions(); + + rulesetsService.disableRetries(); + testGetZoneRulesetWOptions(); + } + + // Test the getZoneRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneRuleset(null).execute(); + } + + // Test the updateZoneRuleset operation with a valid options model parameter + @Test + public void testUpdateZoneRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateZoneRulesetPath = "/v1/testString/zones/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the RuleCreate model + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Construct an instance of the UpdateZoneRulesetOptions model + UpdateZoneRulesetOptions updateZoneRulesetOptionsModel = new UpdateZoneRulesetOptions.Builder() + .rulesetId("testString") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + + // Invoke updateZoneRuleset() with a valid options model and verify the result + Response response = rulesetsService.updateZoneRuleset(updateZoneRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateZoneRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateZoneRuleset operation with and without retries enabled + @Test + public void testUpdateZoneRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateZoneRulesetWOptions(); + + rulesetsService.disableRetries(); + testUpdateZoneRulesetWOptions(); + } + + // Test the updateZoneRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateZoneRuleset(null).execute(); + } + + // Test the deleteZoneRuleset operation with a valid options model parameter + @Test + public void testDeleteZoneRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteZoneRulesetPath = "/v1/testString/zones/testString/rulesets/testString"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteZoneRulesetOptions model + DeleteZoneRulesetOptions deleteZoneRulesetOptionsModel = new DeleteZoneRulesetOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke deleteZoneRuleset() with a valid options model and verify the result + Response response = rulesetsService.deleteZoneRuleset(deleteZoneRulesetOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteZoneRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteZoneRuleset operation with and without retries enabled + @Test + public void testDeleteZoneRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteZoneRulesetWOptions(); + + rulesetsService.disableRetries(); + testDeleteZoneRulesetWOptions(); + } + + // Test the deleteZoneRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteZoneRuleset(null).execute(); + } + + // Test the getZoneRulesetVersions operation with a valid options model parameter + @Test + public void testGetZoneRulesetVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getZoneRulesetVersionsPath = "/v1/testString/zones/testString/rulesets/testString/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneRulesetVersionsOptions model + GetZoneRulesetVersionsOptions getZoneRulesetVersionsOptionsModel = new GetZoneRulesetVersionsOptions.Builder() + .rulesetId("testString") + .build(); + + // Invoke getZoneRulesetVersions() with a valid options model and verify the result + Response response = rulesetsService.getZoneRulesetVersions(getZoneRulesetVersionsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneRulesetVersionsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneRulesetVersions operation with and without retries enabled + @Test + public void testGetZoneRulesetVersionsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneRulesetVersionsWOptions(); + + rulesetsService.disableRetries(); + testGetZoneRulesetVersionsWOptions(); + } + + // Test the getZoneRulesetVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneRulesetVersions(null).execute(); + } + + // Test the getZoneRulesetVersion operation with a valid options model parameter + @Test + public void testGetZoneRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getZoneRulesetVersionPath = "/v1/testString/zones/testString/rulesets/testString/versions/1"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneRulesetVersionOptions model + GetZoneRulesetVersionOptions getZoneRulesetVersionOptionsModel = new GetZoneRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + + // Invoke getZoneRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.getZoneRulesetVersion(getZoneRulesetVersionOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneRulesetVersion operation with and without retries enabled + @Test + public void testGetZoneRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testGetZoneRulesetVersionWOptions(); + } + + // Test the getZoneRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneRulesetVersion(null).execute(); + } + + // Test the deleteZoneRulesetVersion operation with a valid options model parameter + @Test + public void testDeleteZoneRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = ""; + String deleteZoneRulesetVersionPath = "/v1/testString/zones/testString/rulesets/testString/versions/1"; + server.enqueue(new MockResponse() + .setResponseCode(204) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteZoneRulesetVersionOptions model + DeleteZoneRulesetVersionOptions deleteZoneRulesetVersionOptionsModel = new DeleteZoneRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + + // Invoke deleteZoneRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.deleteZoneRulesetVersion(deleteZoneRulesetVersionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + assertNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteZoneRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteZoneRulesetVersion operation with and without retries enabled + @Test + public void testDeleteZoneRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteZoneRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testDeleteZoneRulesetVersionWOptions(); + } + + // Test the deleteZoneRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteZoneRulesetVersion(null).execute(); + } + + // Test the getZoneEntrypointRuleset operation with a valid options model parameter + @Test + public void testGetZoneEntrypointRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getZoneEntrypointRulesetPath = "/v1/testString/zones/testString/rulesets/phases/ddos_l4/entrypoint"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneEntrypointRulesetOptions model + GetZoneEntrypointRulesetOptions getZoneEntrypointRulesetOptionsModel = new GetZoneEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + + // Invoke getZoneEntrypointRuleset() with a valid options model and verify the result + Response response = rulesetsService.getZoneEntrypointRuleset(getZoneEntrypointRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneEntrypointRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneEntrypointRuleset operation with and without retries enabled + @Test + public void testGetZoneEntrypointRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneEntrypointRulesetWOptions(); + + rulesetsService.disableRetries(); + testGetZoneEntrypointRulesetWOptions(); + } + + // Test the getZoneEntrypointRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntrypointRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneEntrypointRuleset(null).execute(); + } + + // Test the updateZoneEntrypointRuleset operation with a valid options model parameter + @Test + public void testUpdateZoneEntrypointRulesetWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateZoneEntrypointRulesetPath = "/v1/testString/zones/testString/rulesets/phases/ddos_l4/entrypoint"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the RuleCreate model + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Construct an instance of the UpdateZoneEntrypointRulesetOptions model + UpdateZoneEntrypointRulesetOptions updateZoneEntrypointRulesetOptionsModel = new UpdateZoneEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + + // Invoke updateZoneEntrypointRuleset() with a valid options model and verify the result + Response response = rulesetsService.updateZoneEntrypointRuleset(updateZoneEntrypointRulesetOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateZoneEntrypointRulesetPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateZoneEntrypointRuleset operation with and without retries enabled + @Test + public void testUpdateZoneEntrypointRulesetWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateZoneEntrypointRulesetWOptions(); + + rulesetsService.disableRetries(); + testUpdateZoneEntrypointRulesetWOptions(); + } + + // Test the updateZoneEntrypointRuleset operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneEntrypointRulesetNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateZoneEntrypointRuleset(null).execute(); + } + + // Test the getZoneEntryPointRulesetVersions operation with a valid options model parameter + @Test + public void testGetZoneEntryPointRulesetVersionsWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": [{\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\"}]}"; + String getZoneEntryPointRulesetVersionsPath = "/v1/testString/zones/testString/rulesets/phases/ddos_l4/entrypoint/versions"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneEntryPointRulesetVersionsOptions model + GetZoneEntryPointRulesetVersionsOptions getZoneEntryPointRulesetVersionsOptionsModel = new GetZoneEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + + // Invoke getZoneEntryPointRulesetVersions() with a valid options model and verify the result + Response response = rulesetsService.getZoneEntryPointRulesetVersions(getZoneEntryPointRulesetVersionsOptionsModel).execute(); + assertNotNull(response); + ListRulesetsResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneEntryPointRulesetVersionsPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneEntryPointRulesetVersions operation with and without retries enabled + @Test + public void testGetZoneEntryPointRulesetVersionsWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneEntryPointRulesetVersionsWOptions(); + + rulesetsService.disableRetries(); + testGetZoneEntryPointRulesetVersionsWOptions(); + } + + // Test the getZoneEntryPointRulesetVersions operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntryPointRulesetVersionsNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneEntryPointRulesetVersions(null).execute(); + } + + // Test the getZoneEntryPointRulesetVersion operation with a valid options model parameter + @Test + public void testGetZoneEntryPointRulesetVersionWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String getZoneEntryPointRulesetVersionPath = "/v1/testString/zones/testString/rulesets/phases/ddos_l4/entrypoint/versions/1"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the GetZoneEntryPointRulesetVersionOptions model + GetZoneEntryPointRulesetVersionOptions getZoneEntryPointRulesetVersionOptionsModel = new GetZoneEntryPointRulesetVersionOptions.Builder() + .rulesetPhase("ddos_l4") + .rulesetVersion("1") + .build(); + + // Invoke getZoneEntryPointRulesetVersion() with a valid options model and verify the result + Response response = rulesetsService.getZoneEntryPointRulesetVersion(getZoneEntryPointRulesetVersionOptionsModel).execute(); + assertNotNull(response); + RulesetResp responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request sent to the mock server + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getZoneEntryPointRulesetVersionPath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the getZoneEntryPointRulesetVersion operation with and without retries enabled + @Test + public void testGetZoneEntryPointRulesetVersionWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testGetZoneEntryPointRulesetVersionWOptions(); + + rulesetsService.disableRetries(); + testGetZoneEntryPointRulesetVersionWOptions(); + } + + // Test the getZoneEntryPointRulesetVersion operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntryPointRulesetVersionNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.getZoneEntryPointRulesetVersion(null).execute(); + } + + // Test the createZoneRulesetRule operation with a valid options model parameter + @Test + public void testCreateZoneRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String createZoneRulesetRulePath = "/v1/testString/zones/testString/rulesets/testString/rules"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the CreateZoneRulesetRuleOptions model + CreateZoneRulesetRuleOptions createZoneRulesetRuleOptionsModel = new CreateZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Invoke createZoneRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.createZoneRulesetRule(createZoneRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RulesetResp 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, createZoneRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the createZoneRulesetRule operation with and without retries enabled + @Test + public void testCreateZoneRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testCreateZoneRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testCreateZoneRulesetRuleWOptions(); + } + + // Test the createZoneRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateZoneRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.createZoneRulesetRule(null).execute(); + } + + // Test the updateZoneRulesetRule operation with a valid options model parameter + @Test + public void testUpdateZoneRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"description\": \"Custom instance ruleset\", \"id\": \"id\", \"kind\": \"managed\", \"last_updated\": \"2000-01-01T00:00:00.000000Z\", \"name\": \"name\", \"phase\": \"ddos_l4\", \"version\": \"1\", \"rules\": [{\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}]}}"; + String updateZoneRulesetRulePath = "/v1/testString/zones/testString/rulesets/testString/rules/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the RulesOverride model + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + + // Construct an instance of the CategoriesOverride model + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + + // Construct an instance of the Overrides model + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + + // Construct an instance of the ActionParametersResponse model + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + + // Construct an instance of the ActionParameters model + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + + // Construct an instance of the Ratelimit model + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + + // Construct an instance of the Logging model + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + + // Construct an instance of the Position model + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + + // Construct an instance of the UpdateZoneRulesetRuleOptions model + UpdateZoneRulesetRuleOptions updateZoneRulesetRuleOptionsModel = new UpdateZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + + // Invoke updateZoneRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.updateZoneRulesetRule(updateZoneRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RulesetResp 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(), "PATCH"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateZoneRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the updateZoneRulesetRule operation with and without retries enabled + @Test + public void testUpdateZoneRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testUpdateZoneRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testUpdateZoneRulesetRuleWOptions(); + } + + // Test the updateZoneRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.updateZoneRulesetRule(null).execute(); + } + + // Test the deleteZoneRulesetRule operation with a valid options model parameter + @Test + public void testDeleteZoneRulesetRuleWOptions() throws Throwable { + // Register a mock response + String mockResponseBody = "{\"success\": true, \"errors\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"messages\": [{\"code\": 10000, \"message\": \"something failed in the request\", \"source\": {\"pointer\": \"/rules/0/action\"}}], \"result\": {\"id\": \"id\", \"version\": \"version\", \"action\": \"action\", \"action_parameters\": {\"id\": \"id\", \"overrides\": {\"action\": \"action\", \"enabled\": false, \"sensitivity_level\": \"high\", \"rules\": [{\"id\": \"id\", \"enabled\": false, \"action\": \"action\", \"sensitivity_level\": \"high\", \"score_threshold\": 60}], \"categories\": [{\"category\": \"category\", \"enabled\": false, \"action\": \"action\"}]}, \"version\": \"version\", \"ruleset\": \"ruleset\", \"rulesets\": [\"rulesets\"], \"phases\": [\"phases\"], \"products\": [\"products\"], \"response\": {\"content\": \"{\\\"success\\\": false, \\\"error\\\": \\\"you have been blocked\\\"}\", \"content_type\": \"application/json\", \"status_code\": 400}}, \"categories\": [\"categories\"], \"enabled\": true, \"description\": \"description\", \"expression\": \"ip.src ne 1.1.1.1\", \"ref\": \"my_ref\", \"logging\": {\"enabled\": true}, \"last_updated\": \"2000-01-01T00:00:00.000000Z\"}}"; + String deleteZoneRulesetRulePath = "/v1/testString/zones/testString/rulesets/testString/rules/testString"; + server.enqueue(new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + // Construct an instance of the DeleteZoneRulesetRuleOptions model + DeleteZoneRulesetRuleOptions deleteZoneRulesetRuleOptionsModel = new DeleteZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .build(); + + // Invoke deleteZoneRulesetRule() with a valid options model and verify the result + Response response = rulesetsService.deleteZoneRulesetRule(deleteZoneRulesetRuleOptionsModel).execute(); + assertNotNull(response); + RuleResp 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(), "DELETE"); + // Verify request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteZoneRulesetRulePath); + // Verify that there is no query string + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + } + + // Test the deleteZoneRulesetRule operation with and without retries enabled + @Test + public void testDeleteZoneRulesetRuleWRetries() throws Throwable { + rulesetsService.enableRetries(4, 30); + testDeleteZoneRulesetRuleWOptions(); + + rulesetsService.disableRetries(); + testDeleteZoneRulesetRuleWOptions(); + } + + // Test the deleteZoneRulesetRule operation with a null options model (negative test) + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetRuleNoOptions() throws Throwable { + server.enqueue(new MockResponse()); + rulesetsService.deleteZoneRulesetRule(null).execute(); + } + + // Perform setup needed before each test method + @BeforeMethod + public void beforeEachTest() { + // Start the mock server. + try { + server = new MockWebServer(); + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + + // Construct an instance of the service + constructClientService(); + } + + // Perform tear down after each test method + @AfterMethod + public void afterEachTest() throws IOException { + server.shutdown(); + rulesetsService = null; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + System.setProperty("TESTSERVICE_AUTH_TYPE", "noAuth"); + final String serviceName = "testService"; + // set mock values for global params + String crn = "testString"; + String zoneIdentifier = "testString"; + + rulesetsService = Rulesets.newInstance(crn, zoneIdentifier, serviceName); + String url = server.url("/").toString(); + rulesetsService.setServiceUrl(url); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponseTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponseTest.java new file mode 100644 index 000000000..2fb70d3aa --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersResponseTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.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 ActionParametersResponse model. + */ +public class ActionParametersResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testActionParametersResponse() throws Throwable { + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + String json = TestUtilities.serialize(actionParametersResponseModel); + + ActionParametersResponse actionParametersResponseModelNew = TestUtilities.deserialize(json, ActionParametersResponse.class); + assertTrue(actionParametersResponseModelNew instanceof ActionParametersResponse); + assertEquals(actionParametersResponseModelNew.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModelNew.contentType(), "application/json"); + assertEquals(actionParametersResponseModelNew.statusCode(), Long.valueOf("400")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testActionParametersResponseError() throws Throwable { + new ActionParametersResponse.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersTest.java new file mode 100644 index 000000000..31bc9b9be --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ActionParametersTest.java @@ -0,0 +1,111 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 ActionParameters model. + */ +public class ActionParametersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testActionParameters() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + String json = TestUtilities.serialize(actionParametersModel); + + ActionParameters actionParametersModelNew = TestUtilities.deserialize(json, ActionParameters.class); + assertTrue(actionParametersModelNew instanceof ActionParameters); + assertEquals(actionParametersModelNew.id(), "testString"); + assertEquals(actionParametersModelNew.overrides().toString(), overridesModel.toString()); + assertEquals(actionParametersModelNew.version(), "testString"); + assertEquals(actionParametersModelNew.ruleset(), "testString"); + assertEquals(actionParametersModelNew.response().toString(), actionParametersResponseModel.toString()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverrideTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverrideTest.java new file mode 100644 index 000000000..5a5dfa116 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CategoriesOverrideTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.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 CategoriesOverride model. + */ +public class CategoriesOverrideTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesOverride() throws Throwable { + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + String json = TestUtilities.serialize(categoriesOverrideModel); + + CategoriesOverride categoriesOverrideModelNew = TestUtilities.deserialize(json, CategoriesOverride.class); + assertTrue(categoriesOverrideModelNew instanceof CategoriesOverride); + assertEquals(categoriesOverrideModelNew.category(), "testString"); + assertEquals(categoriesOverrideModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModelNew.action(), "testString"); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptionsTest.java new file mode 100644 index 000000000..1033b9563 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateInstanceRulesetRuleOptionsTest.java @@ -0,0 +1,163 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.CreateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 CreateInstanceRulesetRuleOptions model. + */ +public class CreateInstanceRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateInstanceRulesetRuleOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + CreateInstanceRulesetRuleOptions createInstanceRulesetRuleOptionsModel = new CreateInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(createInstanceRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(createInstanceRulesetRuleOptionsModel.action(), "testString"); + assertEquals(createInstanceRulesetRuleOptionsModel.actionParameters(), actionParametersModel); + assertEquals(createInstanceRulesetRuleOptionsModel.ratelimit(), ratelimitModel); + assertEquals(createInstanceRulesetRuleOptionsModel.description(), "testString"); + assertEquals(createInstanceRulesetRuleOptionsModel.enabled(), Boolean.valueOf(true)); + assertEquals(createInstanceRulesetRuleOptionsModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(createInstanceRulesetRuleOptionsModel.id(), "testString"); + assertEquals(createInstanceRulesetRuleOptionsModel.logging(), loggingModel); + assertEquals(createInstanceRulesetRuleOptionsModel.ref(), "my_ref"); + assertEquals(createInstanceRulesetRuleOptionsModel.position(), positionModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateInstanceRulesetRuleOptionsError() throws Throwable { + new CreateInstanceRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptionsTest.java new file mode 100644 index 000000000..ff76b4440 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/CreateZoneRulesetRuleOptionsTest.java @@ -0,0 +1,163 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.CreateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 CreateZoneRulesetRuleOptions model. + */ +public class CreateZoneRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateZoneRulesetRuleOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + CreateZoneRulesetRuleOptions createZoneRulesetRuleOptionsModel = new CreateZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(createZoneRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(createZoneRulesetRuleOptionsModel.action(), "testString"); + assertEquals(createZoneRulesetRuleOptionsModel.actionParameters(), actionParametersModel); + assertEquals(createZoneRulesetRuleOptionsModel.ratelimit(), ratelimitModel); + assertEquals(createZoneRulesetRuleOptionsModel.description(), "testString"); + assertEquals(createZoneRulesetRuleOptionsModel.enabled(), Boolean.valueOf(true)); + assertEquals(createZoneRulesetRuleOptionsModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(createZoneRulesetRuleOptionsModel.id(), "testString"); + assertEquals(createZoneRulesetRuleOptionsModel.logging(), loggingModel); + assertEquals(createZoneRulesetRuleOptionsModel.ref(), "my_ref"); + assertEquals(createZoneRulesetRuleOptionsModel.position(), positionModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateZoneRulesetRuleOptionsError() throws Throwable { + new CreateZoneRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptionsTest.java new file mode 100644 index 000000000..64294b84e --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteInstanceRulesetOptions model. + */ +public class DeleteInstanceRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteInstanceRulesetOptions() throws Throwable { + DeleteInstanceRulesetOptions deleteInstanceRulesetOptionsModel = new DeleteInstanceRulesetOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(deleteInstanceRulesetOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetOptionsError() throws Throwable { + new DeleteInstanceRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptionsTest.java new file mode 100644 index 000000000..61cf4921d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetRuleOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteInstanceRulesetRuleOptions model. + */ +public class DeleteInstanceRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteInstanceRulesetRuleOptions() throws Throwable { + DeleteInstanceRulesetRuleOptions deleteInstanceRulesetRuleOptionsModel = new DeleteInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .build(); + assertEquals(deleteInstanceRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(deleteInstanceRulesetRuleOptionsModel.ruleId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetRuleOptionsError() throws Throwable { + new DeleteInstanceRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptionsTest.java new file mode 100644 index 000000000..84544b4a7 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteInstanceRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteInstanceRulesetVersionOptions model. + */ +public class DeleteInstanceRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteInstanceRulesetVersionOptions() throws Throwable { + DeleteInstanceRulesetVersionOptions deleteInstanceRulesetVersionOptionsModel = new DeleteInstanceRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + assertEquals(deleteInstanceRulesetVersionOptionsModel.rulesetId(), "testString"); + assertEquals(deleteInstanceRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteInstanceRulesetVersionOptionsError() throws Throwable { + new DeleteInstanceRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptionsTest.java new file mode 100644 index 000000000..791af200e --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteZoneRulesetOptions model. + */ +public class DeleteZoneRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteZoneRulesetOptions() throws Throwable { + DeleteZoneRulesetOptions deleteZoneRulesetOptionsModel = new DeleteZoneRulesetOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(deleteZoneRulesetOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetOptionsError() throws Throwable { + new DeleteZoneRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptionsTest.java new file mode 100644 index 000000000..ceb9023ec --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetRuleOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteZoneRulesetRuleOptions model. + */ +public class DeleteZoneRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteZoneRulesetRuleOptions() throws Throwable { + DeleteZoneRulesetRuleOptions deleteZoneRulesetRuleOptionsModel = new DeleteZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .build(); + assertEquals(deleteZoneRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(deleteZoneRulesetRuleOptionsModel.ruleId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetRuleOptionsError() throws Throwable { + new DeleteZoneRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptionsTest.java new file mode 100644 index 000000000..ac92357b4 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/DeleteZoneRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.DeleteZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 DeleteZoneRulesetVersionOptions model. + */ +public class DeleteZoneRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteZoneRulesetVersionOptions() throws Throwable { + DeleteZoneRulesetVersionOptions deleteZoneRulesetVersionOptionsModel = new DeleteZoneRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + assertEquals(deleteZoneRulesetVersionOptionsModel.rulesetId(), "testString"); + assertEquals(deleteZoneRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteZoneRulesetVersionOptionsError() throws Throwable { + new DeleteZoneRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptionsTest.java new file mode 100644 index 000000000..1818ad25f --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceEntryPointRulesetVersionOptions model. + */ +public class GetInstanceEntryPointRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceEntryPointRulesetVersionOptions() throws Throwable { + GetInstanceEntryPointRulesetVersionOptions getInstanceEntryPointRulesetVersionOptionsModel = new GetInstanceEntryPointRulesetVersionOptions.Builder() + .rulesetPhase("ddos_l4") + .rulesetVersion("1") + .build(); + assertEquals(getInstanceEntryPointRulesetVersionOptionsModel.rulesetPhase(), "ddos_l4"); + assertEquals(getInstanceEntryPointRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntryPointRulesetVersionOptionsError() throws Throwable { + new GetInstanceEntryPointRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptionsTest.java new file mode 100644 index 000000000..2a109e0a7 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntryPointRulesetVersionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceEntryPointRulesetVersionsOptions model. + */ +public class GetInstanceEntryPointRulesetVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceEntryPointRulesetVersionsOptions() throws Throwable { + GetInstanceEntryPointRulesetVersionsOptions getInstanceEntryPointRulesetVersionsOptionsModel = new GetInstanceEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + assertEquals(getInstanceEntryPointRulesetVersionsOptionsModel.rulesetPhase(), "ddos_l4"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntryPointRulesetVersionsOptionsError() throws Throwable { + new GetInstanceEntryPointRulesetVersionsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptionsTest.java new file mode 100644 index 000000000..dccd1cd4c --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceEntrypointRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceEntrypointRulesetOptions model. + */ +public class GetInstanceEntrypointRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceEntrypointRulesetOptions() throws Throwable { + GetInstanceEntrypointRulesetOptions getInstanceEntrypointRulesetOptionsModel = new GetInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + assertEquals(getInstanceEntrypointRulesetOptionsModel.rulesetPhase(), "ddos_l4"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceEntrypointRulesetOptionsError() throws Throwable { + new GetInstanceEntrypointRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptionsTest.java new file mode 100644 index 000000000..94e62121d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceRulesetOptions model. + */ +public class GetInstanceRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceRulesetOptions() throws Throwable { + GetInstanceRulesetOptions getInstanceRulesetOptionsModel = new GetInstanceRulesetOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(getInstanceRulesetOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetOptionsError() throws Throwable { + new GetInstanceRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptionsTest.java new file mode 100644 index 000000000..accc76e65 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionByTagOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionByTagOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceRulesetVersionByTagOptions model. + */ +public class GetInstanceRulesetVersionByTagOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceRulesetVersionByTagOptions() throws Throwable { + GetInstanceRulesetVersionByTagOptions getInstanceRulesetVersionByTagOptionsModel = new GetInstanceRulesetVersionByTagOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .ruleTag("testString") + .build(); + assertEquals(getInstanceRulesetVersionByTagOptionsModel.rulesetId(), "testString"); + assertEquals(getInstanceRulesetVersionByTagOptionsModel.rulesetVersion(), "1"); + assertEquals(getInstanceRulesetVersionByTagOptionsModel.ruleTag(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionByTagOptionsError() throws Throwable { + new GetInstanceRulesetVersionByTagOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptionsTest.java new file mode 100644 index 000000000..d1d834b2d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceRulesetVersionOptions model. + */ +public class GetInstanceRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceRulesetVersionOptions() throws Throwable { + GetInstanceRulesetVersionOptions getInstanceRulesetVersionOptionsModel = new GetInstanceRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + assertEquals(getInstanceRulesetVersionOptionsModel.rulesetId(), "testString"); + assertEquals(getInstanceRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionOptionsError() throws Throwable { + new GetInstanceRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptionsTest.java new file mode 100644 index 000000000..4fe8b953a --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetVersionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceRulesetVersionsOptions model. + */ +public class GetInstanceRulesetVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceRulesetVersionsOptions() throws Throwable { + GetInstanceRulesetVersionsOptions getInstanceRulesetVersionsOptionsModel = new GetInstanceRulesetVersionsOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(getInstanceRulesetVersionsOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetInstanceRulesetVersionsOptionsError() throws Throwable { + new GetInstanceRulesetVersionsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptionsTest.java new file mode 100644 index 000000000..465a3e45d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetInstanceRulesetsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetInstanceRulesetsOptions; +import com.ibm.cloud.networking.rulesets.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 GetInstanceRulesetsOptions model. + */ +public class GetInstanceRulesetsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetInstanceRulesetsOptions() throws Throwable { + GetInstanceRulesetsOptions getInstanceRulesetsOptionsModel = new GetInstanceRulesetsOptions(); + assertNotNull(getInstanceRulesetsOptionsModel); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptionsTest.java new file mode 100644 index 000000000..c90405280 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneEntryPointRulesetVersionOptions model. + */ +public class GetZoneEntryPointRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneEntryPointRulesetVersionOptions() throws Throwable { + GetZoneEntryPointRulesetVersionOptions getZoneEntryPointRulesetVersionOptionsModel = new GetZoneEntryPointRulesetVersionOptions.Builder() + .rulesetPhase("ddos_l4") + .rulesetVersion("1") + .build(); + assertEquals(getZoneEntryPointRulesetVersionOptionsModel.rulesetPhase(), "ddos_l4"); + assertEquals(getZoneEntryPointRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntryPointRulesetVersionOptionsError() throws Throwable { + new GetZoneEntryPointRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptionsTest.java new file mode 100644 index 000000000..39489d22d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntryPointRulesetVersionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntryPointRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneEntryPointRulesetVersionsOptions model. + */ +public class GetZoneEntryPointRulesetVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneEntryPointRulesetVersionsOptions() throws Throwable { + GetZoneEntryPointRulesetVersionsOptions getZoneEntryPointRulesetVersionsOptionsModel = new GetZoneEntryPointRulesetVersionsOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + assertEquals(getZoneEntryPointRulesetVersionsOptionsModel.rulesetPhase(), "ddos_l4"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntryPointRulesetVersionsOptionsError() throws Throwable { + new GetZoneEntryPointRulesetVersionsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptionsTest.java new file mode 100644 index 000000000..f0cee7a6e --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneEntrypointRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneEntrypointRulesetOptions model. + */ +public class GetZoneEntrypointRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneEntrypointRulesetOptions() throws Throwable { + GetZoneEntrypointRulesetOptions getZoneEntrypointRulesetOptionsModel = new GetZoneEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .build(); + assertEquals(getZoneEntrypointRulesetOptionsModel.rulesetPhase(), "ddos_l4"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneEntrypointRulesetOptionsError() throws Throwable { + new GetZoneEntrypointRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptionsTest.java new file mode 100644 index 000000000..c808ad2a1 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneRulesetOptions model. + */ +public class GetZoneRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneRulesetOptions() throws Throwable { + GetZoneRulesetOptions getZoneRulesetOptionsModel = new GetZoneRulesetOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(getZoneRulesetOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetOptionsError() throws Throwable { + new GetZoneRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptionsTest.java new file mode 100644 index 000000000..d0646033b --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneRulesetVersionOptions model. + */ +public class GetZoneRulesetVersionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneRulesetVersionOptions() throws Throwable { + GetZoneRulesetVersionOptions getZoneRulesetVersionOptionsModel = new GetZoneRulesetVersionOptions.Builder() + .rulesetId("testString") + .rulesetVersion("1") + .build(); + assertEquals(getZoneRulesetVersionOptionsModel.rulesetId(), "testString"); + assertEquals(getZoneRulesetVersionOptionsModel.rulesetVersion(), "1"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetVersionOptionsError() throws Throwable { + new GetZoneRulesetVersionOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptionsTest.java new file mode 100644 index 000000000..87a1da920 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetVersionsOptionsTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetVersionsOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneRulesetVersionsOptions model. + */ +public class GetZoneRulesetVersionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneRulesetVersionsOptions() throws Throwable { + GetZoneRulesetVersionsOptions getZoneRulesetVersionsOptionsModel = new GetZoneRulesetVersionsOptions.Builder() + .rulesetId("testString") + .build(); + assertEquals(getZoneRulesetVersionsOptionsModel.rulesetId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetZoneRulesetVersionsOptionsError() throws Throwable { + new GetZoneRulesetVersionsOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptionsTest.java new file mode 100644 index 000000000..a8b6f8042 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/GetZoneRulesetsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.GetZoneRulesetsOptions; +import com.ibm.cloud.networking.rulesets.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 GetZoneRulesetsOptions model. + */ +public class GetZoneRulesetsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetZoneRulesetsOptions() throws Throwable { + GetZoneRulesetsOptions getZoneRulesetsOptionsModel = new GetZoneRulesetsOptions(); + assertNotNull(getZoneRulesetsOptionsModel); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsRespTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsRespTest.java new file mode 100644 index 000000000..21a3780b4 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListRulesetsRespTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ListRulesetsResp; +import com.ibm.cloud.networking.rulesets.v1.model.ListedRuleset; +import com.ibm.cloud.networking.rulesets.v1.model.Message; +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.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 ListRulesetsResp model. + */ +public class ListRulesetsRespTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListRulesetsResp() throws Throwable { + ListRulesetsResp listRulesetsRespModel = new ListRulesetsResp(); + assertNull(listRulesetsRespModel.isSuccess()); + assertNull(listRulesetsRespModel.getErrors()); + assertNull(listRulesetsRespModel.getMessages()); + assertNull(listRulesetsRespModel.getResult()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRulesetTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRulesetTest.java new file mode 100644 index 000000000..0450aee32 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/ListedRulesetTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ListedRuleset; +import com.ibm.cloud.networking.rulesets.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 ListedRuleset model. + */ +public class ListedRulesetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListedRuleset() throws Throwable { + ListedRuleset listedRulesetModel = new ListedRuleset(); + assertNull(listedRulesetModel.getDescription()); + assertNull(listedRulesetModel.getId()); + assertNull(listedRulesetModel.getKind()); + assertNull(listedRulesetModel.getLastUpdated()); + assertNull(listedRulesetModel.getName()); + assertNull(listedRulesetModel.getPhase()); + assertNull(listedRulesetModel.getVersion()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/LoggingTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/LoggingTest.java new file mode 100644 index 000000000..4c8ca38f6 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/LoggingTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.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 Logging model. + */ +public class LoggingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogging() throws Throwable { + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(loggingModel); + + Logging loggingModelNew = TestUtilities.deserialize(json, Logging.class); + assertTrue(loggingModelNew instanceof Logging); + assertEquals(loggingModelNew.enabled(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLoggingError() throws Throwable { + new Logging.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSourceTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSourceTest.java new file mode 100644 index 000000000..2a00d54d7 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageSourceTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.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 MessageSource model. + */ +public class MessageSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageSource() throws Throwable { + MessageSource messageSourceModel = new MessageSource(); + assertNull(messageSourceModel.getPointer()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageTest.java new file mode 100644 index 000000000..3c314c46a --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/MessageTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.Message; +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.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 Message model. + */ +public class MessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessage() throws Throwable { + Message messageModel = new Message(); + assertNull(messageModel.getCode()); + assertNull(messageModel.getMessage()); + assertNull(messageModel.getSource()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/OverridesTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/OverridesTest.java new file mode 100644 index 000000000..8f12a78b8 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/OverridesTest.java @@ -0,0 +1,79 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 Overrides model. + */ +public class OverridesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testOverrides() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + String json = TestUtilities.serialize(overridesModel); + + Overrides overridesModelNew = TestUtilities.deserialize(json, Overrides.class); + assertTrue(overridesModelNew instanceof Overrides); + assertEquals(overridesModelNew.action(), "testString"); + assertEquals(overridesModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModelNew.sensitivityLevel(), "high"); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/PositionTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/PositionTest.java new file mode 100644 index 000000000..f6f38890b --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/PositionTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.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 Position model. + */ +public class PositionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPosition() throws Throwable { + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + String json = TestUtilities.serialize(positionModel); + + Position positionModelNew = TestUtilities.deserialize(json, Position.class); + assertTrue(positionModelNew instanceof Position); + assertEquals(positionModelNew.before(), "testString"); + assertEquals(positionModelNew.after(), "testString"); + assertEquals(positionModelNew.index(), Long.valueOf("0")); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RatelimitTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RatelimitTest.java new file mode 100644 index 000000000..4a76c42d6 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RatelimitTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.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 Ratelimit model. + */ +public class RatelimitTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRatelimit() throws Throwable { + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + String json = TestUtilities.serialize(ratelimitModel); + + Ratelimit ratelimitModelNew = TestUtilities.deserialize(json, Ratelimit.class); + assertTrue(ratelimitModelNew instanceof Ratelimit); + assertEquals(ratelimitModelNew.countingExpression(), "testString"); + assertEquals(ratelimitModelNew.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModelNew.period(), Long.valueOf("26")); + assertEquals(ratelimitModelNew.requestsPerPeriod(), Long.valueOf("26")); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreateTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreateTest.java new file mode 100644 index 000000000..3c5323866 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleCreateTest.java @@ -0,0 +1,176 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 RuleCreate model. + */ +public class RuleCreateTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuleCreate() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(ruleCreateModel.action(), "testString"); + assertEquals(ruleCreateModel.actionParameters(), actionParametersModel); + assertEquals(ruleCreateModel.ratelimit(), ratelimitModel); + assertEquals(ruleCreateModel.description(), "testString"); + assertEquals(ruleCreateModel.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModel.id(), "testString"); + assertEquals(ruleCreateModel.logging(), loggingModel); + assertEquals(ruleCreateModel.ref(), "my_ref"); + assertEquals(ruleCreateModel.position(), positionModel); + + String json = TestUtilities.serialize(ruleCreateModel); + + RuleCreate ruleCreateModelNew = TestUtilities.deserialize(json, RuleCreate.class); + assertTrue(ruleCreateModelNew instanceof RuleCreate); + assertEquals(ruleCreateModelNew.action(), "testString"); + assertEquals(ruleCreateModelNew.actionParameters().toString(), actionParametersModel.toString()); + assertEquals(ruleCreateModelNew.ratelimit().toString(), ratelimitModel.toString()); + assertEquals(ruleCreateModelNew.description(), "testString"); + assertEquals(ruleCreateModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModelNew.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModelNew.id(), "testString"); + assertEquals(ruleCreateModelNew.logging().toString(), loggingModel.toString()); + assertEquals(ruleCreateModelNew.ref(), "my_ref"); + assertEquals(ruleCreateModelNew.position().toString(), positionModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuleCreateError() throws Throwable { + new RuleCreate.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetailsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetailsTest.java new file mode 100644 index 000000000..b39448f70 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleDetailsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RuleDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 RuleDetails model. + */ +public class RuleDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuleDetails() throws Throwable { + RuleDetails ruleDetailsModel = new RuleDetails(); + assertNull(ruleDetailsModel.getId()); + assertNull(ruleDetailsModel.getVersion()); + assertNull(ruleDetailsModel.getAction()); + assertNull(ruleDetailsModel.getActionParameters()); + assertNull(ruleDetailsModel.getCategories()); + assertNull(ruleDetailsModel.isEnabled()); + assertNull(ruleDetailsModel.getDescription()); + assertNull(ruleDetailsModel.getExpression()); + assertNull(ruleDetailsModel.getRef()); + assertNull(ruleDetailsModel.getLogging()); + assertNull(ruleDetailsModel.getLastUpdated()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleRespTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleRespTest.java new file mode 100644 index 000000000..e1e6afdd5 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RuleRespTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Message; +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RuleDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RuleResp; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 RuleResp model. + */ +public class RuleRespTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuleResp() throws Throwable { + RuleResp ruleRespModel = new RuleResp(); + assertNull(ruleRespModel.isSuccess()); + assertNull(ruleRespModel.getErrors()); + assertNull(ruleRespModel.getMessages()); + assertNull(ruleRespModel.getResult()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverrideTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverrideTest.java new file mode 100644 index 000000000..8fdc6b1ab --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesOverrideTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.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 RulesOverride model. + */ +public class RulesOverrideTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRulesOverride() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + String json = TestUtilities.serialize(rulesOverrideModel); + + RulesOverride rulesOverrideModelNew = TestUtilities.deserialize(json, RulesOverride.class); + assertTrue(rulesOverrideModelNew instanceof RulesOverride); + assertEquals(rulesOverrideModelNew.id(), "testString"); + assertEquals(rulesOverrideModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModelNew.action(), "testString"); + assertEquals(rulesOverrideModelNew.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModelNew.scoreThreshold(), Long.valueOf("60")); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetailsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetailsTest.java new file mode 100644 index 000000000..8df03908d --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetDetailsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RuleDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetDetails; +import com.ibm.cloud.networking.rulesets.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 RulesetDetails model. + */ +public class RulesetDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRulesetDetails() throws Throwable { + RulesetDetails rulesetDetailsModel = new RulesetDetails(); + assertNull(rulesetDetailsModel.getDescription()); + assertNull(rulesetDetailsModel.getId()); + assertNull(rulesetDetailsModel.getKind()); + assertNull(rulesetDetailsModel.getLastUpdated()); + assertNull(rulesetDetailsModel.getName()); + assertNull(rulesetDetailsModel.getPhase()); + assertNull(rulesetDetailsModel.getVersion()); + assertNull(rulesetDetailsModel.getRules()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetRespTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetRespTest.java new file mode 100644 index 000000000..e2eded6b6 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/RulesetRespTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Message; +import com.ibm.cloud.networking.rulesets.v1.model.MessageSource; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.RuleDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetDetails; +import com.ibm.cloud.networking.rulesets.v1.model.RulesetResp; +import com.ibm.cloud.networking.rulesets.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 RulesetResp model. + */ +public class RulesetRespTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRulesetResp() throws Throwable { + RulesetResp rulesetRespModel = new RulesetResp(); + assertNull(rulesetRespModel.isSuccess()); + assertNull(rulesetRespModel.getErrors()); + assertNull(rulesetRespModel.getMessages()); + assertNull(rulesetRespModel.getResult()); + } +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptionsTest.java new file mode 100644 index 000000000..c558bbe8b --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceEntrypointRulesetOptionsTest.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateInstanceEntrypointRulesetOptions model. + */ +public class UpdateInstanceEntrypointRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateInstanceEntrypointRulesetOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(ruleCreateModel.action(), "testString"); + assertEquals(ruleCreateModel.actionParameters(), actionParametersModel); + assertEquals(ruleCreateModel.ratelimit(), ratelimitModel); + assertEquals(ruleCreateModel.description(), "testString"); + assertEquals(ruleCreateModel.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModel.id(), "testString"); + assertEquals(ruleCreateModel.logging(), loggingModel); + assertEquals(ruleCreateModel.ref(), "my_ref"); + assertEquals(ruleCreateModel.position(), positionModel); + + UpdateInstanceEntrypointRulesetOptions updateInstanceEntrypointRulesetOptionsModel = new UpdateInstanceEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.rulesetPhase(), "ddos_l4"); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.description(), "Custom instance ruleset"); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.kind(), "managed"); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.name(), "testString"); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.phase(), "ddos_l4"); + assertEquals(updateInstanceEntrypointRulesetOptionsModel.rules(), java.util.Arrays.asList(ruleCreateModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceEntrypointRulesetOptionsError() throws Throwable { + new UpdateInstanceEntrypointRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptionsTest.java new file mode 100644 index 000000000..fa5b731bc --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetOptionsTest.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateInstanceRulesetOptions model. + */ +public class UpdateInstanceRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateInstanceRulesetOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(ruleCreateModel.action(), "testString"); + assertEquals(ruleCreateModel.actionParameters(), actionParametersModel); + assertEquals(ruleCreateModel.ratelimit(), ratelimitModel); + assertEquals(ruleCreateModel.description(), "testString"); + assertEquals(ruleCreateModel.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModel.id(), "testString"); + assertEquals(ruleCreateModel.logging(), loggingModel); + assertEquals(ruleCreateModel.ref(), "my_ref"); + assertEquals(ruleCreateModel.position(), positionModel); + + UpdateInstanceRulesetOptions updateInstanceRulesetOptionsModel = new UpdateInstanceRulesetOptions.Builder() + .rulesetId("testString") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + assertEquals(updateInstanceRulesetOptionsModel.rulesetId(), "testString"); + assertEquals(updateInstanceRulesetOptionsModel.description(), "Custom instance ruleset"); + assertEquals(updateInstanceRulesetOptionsModel.kind(), "managed"); + assertEquals(updateInstanceRulesetOptionsModel.name(), "testString"); + assertEquals(updateInstanceRulesetOptionsModel.phase(), "ddos_l4"); + assertEquals(updateInstanceRulesetOptionsModel.rules(), java.util.Arrays.asList(ruleCreateModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceRulesetOptionsError() throws Throwable { + new UpdateInstanceRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptionsTest.java new file mode 100644 index 000000000..1d854e685 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateInstanceRulesetRuleOptionsTest.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateInstanceRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateInstanceRulesetRuleOptions model. + */ +public class UpdateInstanceRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateInstanceRulesetRuleOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + UpdateInstanceRulesetRuleOptions updateInstanceRulesetRuleOptionsModel = new UpdateInstanceRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(updateInstanceRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(updateInstanceRulesetRuleOptionsModel.ruleId(), "testString"); + assertEquals(updateInstanceRulesetRuleOptionsModel.action(), "testString"); + assertEquals(updateInstanceRulesetRuleOptionsModel.actionParameters(), actionParametersModel); + assertEquals(updateInstanceRulesetRuleOptionsModel.ratelimit(), ratelimitModel); + assertEquals(updateInstanceRulesetRuleOptionsModel.description(), "testString"); + assertEquals(updateInstanceRulesetRuleOptionsModel.enabled(), Boolean.valueOf(true)); + assertEquals(updateInstanceRulesetRuleOptionsModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(updateInstanceRulesetRuleOptionsModel.id(), "testString"); + assertEquals(updateInstanceRulesetRuleOptionsModel.logging(), loggingModel); + assertEquals(updateInstanceRulesetRuleOptionsModel.ref(), "my_ref"); + assertEquals(updateInstanceRulesetRuleOptionsModel.position(), positionModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateInstanceRulesetRuleOptionsError() throws Throwable { + new UpdateInstanceRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptionsTest.java new file mode 100644 index 000000000..a9655c115 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneEntrypointRulesetOptionsTest.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneEntrypointRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateZoneEntrypointRulesetOptions model. + */ +public class UpdateZoneEntrypointRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateZoneEntrypointRulesetOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(ruleCreateModel.action(), "testString"); + assertEquals(ruleCreateModel.actionParameters(), actionParametersModel); + assertEquals(ruleCreateModel.ratelimit(), ratelimitModel); + assertEquals(ruleCreateModel.description(), "testString"); + assertEquals(ruleCreateModel.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModel.id(), "testString"); + assertEquals(ruleCreateModel.logging(), loggingModel); + assertEquals(ruleCreateModel.ref(), "my_ref"); + assertEquals(ruleCreateModel.position(), positionModel); + + UpdateZoneEntrypointRulesetOptions updateZoneEntrypointRulesetOptionsModel = new UpdateZoneEntrypointRulesetOptions.Builder() + .rulesetPhase("ddos_l4") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + assertEquals(updateZoneEntrypointRulesetOptionsModel.rulesetPhase(), "ddos_l4"); + assertEquals(updateZoneEntrypointRulesetOptionsModel.description(), "Custom instance ruleset"); + assertEquals(updateZoneEntrypointRulesetOptionsModel.kind(), "managed"); + assertEquals(updateZoneEntrypointRulesetOptionsModel.name(), "testString"); + assertEquals(updateZoneEntrypointRulesetOptionsModel.phase(), "ddos_l4"); + assertEquals(updateZoneEntrypointRulesetOptionsModel.rules(), java.util.Arrays.asList(ruleCreateModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneEntrypointRulesetOptionsError() throws Throwable { + new UpdateZoneEntrypointRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptionsTest.java new file mode 100644 index 000000000..bd8f8cbac --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetOptionsTest.java @@ -0,0 +1,177 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RuleCreate; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateZoneRulesetOptions model. + */ +public class UpdateZoneRulesetOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateZoneRulesetOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + RuleCreate ruleCreateModel = new RuleCreate.Builder() + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(ruleCreateModel.action(), "testString"); + assertEquals(ruleCreateModel.actionParameters(), actionParametersModel); + assertEquals(ruleCreateModel.ratelimit(), ratelimitModel); + assertEquals(ruleCreateModel.description(), "testString"); + assertEquals(ruleCreateModel.enabled(), Boolean.valueOf(true)); + assertEquals(ruleCreateModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(ruleCreateModel.id(), "testString"); + assertEquals(ruleCreateModel.logging(), loggingModel); + assertEquals(ruleCreateModel.ref(), "my_ref"); + assertEquals(ruleCreateModel.position(), positionModel); + + UpdateZoneRulesetOptions updateZoneRulesetOptionsModel = new UpdateZoneRulesetOptions.Builder() + .rulesetId("testString") + .description("Custom instance ruleset") + .kind("managed") + .name("testString") + .phase("ddos_l4") + .rules(java.util.Arrays.asList(ruleCreateModel)) + .build(); + assertEquals(updateZoneRulesetOptionsModel.rulesetId(), "testString"); + assertEquals(updateZoneRulesetOptionsModel.description(), "Custom instance ruleset"); + assertEquals(updateZoneRulesetOptionsModel.kind(), "managed"); + assertEquals(updateZoneRulesetOptionsModel.name(), "testString"); + assertEquals(updateZoneRulesetOptionsModel.phase(), "ddos_l4"); + assertEquals(updateZoneRulesetOptionsModel.rules(), java.util.Arrays.asList(ruleCreateModel)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneRulesetOptionsError() throws Throwable { + new UpdateZoneRulesetOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptionsTest.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptionsTest.java new file mode 100644 index 000000000..0cf905f06 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/model/UpdateZoneRulesetRuleOptionsTest.java @@ -0,0 +1,165 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.model; + +import com.ibm.cloud.networking.rulesets.v1.model.ActionParameters; +import com.ibm.cloud.networking.rulesets.v1.model.ActionParametersResponse; +import com.ibm.cloud.networking.rulesets.v1.model.CategoriesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.Logging; +import com.ibm.cloud.networking.rulesets.v1.model.Overrides; +import com.ibm.cloud.networking.rulesets.v1.model.Position; +import com.ibm.cloud.networking.rulesets.v1.model.Ratelimit; +import com.ibm.cloud.networking.rulesets.v1.model.RulesOverride; +import com.ibm.cloud.networking.rulesets.v1.model.UpdateZoneRulesetRuleOptions; +import com.ibm.cloud.networking.rulesets.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 UpdateZoneRulesetRuleOptions model. + */ +public class UpdateZoneRulesetRuleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateZoneRulesetRuleOptions() throws Throwable { + RulesOverride rulesOverrideModel = new RulesOverride.Builder() + .id("testString") + .enabled(true) + .action("testString") + .sensitivityLevel("high") + .scoreThreshold(Long.valueOf("60")) + .build(); + assertEquals(rulesOverrideModel.id(), "testString"); + assertEquals(rulesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(rulesOverrideModel.action(), "testString"); + assertEquals(rulesOverrideModel.sensitivityLevel(), "high"); + assertEquals(rulesOverrideModel.scoreThreshold(), Long.valueOf("60")); + + CategoriesOverride categoriesOverrideModel = new CategoriesOverride.Builder() + .category("testString") + .enabled(true) + .action("testString") + .build(); + assertEquals(categoriesOverrideModel.category(), "testString"); + assertEquals(categoriesOverrideModel.enabled(), Boolean.valueOf(true)); + assertEquals(categoriesOverrideModel.action(), "testString"); + + Overrides overridesModel = new Overrides.Builder() + .action("testString") + .enabled(true) + .sensitivityLevel("high") + .rules(java.util.Arrays.asList(rulesOverrideModel)) + .categories(java.util.Arrays.asList(categoriesOverrideModel)) + .build(); + assertEquals(overridesModel.action(), "testString"); + assertEquals(overridesModel.enabled(), Boolean.valueOf(true)); + assertEquals(overridesModel.sensitivityLevel(), "high"); + assertEquals(overridesModel.rules(), java.util.Arrays.asList(rulesOverrideModel)); + assertEquals(overridesModel.categories(), java.util.Arrays.asList(categoriesOverrideModel)); + + ActionParametersResponse actionParametersResponseModel = new ActionParametersResponse.Builder() + .content("{\"success\": false, \"error\": \"you have been blocked\"}") + .contentType("application/json") + .statusCode(Long.valueOf("400")) + .build(); + assertEquals(actionParametersResponseModel.content(), "{\"success\": false, \"error\": \"you have been blocked\"}"); + assertEquals(actionParametersResponseModel.contentType(), "application/json"); + assertEquals(actionParametersResponseModel.statusCode(), Long.valueOf("400")); + + ActionParameters actionParametersModel = new ActionParameters.Builder() + .id("testString") + .overrides(overridesModel) + .version("testString") + .ruleset("testString") + .rulesets(java.util.Arrays.asList("testString")) + .phases(java.util.Arrays.asList("testString")) + .products(java.util.Arrays.asList("testString")) + .response(actionParametersResponseModel) + .build(); + assertEquals(actionParametersModel.id(), "testString"); + assertEquals(actionParametersModel.overrides(), overridesModel); + assertEquals(actionParametersModel.version(), "testString"); + assertEquals(actionParametersModel.ruleset(), "testString"); + assertEquals(actionParametersModel.rulesets(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.phases(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.products(), java.util.Arrays.asList("testString")); + assertEquals(actionParametersModel.response(), actionParametersResponseModel); + + Ratelimit ratelimitModel = new Ratelimit.Builder() + .characteristics(java.util.Arrays.asList("testString")) + .countingExpression("testString") + .mitigationTimeout(Long.valueOf("26")) + .period(Long.valueOf("26")) + .requestsPerPeriod(Long.valueOf("26")) + .build(); + assertEquals(ratelimitModel.characteristics(), java.util.Arrays.asList("testString")); + assertEquals(ratelimitModel.countingExpression(), "testString"); + assertEquals(ratelimitModel.mitigationTimeout(), Long.valueOf("26")); + assertEquals(ratelimitModel.period(), Long.valueOf("26")); + assertEquals(ratelimitModel.requestsPerPeriod(), Long.valueOf("26")); + + Logging loggingModel = new Logging.Builder() + .enabled(true) + .build(); + assertEquals(loggingModel.enabled(), Boolean.valueOf(true)); + + Position positionModel = new Position.Builder() + .before("testString") + .after("testString") + .index(Long.valueOf("0")) + .build(); + assertEquals(positionModel.before(), "testString"); + assertEquals(positionModel.after(), "testString"); + assertEquals(positionModel.index(), Long.valueOf("0")); + + UpdateZoneRulesetRuleOptions updateZoneRulesetRuleOptionsModel = new UpdateZoneRulesetRuleOptions.Builder() + .rulesetId("testString") + .ruleId("testString") + .action("testString") + .actionParameters(actionParametersModel) + .ratelimit(ratelimitModel) + .description("testString") + .enabled(true) + .expression("ip.src ne 1.1.1.1") + .id("testString") + .logging(loggingModel) + .ref("my_ref") + .position(positionModel) + .build(); + assertEquals(updateZoneRulesetRuleOptionsModel.rulesetId(), "testString"); + assertEquals(updateZoneRulesetRuleOptionsModel.ruleId(), "testString"); + assertEquals(updateZoneRulesetRuleOptionsModel.action(), "testString"); + assertEquals(updateZoneRulesetRuleOptionsModel.actionParameters(), actionParametersModel); + assertEquals(updateZoneRulesetRuleOptionsModel.ratelimit(), ratelimitModel); + assertEquals(updateZoneRulesetRuleOptionsModel.description(), "testString"); + assertEquals(updateZoneRulesetRuleOptionsModel.enabled(), Boolean.valueOf(true)); + assertEquals(updateZoneRulesetRuleOptionsModel.expression(), "ip.src ne 1.1.1.1"); + assertEquals(updateZoneRulesetRuleOptionsModel.id(), "testString"); + assertEquals(updateZoneRulesetRuleOptionsModel.logging(), loggingModel); + assertEquals(updateZoneRulesetRuleOptionsModel.ref(), "my_ref"); + assertEquals(updateZoneRulesetRuleOptionsModel.position(), positionModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateZoneRulesetRuleOptionsError() throws Throwable { + new UpdateZoneRulesetRuleOptions.Builder().build(); + } + +} \ No newline at end of file diff --git a/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/utils/TestUtilities.java b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/utils/TestUtilities.java new file mode 100644 index 000000000..2fc3d0f92 --- /dev/null +++ b/modules/rulesets/src/test/java/com/ibm/cloud/networking/rulesets/v1/utils/TestUtilities.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2025. + * + * 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.rulesets.v1.utils; + +import java.util.Base64; +import java.util.Map; +import java.util.Set; +import java.util.List; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.io.InputStream; +import java.io.ByteArrayInputStream; + +import okhttp3.mockwebserver.RecordedRequest; +import okhttp3.HttpUrl; +import com.ibm.cloud.sdk.core.util.DateUtils; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; + +/** + * A class used by the unit tests containing utility functions. + */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { put("key1", createMockStream("This is a mock file.")); } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String encodedString) throws Exception { + return Base64.getDecoder().decode(encodedString); + } + + public static Date createMockDate(String date) throws Exception { + return DateUtils.parseAsDate(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return DateUtils.parseAsDateTime(date); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 28682522b..d011077df 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ modules/firewall-rules modules/webhooks modules/alerts + modules/rulesets modules/coverage-reports