diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 838f5745fd5..ad11665c837 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -14597,6 +14597,61 @@ components: oneOf: - $ref: '#/components/schemas/SyntheticsAPITestStep' - $ref: '#/components/schemas/SyntheticsAPIWaitStep' + - $ref: '#/components/schemas/SyntheticsAPISubtestStep' + SyntheticsAPISubtestStep: + description: The subtest step used in a Synthetics multi-step API test. + properties: + allowFailure: + description: Determines whether or not to continue with test if this step + fails. + type: boolean + alwaysExecute: + description: A boolean set to always execute this step even if the previous + step failed or was skipped. + type: boolean + exitIfSucceed: + description: Determines whether or not to exit the test if the step succeeds. + type: boolean + extractedValuesFromScript: + description: Generate variables using JavaScript. + type: string + id: + description: ID of the step. + example: abc-def-123 + readOnly: true + type: string + isCritical: + description: 'Determines whether or not to consider the entire test as failed + if this step fails. + + Can be used only if `allowFailure` is `true`.' + type: boolean + name: + description: The name of the step. + example: Example step name + type: string + retry: + $ref: '#/components/schemas/SyntheticsTestOptionsRetry' + subtestPublicId: + description: Public ID of the test to be played as part of a `playSubTest` + step type. + example: '' + type: string + subtype: + $ref: '#/components/schemas/SyntheticsAPISubtestStepSubtype' + required: + - name + - subtype + - subtestPublicId + type: object + SyntheticsAPISubtestStepSubtype: + description: The subtype of the Synthetic multi-step API subtest step. + enum: + - playSubTest + example: playSubTest + type: string + x-enum-varnames: + - PLAY_SUB_TEST SyntheticsAPITest: description: Object containing details about a Synthetic API test. properties: diff --git a/examples/v1/synthetics/CreateSyntheticsAPITest_2106135939.java b/examples/v1/synthetics/CreateSyntheticsAPITest_2106135939.java new file mode 100644 index 00000000000..a59f96d015f --- /dev/null +++ b/examples/v1/synthetics/CreateSyntheticsAPITest_2106135939.java @@ -0,0 +1,86 @@ +// Create a multistep test with subtest returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.SyntheticsApi; +import com.datadog.api.client.v1.model.SyntheticsAPIStep; +import com.datadog.api.client.v1.model.SyntheticsAPISubtestStep; +import com.datadog.api.client.v1.model.SyntheticsAPISubtestStepSubtype; +import com.datadog.api.client.v1.model.SyntheticsAPITest; +import com.datadog.api.client.v1.model.SyntheticsAPITestConfig; +import com.datadog.api.client.v1.model.SyntheticsAPITestStep; +import com.datadog.api.client.v1.model.SyntheticsAPITestStepSubtype; +import com.datadog.api.client.v1.model.SyntheticsAPITestType; +import com.datadog.api.client.v1.model.SyntheticsAssertion; +import com.datadog.api.client.v1.model.SyntheticsAssertionOperator; +import com.datadog.api.client.v1.model.SyntheticsAssertionTarget; +import com.datadog.api.client.v1.model.SyntheticsAssertionTargetValue; +import com.datadog.api.client.v1.model.SyntheticsAssertionType; +import com.datadog.api.client.v1.model.SyntheticsBasicAuth; +import com.datadog.api.client.v1.model.SyntheticsBasicAuthWeb; +import com.datadog.api.client.v1.model.SyntheticsTestDetailsSubType; +import com.datadog.api.client.v1.model.SyntheticsTestOptions; +import com.datadog.api.client.v1.model.SyntheticsTestRequest; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SyntheticsApi apiInstance = new SyntheticsApi(defaultClient); + + // there is a valid "synthetics_api_test" in the system + String SYNTHETICS_API_TEST_PUBLIC_ID = System.getenv("SYNTHETICS_API_TEST_PUBLIC_ID"); + + SyntheticsAPITest body = + new SyntheticsAPITest() + .config( + new SyntheticsAPITestConfig() + .steps( + Arrays.asList( + new SyntheticsAPIStep( + new SyntheticsAPITestStep() + .assertions( + Collections.singletonList( + new SyntheticsAssertion( + new SyntheticsAssertionTarget() + .operator(SyntheticsAssertionOperator.IS) + .type(SyntheticsAssertionType.STATUS_CODE) + .target( + new SyntheticsAssertionTargetValue( + 200.0))))) + .name("request is sent") + .request( + new SyntheticsTestRequest() + .url("https://httpbin.org/status/200") + .method("GET") + .basicAuth( + new SyntheticsBasicAuth( + new SyntheticsBasicAuthWeb() + .password("password") + .username("username")))) + .subtype(SyntheticsAPITestStepSubtype.HTTP)), + new SyntheticsAPIStep( + new SyntheticsAPISubtestStep() + .subtype(SyntheticsAPISubtestStepSubtype.PLAY_SUB_TEST) + .subtestPublicId(SYNTHETICS_API_TEST_PUBLIC_ID) + .name("subtest step"))))) + .locations(Collections.singletonList("aws:us-east-2")) + .message("BDD test payload: synthetics_api_test_multi_step_with_subtest.json") + .name("Example-Synthetic") + .options(new SyntheticsTestOptions().tickEvery(60L)) + .subtype(SyntheticsTestDetailsSubType.MULTI) + .type(SyntheticsAPITestType.API); + + try { + SyntheticsAPITest result = apiInstance.createSyntheticsAPITest(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SyntheticsApi#createSyntheticsAPITest"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPIStep.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPIStep.java index 1f489c2da58..e716222e7d0 100644 --- a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPIStep.java +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPIStep.java @@ -167,6 +167,51 @@ public SyntheticsAPIStep deserialize(JsonParser jp, DeserializationContext ctxt) log.log(Level.FINER, "Input data does not match schema 'SyntheticsAPIWaitStep'", e); } + // deserialize SyntheticsAPISubtestStep + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SyntheticsAPISubtestStep.class.equals(Integer.class) + || SyntheticsAPISubtestStep.class.equals(Long.class) + || SyntheticsAPISubtestStep.class.equals(Float.class) + || SyntheticsAPISubtestStep.class.equals(Double.class) + || SyntheticsAPISubtestStep.class.equals(Boolean.class) + || SyntheticsAPISubtestStep.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SyntheticsAPISubtestStep.class.equals(Integer.class) + || SyntheticsAPISubtestStep.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SyntheticsAPISubtestStep.class.equals(Float.class) + || SyntheticsAPISubtestStep.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (SyntheticsAPISubtestStep.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SyntheticsAPISubtestStep.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(SyntheticsAPISubtestStep.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((SyntheticsAPISubtestStep) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'SyntheticsAPISubtestStep'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SyntheticsAPISubtestStep'", e); + } + SyntheticsAPIStep ret = new SyntheticsAPIStep(); if (match == 1) { ret.setActualInstance(deserialized); @@ -205,9 +250,15 @@ public SyntheticsAPIStep(SyntheticsAPIWaitStep o) { setActualInstance(o); } + public SyntheticsAPIStep(SyntheticsAPISubtestStep o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("SyntheticsAPITestStep", new GenericType() {}); schemas.put("SyntheticsAPIWaitStep", new GenericType() {}); + schemas.put("SyntheticsAPISubtestStep", new GenericType() {}); JSON.registerDescendants(SyntheticsAPIStep.class, Collections.unmodifiableMap(schemas)); } @@ -218,7 +269,8 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: SyntheticsAPITestStep, SyntheticsAPIWaitStep + * against the oneOf child schemas: SyntheticsAPITestStep, SyntheticsAPIWaitStep, + * SyntheticsAPISubtestStep * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -233,20 +285,26 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(SyntheticsAPISubtestStep.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); return; } throw new RuntimeException( - "Invalid instance type. Must be SyntheticsAPITestStep, SyntheticsAPIWaitStep"); + "Invalid instance type. Must be SyntheticsAPITestStep, SyntheticsAPIWaitStep," + + " SyntheticsAPISubtestStep"); } /** * Get the actual instance, which can be the following: SyntheticsAPITestStep, - * SyntheticsAPIWaitStep + * SyntheticsAPIWaitStep, SyntheticsAPISubtestStep * - * @return The actual instance (SyntheticsAPITestStep, SyntheticsAPIWaitStep) + * @return The actual instance (SyntheticsAPITestStep, SyntheticsAPIWaitStep, + * SyntheticsAPISubtestStep) */ @Override public Object getActualInstance() { @@ -274,4 +332,15 @@ public SyntheticsAPITestStep getSyntheticsAPITestStep() throws ClassCastExceptio public SyntheticsAPIWaitStep getSyntheticsAPIWaitStep() throws ClassCastException { return (SyntheticsAPIWaitStep) super.getActualInstance(); } + + /** + * Get the actual instance of `SyntheticsAPISubtestStep`. If the actual instance is not + * `SyntheticsAPISubtestStep`, the ClassCastException will be thrown. + * + * @return The actual instance of `SyntheticsAPISubtestStep` + * @throws ClassCastException if the instance is not `SyntheticsAPISubtestStep` + */ + public SyntheticsAPISubtestStep getSyntheticsAPISubtestStep() throws ClassCastException { + return (SyntheticsAPISubtestStep) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStep.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStep.java new file mode 100644 index 00000000000..ea8561fc915 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStep.java @@ -0,0 +1,405 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The subtest step used in a Synthetics multi-step API test. */ +@JsonPropertyOrder({ + SyntheticsAPISubtestStep.JSON_PROPERTY_ALLOW_FAILURE, + SyntheticsAPISubtestStep.JSON_PROPERTY_ALWAYS_EXECUTE, + SyntheticsAPISubtestStep.JSON_PROPERTY_EXIT_IF_SUCCEED, + SyntheticsAPISubtestStep.JSON_PROPERTY_EXTRACTED_VALUES_FROM_SCRIPT, + SyntheticsAPISubtestStep.JSON_PROPERTY_ID, + SyntheticsAPISubtestStep.JSON_PROPERTY_IS_CRITICAL, + SyntheticsAPISubtestStep.JSON_PROPERTY_NAME, + SyntheticsAPISubtestStep.JSON_PROPERTY_RETRY, + SyntheticsAPISubtestStep.JSON_PROPERTY_SUBTEST_PUBLIC_ID, + SyntheticsAPISubtestStep.JSON_PROPERTY_SUBTYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SyntheticsAPISubtestStep { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ALLOW_FAILURE = "allowFailure"; + private Boolean allowFailure; + + public static final String JSON_PROPERTY_ALWAYS_EXECUTE = "alwaysExecute"; + private Boolean alwaysExecute; + + public static final String JSON_PROPERTY_EXIT_IF_SUCCEED = "exitIfSucceed"; + private Boolean exitIfSucceed; + + public static final String JSON_PROPERTY_EXTRACTED_VALUES_FROM_SCRIPT = + "extractedValuesFromScript"; + private String extractedValuesFromScript; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_IS_CRITICAL = "isCritical"; + private Boolean isCritical; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_RETRY = "retry"; + private SyntheticsTestOptionsRetry retry; + + public static final String JSON_PROPERTY_SUBTEST_PUBLIC_ID = "subtestPublicId"; + private String subtestPublicId; + + public static final String JSON_PROPERTY_SUBTYPE = "subtype"; + private SyntheticsAPISubtestStepSubtype subtype; + + public SyntheticsAPISubtestStep() {} + + @JsonCreator + public SyntheticsAPISubtestStep( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SUBTEST_PUBLIC_ID) + String subtestPublicId, + @JsonProperty(required = true, value = JSON_PROPERTY_SUBTYPE) + SyntheticsAPISubtestStepSubtype subtype) { + this.name = name; + this.subtestPublicId = subtestPublicId; + this.subtype = subtype; + this.unparsed |= !subtype.isValid(); + } + + public SyntheticsAPISubtestStep allowFailure(Boolean allowFailure) { + this.allowFailure = allowFailure; + return this; + } + + /** + * Determines whether or not to continue with test if this step fails. + * + * @return allowFailure + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ALLOW_FAILURE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getAllowFailure() { + return allowFailure; + } + + public void setAllowFailure(Boolean allowFailure) { + this.allowFailure = allowFailure; + } + + public SyntheticsAPISubtestStep alwaysExecute(Boolean alwaysExecute) { + this.alwaysExecute = alwaysExecute; + return this; + } + + /** + * A boolean set to always execute this step even if the previous step failed or was skipped. + * + * @return alwaysExecute + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ALWAYS_EXECUTE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getAlwaysExecute() { + return alwaysExecute; + } + + public void setAlwaysExecute(Boolean alwaysExecute) { + this.alwaysExecute = alwaysExecute; + } + + public SyntheticsAPISubtestStep exitIfSucceed(Boolean exitIfSucceed) { + this.exitIfSucceed = exitIfSucceed; + return this; + } + + /** + * Determines whether or not to exit the test if the step succeeds. + * + * @return exitIfSucceed + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXIT_IF_SUCCEED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getExitIfSucceed() { + return exitIfSucceed; + } + + public void setExitIfSucceed(Boolean exitIfSucceed) { + this.exitIfSucceed = exitIfSucceed; + } + + public SyntheticsAPISubtestStep extractedValuesFromScript(String extractedValuesFromScript) { + this.extractedValuesFromScript = extractedValuesFromScript; + return this; + } + + /** + * Generate variables using JavaScript. + * + * @return extractedValuesFromScript + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXTRACTED_VALUES_FROM_SCRIPT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getExtractedValuesFromScript() { + return extractedValuesFromScript; + } + + public void setExtractedValuesFromScript(String extractedValuesFromScript) { + this.extractedValuesFromScript = extractedValuesFromScript; + } + + /** + * ID of the step. + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public SyntheticsAPISubtestStep isCritical(Boolean isCritical) { + this.isCritical = isCritical; + return this; + } + + /** + * Determines whether or not to consider the entire test as failed if this step fails. Can be used + * only if allowFailure is true. + * + * @return isCritical + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_IS_CRITICAL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getIsCritical() { + return isCritical; + } + + public void setIsCritical(Boolean isCritical) { + this.isCritical = isCritical; + } + + public SyntheticsAPISubtestStep name(String name) { + this.name = name; + return this; + } + + /** + * The name of the step. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public SyntheticsAPISubtestStep retry(SyntheticsTestOptionsRetry retry) { + this.retry = retry; + this.unparsed |= retry.unparsed; + return this; + } + + /** + * Object describing the retry strategy to apply to a Synthetic test. + * + * @return retry + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RETRY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SyntheticsTestOptionsRetry getRetry() { + return retry; + } + + public void setRetry(SyntheticsTestOptionsRetry retry) { + this.retry = retry; + } + + public SyntheticsAPISubtestStep subtestPublicId(String subtestPublicId) { + this.subtestPublicId = subtestPublicId; + return this; + } + + /** + * Public ID of the test to be played as part of a playSubTest step type. + * + * @return subtestPublicId + */ + @JsonProperty(JSON_PROPERTY_SUBTEST_PUBLIC_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSubtestPublicId() { + return subtestPublicId; + } + + public void setSubtestPublicId(String subtestPublicId) { + this.subtestPublicId = subtestPublicId; + } + + public SyntheticsAPISubtestStep subtype(SyntheticsAPISubtestStepSubtype subtype) { + this.subtype = subtype; + this.unparsed |= !subtype.isValid(); + return this; + } + + /** + * The subtype of the Synthetic multi-step API subtest step. + * + * @return subtype + */ + @JsonProperty(JSON_PROPERTY_SUBTYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SyntheticsAPISubtestStepSubtype getSubtype() { + return subtype; + } + + public void setSubtype(SyntheticsAPISubtestStepSubtype subtype) { + if (!subtype.isValid()) { + this.unparsed = true; + } + this.subtype = subtype; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SyntheticsAPISubtestStep + */ + @JsonAnySetter + public SyntheticsAPISubtestStep putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SyntheticsAPISubtestStep object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SyntheticsAPISubtestStep syntheticsApiSubtestStep = (SyntheticsAPISubtestStep) o; + return Objects.equals(this.allowFailure, syntheticsApiSubtestStep.allowFailure) + && Objects.equals(this.alwaysExecute, syntheticsApiSubtestStep.alwaysExecute) + && Objects.equals(this.exitIfSucceed, syntheticsApiSubtestStep.exitIfSucceed) + && Objects.equals( + this.extractedValuesFromScript, syntheticsApiSubtestStep.extractedValuesFromScript) + && Objects.equals(this.id, syntheticsApiSubtestStep.id) + && Objects.equals(this.isCritical, syntheticsApiSubtestStep.isCritical) + && Objects.equals(this.name, syntheticsApiSubtestStep.name) + && Objects.equals(this.retry, syntheticsApiSubtestStep.retry) + && Objects.equals(this.subtestPublicId, syntheticsApiSubtestStep.subtestPublicId) + && Objects.equals(this.subtype, syntheticsApiSubtestStep.subtype) + && Objects.equals(this.additionalProperties, syntheticsApiSubtestStep.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + allowFailure, + alwaysExecute, + exitIfSucceed, + extractedValuesFromScript, + id, + isCritical, + name, + retry, + subtestPublicId, + subtype, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SyntheticsAPISubtestStep {\n"); + sb.append(" allowFailure: ").append(toIndentedString(allowFailure)).append("\n"); + sb.append(" alwaysExecute: ").append(toIndentedString(alwaysExecute)).append("\n"); + sb.append(" exitIfSucceed: ").append(toIndentedString(exitIfSucceed)).append("\n"); + sb.append(" extractedValuesFromScript: ") + .append(toIndentedString(extractedValuesFromScript)) + .append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" isCritical: ").append(toIndentedString(isCritical)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" retry: ").append(toIndentedString(retry)).append("\n"); + sb.append(" subtestPublicId: ").append(toIndentedString(subtestPublicId)).append("\n"); + sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStepSubtype.java b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStepSubtype.java new file mode 100644 index 00000000000..70b11a6d48a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/SyntheticsAPISubtestStepSubtype.java @@ -0,0 +1,58 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The subtype of the Synthetic multi-step API subtest step. */ +@JsonSerialize( + using = SyntheticsAPISubtestStepSubtype.SyntheticsAPISubtestStepSubtypeSerializer.class) +public class SyntheticsAPISubtestStepSubtype extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("playSubTest")); + + public static final SyntheticsAPISubtestStepSubtype PLAY_SUB_TEST = + new SyntheticsAPISubtestStepSubtype("playSubTest"); + + SyntheticsAPISubtestStepSubtype(String value) { + super(value, allowedValues); + } + + public static class SyntheticsAPISubtestStepSubtypeSerializer + extends StdSerializer { + public SyntheticsAPISubtestStepSubtypeSerializer(Class t) { + super(t); + } + + public SyntheticsAPISubtestStepSubtypeSerializer() { + this(null); + } + + @Override + public void serialize( + SyntheticsAPISubtestStepSubtype value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static SyntheticsAPISubtestStepSubtype fromValue(String value) { + return new SyntheticsAPISubtestStepSubtype(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature b/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature index 4d3e23061ae..25b209f05ad 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature @@ -169,6 +169,14 @@ Feature: Synthetics And the response "config.steps[5].request.basicAuth.type" is equal to "oauth-client" And the response "config.steps[6].request.basicAuth.type" is equal to "oauth-rop" + @team:DataDog/synthetics-managing + Scenario: Create a multistep test with subtest returns "OK" response + Given there is a valid "synthetics_api_test" in the system + And new "CreateSyntheticsAPITest" request + And body from file "synthetics_api_test_multi_step_with_subtest.json" + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/synthetics-managing Scenario: Create a private location returns "OK" response Given there is a valid "role" in the system diff --git a/src/test/resources/com/datadog/api/client/v1/api/synthetics_api_test_multi_step_with_subtest.json b/src/test/resources/com/datadog/api/client/v1/api/synthetics_api_test_multi_step_with_subtest.json new file mode 100644 index 00000000000..5d7375c18ad --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v1/api/synthetics_api_test_multi_step_with_subtest.json @@ -0,0 +1,38 @@ +{ + "config": { + "steps": [ + { + "assertions": [ + { + "operator": "is", + "type": "statusCode", + "target": 200 + } + ], + "name": "request is sent", + "request": { + "url": "https://httpbin.org/status/200", + "method": "GET", + "basicAuth": { + "password": "password", + "username": "username" + } + }, + "subtype": "http" + }, + { + "subtype": "playSubTest", + "subtestPublicId": "{{ synthetics_api_test.public_id }}", + "name": "subtest step" + } + ] + }, + "locations": ["aws:us-east-2"], + "message": "BDD test payload: synthetics_api_test_multi_step_with_subtest.json", + "name": "{{ unique }}", + "options": { + "tick_every": 60 + }, + "subtype": "multi", + "type": "api" +}