From 92da49a5aae6759eb4267de551b64e71703f2760 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 29 Mar 2023 13:53:42 +0000 Subject: [PATCH] Regenerate client from commit 1f3268e7 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 205 ++++++++ .../CreateOrUpdateServiceDefinitions.java | 73 ++- ...OrUpdateServiceDefinitions_1808735248.java | 85 ++++ ...OrUpdateServiceDefinitions_2619874414.java | 84 ++++ .../v2/model/ServiceDefinitionSchema.java | 77 ++- .../v2/model/ServiceDefinitionV2Dot1.java | 454 ++++++++++++++++++ .../model/ServiceDefinitionV2Dot1Contact.java | 287 +++++++++++ .../model/ServiceDefinitionV2Dot1Email.java | 152 ++++++ .../ServiceDefinitionV2Dot1EmailType.java | 95 ++++ .../ServiceDefinitionV2Dot1Integrations.java | 113 +++++ .../v2/model/ServiceDefinitionV2Dot1Link.java | 180 +++++++ .../ServiceDefinitionV2Dot1LinkType.java | 104 ++++ .../ServiceDefinitionV2Dot1Opsgenie.java | 123 +++++ ...ServiceDefinitionV2Dot1OpsgenieRegion.java | 101 ++++ .../ServiceDefinitionV2Dot1Pagerduty.java | 82 ++++ .../model/ServiceDefinitionV2Dot1Slack.java | 152 ++++++ .../ServiceDefinitionV2Dot1SlackType.java | 95 ++++ .../model/ServiceDefinitionV2Dot1Version.java | 95 ++++ .../ServiceDefinitionsCreateRequest.java | 76 ++- ...definition_returns_CREATED_response.freeze | 2 +- ...e_definition_returns_CREATED_response.json | 10 +- ...chema_v2_1_returns_CREATED_response.freeze | 1 + ..._schema_v2_1_returns_CREATED_response.json | 58 +++ ..._schema_v2_returns_CREATED_response.freeze | 1 + ...ng_schema_v2_returns_CREATED_response.json | 58 +++ .../com/datadog/api/client/v2/api/given.json | 2 +- .../client/v2/api/service_definition.feature | 48 +- 28 files changed, 2746 insertions(+), 75 deletions(-) create mode 100644 examples/v2/service-definition/CreateOrUpdateServiceDefinitions_1808735248.java create mode 100644 examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2619874414.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Contact.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Email.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1EmailType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Integrations.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Link.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1LinkType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Opsgenie.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1OpsgenieRegion.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Pagerduty.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Slack.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1SlackType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Version.java create mode 100644 src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.json create mode 100644 src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.freeze create mode 100644 src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.json diff --git a/.apigentools-info b/.apigentools-info index 2b41be34ac9..ca9ac0cb4e7 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-28 08:41:49.652997", - "spec_repo_commit": "21917b12" + "regenerated": "2023-03-29 13:52:23.932412", + "spec_repo_commit": "1f3268e7" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-28 08:41:49.665061", - "spec_repo_commit": "21917b12" + "regenerated": "2023-03-29 13:52:23.944728", + "spec_repo_commit": "1f3268e7" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 68d43313a33..8a8b63be81e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -12101,6 +12101,7 @@ components: oneOf: - $ref: '#/components/schemas/ServiceDefinitionV1' - $ref: '#/components/schemas/ServiceDefinitionV2' + - $ref: '#/components/schemas/ServiceDefinitionV2Dot1' type: object ServiceDefinitionV1: deprecated: true @@ -12331,6 +12332,209 @@ components: - name - url type: object + ServiceDefinitionV2Dot1: + description: Service definition v2.1 for providing service metadata and integrations. + properties: + application: + description: Identifier for a group of related services serving a product + feature, which the service is a part of. + example: my-app + type: string + contacts: + description: A list of contacts related to the services. + items: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Contact' + type: array + dd-service: + description: Unique identifier of the service. Must be unique across all + services and is used to match with a service in Datadog. + example: my-service + type: string + description: + description: A short description of the service. + example: My service description + type: string + extensions: + additionalProperties: {} + description: Extensions to v2.1 schema. + example: + myorg/extension: extensionValue + type: object + integrations: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Integrations' + lifecycle: + description: The current life cycle phase of the service. + example: sandbox + type: string + links: + description: A list of links related to the services. + items: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Link' + type: array + schema-version: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Version' + tags: + description: A set of custom tags. + example: + - my:tag + - service:tag + items: + type: string + type: array + team: + description: Team that owns the service. It is used to locate a team defined + in Datadog Teams if it exists. + example: my-team + type: string + tier: + description: Importance of the service. + example: High + type: string + required: + - schema-version + - dd-service + type: object + ServiceDefinitionV2Dot1Contact: + description: Service owner's contacts information. + oneOf: + - $ref: '#/components/schemas/ServiceDefinitionV2Dot1Email' + - $ref: '#/components/schemas/ServiceDefinitionV2Dot1Slack' + ServiceDefinitionV2Dot1Email: + description: Service owner's email. + properties: + contact: + description: Contact value. + example: contact@datadoghq.com + format: email + type: string + name: + description: Contact email. + example: Team Email + type: string + type: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1EmailType' + required: + - type + - contact + type: object + ServiceDefinitionV2Dot1EmailType: + description: Contact type. + enum: + - email + example: email + type: string + x-enum-varnames: + - EMAIL + ServiceDefinitionV2Dot1Integrations: + description: Third party integrations that Datadog supports. + properties: + opsgenie: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Opsgenie' + pagerduty: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1Pagerduty' + type: object + ServiceDefinitionV2Dot1Link: + description: Service's external links. + properties: + name: + description: Link name. + example: Runbook + type: string + provider: + description: Link provider. + example: Github + type: string + type: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1LinkType' + url: + description: Link URL. + example: https://my-runbook + type: string + required: + - name + - type + - url + type: object + ServiceDefinitionV2Dot1LinkType: + description: Link type. + enum: + - doc + - repo + - runbook + - dashboard + - other + example: runbook + type: string + x-enum-varnames: + - DOC + - REPO + - RUNBOOK + - DASHBOARD + - OTHER + ServiceDefinitionV2Dot1Opsgenie: + description: Opsgenie integration for the service. + properties: + region: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1OpsgenieRegion' + service-url: + description: Opsgenie service url. + example: https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000 + type: string + required: + - service-url + type: object + ServiceDefinitionV2Dot1OpsgenieRegion: + description: Opsgenie instance region. + enum: + - US + - EU + example: US + type: string + x-enum-varnames: + - US + - EU + ServiceDefinitionV2Dot1Pagerduty: + description: PagerDuty integration for the service. + properties: + service-url: + description: PagerDuty service url. + example: https://my-org.pagerduty.com/service-directory/PMyService + type: string + type: object + ServiceDefinitionV2Dot1Slack: + description: Service owner's Slack channel. + properties: + contact: + description: Slack Channel. + example: https://yourcompany.slack.com/archives/channel123 + type: string + name: + description: Contact Slack. + example: Team Slack + type: string + type: + $ref: '#/components/schemas/ServiceDefinitionV2Dot1SlackType' + required: + - type + - contact + type: object + ServiceDefinitionV2Dot1SlackType: + description: Contact type. + enum: + - slack + example: slack + type: string + x-enum-varnames: + - SLACK + ServiceDefinitionV2Dot1Version: + default: v2.1 + description: Schema version being used. + enum: + - v2.1 + example: v2.1 + type: string + x-enum-varnames: + - V2_1 ServiceDefinitionV2Email: description: Service owner's email. properties: @@ -12489,6 +12693,7 @@ components: ServiceDefinitionsCreateRequest: description: Create service definitions request. oneOf: + - $ref: '#/components/schemas/ServiceDefinitionV2Dot1' - $ref: '#/components/schemas/ServiceDefinitionV2' - $ref: '#/components/schemas/ServiceDefinitionRaw' ServiceDefinitionsListResponse: diff --git a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java index 3af461035b0..8677319775c 100644 --- a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java +++ b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java @@ -4,18 +4,17 @@ import com.datadog.api.client.ApiException; import com.datadog.api.client.v2.api.ServiceDefinitionApi; import com.datadog.api.client.v2.model.ServiceDefinitionCreateResponse; -import com.datadog.api.client.v2.model.ServiceDefinitionV2; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Contact; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Doc; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Email; -import com.datadog.api.client.v2.model.ServiceDefinitionV2EmailType; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Integrations; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Link; -import com.datadog.api.client.v2.model.ServiceDefinitionV2LinkType; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Opsgenie; -import com.datadog.api.client.v2.model.ServiceDefinitionV2OpsgenieRegion; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Repo; -import com.datadog.api.client.v2.model.ServiceDefinitionV2Version; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Contact; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Email; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1EmailType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Integrations; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Link; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1LinkType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Opsgenie; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1OpsgenieRegion; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Pagerduty; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Version; import com.datadog.api.client.v2.model.ServiceDefinitionsCreateRequest; import java.util.Arrays; import java.util.Collections; @@ -28,47 +27,41 @@ public static void main(String[] args) { ServiceDefinitionsCreateRequest body = new ServiceDefinitionsCreateRequest( - new ServiceDefinitionV2() + new ServiceDefinitionV2Dot1() + .application("my-app") .contacts( Collections.singletonList( - new ServiceDefinitionV2Contact( - new ServiceDefinitionV2Email() + new ServiceDefinitionV2Dot1Contact( + new ServiceDefinitionV2Dot1Email() .contact("contact@datadoghq.com") .name("Team Email") - .type(ServiceDefinitionV2EmailType.EMAIL)))) - .ddService( - "service-Example-Create_or_update_service_definition_returns_CREATED_response") - .ddTeam("my-team") - .docs( - Collections.singletonList( - new ServiceDefinitionV2Doc() - .name("Architecture") - .provider("google drive") - .url("https://gdrive/mydoc"))) - .extensions(Map.ofEntries(Map.entry("myorgextension", "extensionvalue"))) + .type(ServiceDefinitionV2Dot1EmailType.EMAIL)))) + .ddService("my-service") + .description("My service description") + .extensions(Map.ofEntries(Map.entry("myorg/extension", "extensionValue"))) .integrations( - new ServiceDefinitionV2Integrations() + new ServiceDefinitionV2Dot1Integrations() .opsgenie( - new ServiceDefinitionV2Opsgenie() - .region(ServiceDefinitionV2OpsgenieRegion.US) + new ServiceDefinitionV2Dot1Opsgenie() + .region(ServiceDefinitionV2Dot1OpsgenieRegion.US) .serviceUrl( "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000")) - .pagerduty("https://my-org.pagerduty.com/service-directory/PMyService")) + .pagerduty( + new ServiceDefinitionV2Dot1Pagerduty() + .serviceUrl( + "https://my-org.pagerduty.com/service-directory/PMyService"))) + .lifecycle("sandbox") .links( Collections.singletonList( - new ServiceDefinitionV2Link() + new ServiceDefinitionV2Dot1Link() .name("Runbook") - .type(ServiceDefinitionV2LinkType.RUNBOOK) + .provider("Github") + .type(ServiceDefinitionV2Dot1LinkType.RUNBOOK) .url("https://my-runbook"))) - .repos( - Collections.singletonList( - new ServiceDefinitionV2Repo() - .name("Source Code") - .provider("GitHub") - .url("https://github.com/DataDog/schema"))) - .schemaVersion(ServiceDefinitionV2Version.V2) + .schemaVersion(ServiceDefinitionV2Dot1Version.V2_1) .tags(Arrays.asList("my:tag", "service:tag")) - .team("my-team")); + .team("my-team") + .tier("High")); try { ServiceDefinitionCreateResponse result = apiInstance.createOrUpdateServiceDefinitions(body); diff --git a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_1808735248.java b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_1808735248.java new file mode 100644 index 00000000000..227ba1ca0f3 --- /dev/null +++ b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_1808735248.java @@ -0,0 +1,85 @@ +// Create or update service definition using schema v2 returns "CREATED" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ServiceDefinitionApi; +import com.datadog.api.client.v2.model.ServiceDefinitionCreateResponse; +import com.datadog.api.client.v2.model.ServiceDefinitionV2; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Contact; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Doc; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Email; +import com.datadog.api.client.v2.model.ServiceDefinitionV2EmailType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Integrations; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Link; +import com.datadog.api.client.v2.model.ServiceDefinitionV2LinkType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Opsgenie; +import com.datadog.api.client.v2.model.ServiceDefinitionV2OpsgenieRegion; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Repo; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Version; +import com.datadog.api.client.v2.model.ServiceDefinitionsCreateRequest; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ServiceDefinitionApi apiInstance = new ServiceDefinitionApi(defaultClient); + + ServiceDefinitionsCreateRequest body = + new ServiceDefinitionsCreateRequest( + new ServiceDefinitionV2() + .contacts( + Collections.singletonList( + new ServiceDefinitionV2Contact( + new ServiceDefinitionV2Email() + .contact("contact@datadoghq.com") + .name("Team Email") + .type(ServiceDefinitionV2EmailType.EMAIL)))) + .ddService( + "service-examplecreateorupdateservicedefinitionusingschemav2returnscreatedresponse") + .ddTeam("my-team") + .docs( + Collections.singletonList( + new ServiceDefinitionV2Doc() + .name("Architecture") + .provider("google drive") + .url("https://gdrive/mydoc"))) + .extensions(Map.ofEntries(Map.entry("myorgextension", "extensionvalue"))) + .integrations( + new ServiceDefinitionV2Integrations() + .opsgenie( + new ServiceDefinitionV2Opsgenie() + .region(ServiceDefinitionV2OpsgenieRegion.US) + .serviceUrl( + "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000")) + .pagerduty("https://my-org.pagerduty.com/service-directory/PMyService")) + .links( + Collections.singletonList( + new ServiceDefinitionV2Link() + .name("Runbook") + .type(ServiceDefinitionV2LinkType.RUNBOOK) + .url("https://my-runbook"))) + .repos( + Collections.singletonList( + new ServiceDefinitionV2Repo() + .name("Source Code") + .provider("GitHub") + .url("https://github.com/DataDog/schema"))) + .schemaVersion(ServiceDefinitionV2Version.V2) + .tags(Arrays.asList("my:tag", "service:tag")) + .team("my-team")); + + try { + ServiceDefinitionCreateResponse result = apiInstance.createOrUpdateServiceDefinitions(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling ServiceDefinitionApi#createOrUpdateServiceDefinitions"); + 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/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2619874414.java b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2619874414.java new file mode 100644 index 00000000000..90d870036da --- /dev/null +++ b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2619874414.java @@ -0,0 +1,84 @@ +// Create or update service definition using schema v2-1 returns "CREATED" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ServiceDefinitionApi; +import com.datadog.api.client.v2.model.ServiceDefinitionCreateResponse; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Contact; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Email; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1EmailType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Integrations; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Link; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1LinkType; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Opsgenie; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1OpsgenieRegion; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Pagerduty; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot1Version; +import com.datadog.api.client.v2.model.ServiceDefinitionsCreateRequest; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + ServiceDefinitionApi apiInstance = new ServiceDefinitionApi(defaultClient); + + ServiceDefinitionsCreateRequest body = + new ServiceDefinitionsCreateRequest( + new ServiceDefinitionV2Dot1() + .contacts( + Collections.singletonList( + new ServiceDefinitionV2Dot1Contact( + new ServiceDefinitionV2Dot1Email() + .contact("contact@datadoghq.com") + .name("Team Email") + .type(ServiceDefinitionV2Dot1EmailType.EMAIL)))) + .ddService( + "service-Example-Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response") + .extensions(Map.ofEntries(Map.entry("myorgextension", "extensionvalue"))) + .integrations( + new ServiceDefinitionV2Dot1Integrations() + .opsgenie( + new ServiceDefinitionV2Dot1Opsgenie() + .region(ServiceDefinitionV2Dot1OpsgenieRegion.US) + .serviceUrl( + "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000")) + .pagerduty( + new ServiceDefinitionV2Dot1Pagerduty() + .serviceUrl( + "https://my-org.pagerduty.com/service-directory/PMyService"))) + .links( + Arrays.asList( + new ServiceDefinitionV2Dot1Link() + .name("Runbook") + .type(ServiceDefinitionV2Dot1LinkType.RUNBOOK) + .url("https://my-runbook"), + new ServiceDefinitionV2Dot1Link() + .name("Source Code") + .type(ServiceDefinitionV2Dot1LinkType.REPO) + .provider("GitHub") + .url("https://github.com/DataDog/schema"), + new ServiceDefinitionV2Dot1Link() + .name("Architecture") + .type(ServiceDefinitionV2Dot1LinkType.DOC) + .provider("Gigoogle drivetHub") + .url("https://my-runbook"))) + .schemaVersion(ServiceDefinitionV2Dot1Version.V2_1) + .tags(Arrays.asList("my:tag", "service:tag")) + .team("my-team")); + + try { + ServiceDefinitionCreateResponse result = apiInstance.createOrUpdateServiceDefinitions(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling ServiceDefinitionApi#createOrUpdateServiceDefinitions"); + 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/v2/model/ServiceDefinitionSchema.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchema.java index 31c97a2e421..5aa7a7c0b25 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchema.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchema.java @@ -168,6 +168,51 @@ public ServiceDefinitionSchema deserialize(JsonParser jp, DeserializationContext log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2'", e); } + // deserialize ServiceDefinitionV2Dot1 + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot1.class.equals(Integer.class) + || ServiceDefinitionV2Dot1.class.equals(Long.class) + || ServiceDefinitionV2Dot1.class.equals(Float.class) + || ServiceDefinitionV2Dot1.class.equals(Double.class) + || ServiceDefinitionV2Dot1.class.equals(Boolean.class) + || ServiceDefinitionV2Dot1.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot1.class.equals(Integer.class) + || ServiceDefinitionV2Dot1.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot1.class.equals(Float.class) + || ServiceDefinitionV2Dot1.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot1.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot1.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot1.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 (!((ServiceDefinitionV2Dot1) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot1'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot1'", e); + } + ServiceDefinitionSchema ret = new ServiceDefinitionSchema(); if (match == 1) { ret.setActualInstance(deserialized); @@ -207,9 +252,15 @@ public ServiceDefinitionSchema(ServiceDefinitionV2 o) { setActualInstance(o); } + public ServiceDefinitionSchema(ServiceDefinitionV2Dot1 o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("ServiceDefinitionV1", new GenericType() {}); schemas.put("ServiceDefinitionV2", new GenericType() {}); + schemas.put("ServiceDefinitionV2Dot1", new GenericType() {}); JSON.registerDescendants(ServiceDefinitionSchema.class, Collections.unmodifiableMap(schemas)); } @@ -220,7 +271,8 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: ServiceDefinitionV1, ServiceDefinitionV2 + * against the oneOf child schemas: ServiceDefinitionV1, ServiceDefinitionV2, + * ServiceDefinitionV2Dot1 * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -235,19 +287,25 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(ServiceDefinitionV2Dot1.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 ServiceDefinitionV1, ServiceDefinitionV2"); + "Invalid instance type. Must be ServiceDefinitionV1, ServiceDefinitionV2," + + " ServiceDefinitionV2Dot1"); } /** - * Get the actual instance, which can be the following: ServiceDefinitionV1, ServiceDefinitionV2 + * Get the actual instance, which can be the following: ServiceDefinitionV1, ServiceDefinitionV2, + * ServiceDefinitionV2Dot1 * - * @return The actual instance (ServiceDefinitionV1, ServiceDefinitionV2) + * @return The actual instance (ServiceDefinitionV1, ServiceDefinitionV2, ServiceDefinitionV2Dot1) */ @Override public Object getActualInstance() { @@ -275,4 +333,15 @@ public ServiceDefinitionV1 getServiceDefinitionV1() throws ClassCastException { public ServiceDefinitionV2 getServiceDefinitionV2() throws ClassCastException { return (ServiceDefinitionV2) super.getActualInstance(); } + + /** + * Get the actual instance of `ServiceDefinitionV2Dot1`. If the actual instance is not + * `ServiceDefinitionV2Dot1`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot1` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot1` + */ + public ServiceDefinitionV2Dot1 getServiceDefinitionV2Dot1() throws ClassCastException { + return (ServiceDefinitionV2Dot1) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1.java new file mode 100644 index 00000000000..5be38a386c8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1.java @@ -0,0 +1,454 @@ +/* + * 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.v2.model; + +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Service definition v2.1 for providing service metadata and integrations. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1.JSON_PROPERTY_APPLICATION, + ServiceDefinitionV2Dot1.JSON_PROPERTY_CONTACTS, + ServiceDefinitionV2Dot1.JSON_PROPERTY_DD_SERVICE, + ServiceDefinitionV2Dot1.JSON_PROPERTY_DESCRIPTION, + ServiceDefinitionV2Dot1.JSON_PROPERTY_EXTENSIONS, + ServiceDefinitionV2Dot1.JSON_PROPERTY_INTEGRATIONS, + ServiceDefinitionV2Dot1.JSON_PROPERTY_LIFECYCLE, + ServiceDefinitionV2Dot1.JSON_PROPERTY_LINKS, + ServiceDefinitionV2Dot1.JSON_PROPERTY_SCHEMA_VERSION, + ServiceDefinitionV2Dot1.JSON_PROPERTY_TAGS, + ServiceDefinitionV2Dot1.JSON_PROPERTY_TEAM, + ServiceDefinitionV2Dot1.JSON_PROPERTY_TIER +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1 { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_APPLICATION = "application"; + private String application; + + public static final String JSON_PROPERTY_CONTACTS = "contacts"; + private List contacts = null; + + public static final String JSON_PROPERTY_DD_SERVICE = "dd-service"; + private String ddService; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + private String description; + + public static final String JSON_PROPERTY_EXTENSIONS = "extensions"; + private Map extensions = null; + + public static final String JSON_PROPERTY_INTEGRATIONS = "integrations"; + private ServiceDefinitionV2Dot1Integrations integrations; + + public static final String JSON_PROPERTY_LIFECYCLE = "lifecycle"; + private String lifecycle; + + public static final String JSON_PROPERTY_LINKS = "links"; + private List links = null; + + public static final String JSON_PROPERTY_SCHEMA_VERSION = "schema-version"; + private ServiceDefinitionV2Dot1Version schemaVersion = ServiceDefinitionV2Dot1Version.V2_1; + + public static final String JSON_PROPERTY_TAGS = "tags"; + private List tags = null; + + public static final String JSON_PROPERTY_TEAM = "team"; + private String team; + + public static final String JSON_PROPERTY_TIER = "tier"; + private String tier; + + public ServiceDefinitionV2Dot1() {} + + @JsonCreator + public ServiceDefinitionV2Dot1( + @JsonProperty(required = true, value = JSON_PROPERTY_DD_SERVICE) String ddService, + @JsonProperty(required = true, value = JSON_PROPERTY_SCHEMA_VERSION) + ServiceDefinitionV2Dot1Version schemaVersion) { + this.ddService = ddService; + this.schemaVersion = schemaVersion; + this.unparsed |= !schemaVersion.isValid(); + } + + public ServiceDefinitionV2Dot1 application(String application) { + this.application = application; + return this; + } + + /** + * Identifier for a group of related services serving a product feature, which the service is a + * part of. + * + * @return application + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_APPLICATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getApplication() { + return application; + } + + public void setApplication(String application) { + this.application = application; + } + + public ServiceDefinitionV2Dot1 contacts(List contacts) { + this.contacts = contacts; + for (ServiceDefinitionV2Dot1Contact item : contacts) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ServiceDefinitionV2Dot1 addContactsItem(ServiceDefinitionV2Dot1Contact contactsItem) { + if (this.contacts == null) { + this.contacts = new ArrayList<>(); + } + this.contacts.add(contactsItem); + this.unparsed |= contactsItem.unparsed; + return this; + } + + /** + * A list of contacts related to the services. + * + * @return contacts + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTACTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getContacts() { + return contacts; + } + + public void setContacts(List contacts) { + this.contacts = contacts; + } + + public ServiceDefinitionV2Dot1 ddService(String ddService) { + this.ddService = ddService; + return this; + } + + /** + * Unique identifier of the service. Must be unique across all services and is used to match with + * a service in Datadog. + * + * @return ddService + */ + @JsonProperty(JSON_PROPERTY_DD_SERVICE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getDdService() { + return ddService; + } + + public void setDdService(String ddService) { + this.ddService = ddService; + } + + public ServiceDefinitionV2Dot1 description(String description) { + this.description = description; + return this; + } + + /** + * A short description of the service. + * + * @return description + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ServiceDefinitionV2Dot1 extensions(Map extensions) { + this.extensions = extensions; + return this; + } + + public ServiceDefinitionV2Dot1 putExtensionsItem(String key, Object extensionsItem) { + if (this.extensions == null) { + this.extensions = new HashMap<>(); + } + this.extensions.put(key, extensionsItem); + return this; + } + + /** + * Extensions to v2.1 schema. + * + * @return extensions + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXTENSIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getExtensions() { + return extensions; + } + + public void setExtensions(Map extensions) { + this.extensions = extensions; + } + + public ServiceDefinitionV2Dot1 integrations(ServiceDefinitionV2Dot1Integrations integrations) { + this.integrations = integrations; + this.unparsed |= integrations.unparsed; + return this; + } + + /** + * Third party integrations that Datadog supports. + * + * @return integrations + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INTEGRATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ServiceDefinitionV2Dot1Integrations getIntegrations() { + return integrations; + } + + public void setIntegrations(ServiceDefinitionV2Dot1Integrations integrations) { + this.integrations = integrations; + } + + public ServiceDefinitionV2Dot1 lifecycle(String lifecycle) { + this.lifecycle = lifecycle; + return this; + } + + /** + * The current life cycle phase of the service. + * + * @return lifecycle + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LIFECYCLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLifecycle() { + return lifecycle; + } + + public void setLifecycle(String lifecycle) { + this.lifecycle = lifecycle; + } + + public ServiceDefinitionV2Dot1 links(List links) { + this.links = links; + for (ServiceDefinitionV2Dot1Link item : links) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ServiceDefinitionV2Dot1 addLinksItem(ServiceDefinitionV2Dot1Link linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + this.unparsed |= linksItem.unparsed; + return this; + } + + /** + * A list of links related to the services. + * + * @return links + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + public void setLinks(List links) { + this.links = links; + } + + public ServiceDefinitionV2Dot1 schemaVersion(ServiceDefinitionV2Dot1Version schemaVersion) { + this.schemaVersion = schemaVersion; + this.unparsed |= !schemaVersion.isValid(); + return this; + } + + /** + * Schema version being used. + * + * @return schemaVersion + */ + @JsonProperty(JSON_PROPERTY_SCHEMA_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ServiceDefinitionV2Dot1Version getSchemaVersion() { + return schemaVersion; + } + + public void setSchemaVersion(ServiceDefinitionV2Dot1Version schemaVersion) { + if (!schemaVersion.isValid()) { + this.unparsed = true; + } + this.schemaVersion = schemaVersion; + } + + public ServiceDefinitionV2Dot1 tags(List tags) { + this.tags = tags; + return this; + } + + public ServiceDefinitionV2Dot1 addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * A set of custom tags. + * + * @return tags + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public ServiceDefinitionV2Dot1 team(String team) { + this.team = team; + return this; + } + + /** + * Team that owns the service. It is used to locate a team defined in Datadog Teams if it exists. + * + * @return team + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEAM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTeam() { + return team; + } + + public void setTeam(String team) { + this.team = team; + } + + public ServiceDefinitionV2Dot1 tier(String tier) { + this.tier = tier; + return this; + } + + /** + * Importance of the service. + * + * @return tier + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTier() { + return tier; + } + + public void setTier(String tier) { + this.tier = tier; + } + + /** Return true if this ServiceDefinitionV2Dot1 object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1 serviceDefinitionV2Dot1 = (ServiceDefinitionV2Dot1) o; + return Objects.equals(this.application, serviceDefinitionV2Dot1.application) + && Objects.equals(this.contacts, serviceDefinitionV2Dot1.contacts) + && Objects.equals(this.ddService, serviceDefinitionV2Dot1.ddService) + && Objects.equals(this.description, serviceDefinitionV2Dot1.description) + && Objects.equals(this.extensions, serviceDefinitionV2Dot1.extensions) + && Objects.equals(this.integrations, serviceDefinitionV2Dot1.integrations) + && Objects.equals(this.lifecycle, serviceDefinitionV2Dot1.lifecycle) + && Objects.equals(this.links, serviceDefinitionV2Dot1.links) + && Objects.equals(this.schemaVersion, serviceDefinitionV2Dot1.schemaVersion) + && Objects.equals(this.tags, serviceDefinitionV2Dot1.tags) + && Objects.equals(this.team, serviceDefinitionV2Dot1.team) + && Objects.equals(this.tier, serviceDefinitionV2Dot1.tier); + } + + @Override + public int hashCode() { + return Objects.hash( + application, + contacts, + ddService, + description, + extensions, + integrations, + lifecycle, + links, + schemaVersion, + tags, + team, + tier); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1 {\n"); + sb.append(" application: ").append(toIndentedString(application)).append("\n"); + sb.append(" contacts: ").append(toIndentedString(contacts)).append("\n"); + sb.append(" ddService: ").append(toIndentedString(ddService)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" extensions: ").append(toIndentedString(extensions)).append("\n"); + sb.append(" integrations: ").append(toIndentedString(integrations)).append("\n"); + sb.append(" lifecycle: ").append(toIndentedString(lifecycle)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" schemaVersion: ").append(toIndentedString(schemaVersion)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" team: ").append(toIndentedString(team)).append("\n"); + sb.append(" tier: ").append(toIndentedString(tier)).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/v2/model/ServiceDefinitionV2Dot1Contact.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Contact.java new file mode 100644 index 00000000000..c14d6a79d5b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Contact.java @@ -0,0 +1,287 @@ +/* + * 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.v2.model; + +import com.datadog.api.client.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = ServiceDefinitionV2Dot1Contact.ServiceDefinitionV2Dot1ContactDeserializer.class) +@JsonSerialize( + using = ServiceDefinitionV2Dot1Contact.ServiceDefinitionV2Dot1ContactSerializer.class) +public class ServiceDefinitionV2Dot1Contact extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ServiceDefinitionV2Dot1Contact.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceDefinitionV2Dot1ContactSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1ContactSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1ContactSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1Contact value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceDefinitionV2Dot1ContactDeserializer + extends StdDeserializer { + public ServiceDefinitionV2Dot1ContactDeserializer() { + this(ServiceDefinitionV2Dot1Contact.class); + } + + public ServiceDefinitionV2Dot1ContactDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceDefinitionV2Dot1Contact deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize ServiceDefinitionV2Dot1Email + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot1Email.class.equals(Integer.class) + || ServiceDefinitionV2Dot1Email.class.equals(Long.class) + || ServiceDefinitionV2Dot1Email.class.equals(Float.class) + || ServiceDefinitionV2Dot1Email.class.equals(Double.class) + || ServiceDefinitionV2Dot1Email.class.equals(Boolean.class) + || ServiceDefinitionV2Dot1Email.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot1Email.class.equals(Integer.class) + || ServiceDefinitionV2Dot1Email.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot1Email.class.equals(Float.class) + || ServiceDefinitionV2Dot1Email.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot1Email.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot1Email.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot1Email.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 (!((ServiceDefinitionV2Dot1Email) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot1Email'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot1Email'", e); + } + + // deserialize ServiceDefinitionV2Dot1Slack + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot1Slack.class.equals(Integer.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Long.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Float.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Double.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Boolean.class) + || ServiceDefinitionV2Dot1Slack.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot1Slack.class.equals(Integer.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot1Slack.class.equals(Float.class) + || ServiceDefinitionV2Dot1Slack.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot1Slack.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot1Slack.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot1Slack.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 (!((ServiceDefinitionV2Dot1Slack) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot1Slack'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot1Slack'", e); + } + + ServiceDefinitionV2Dot1Contact ret = new ServiceDefinitionV2Dot1Contact(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public ServiceDefinitionV2Dot1Contact getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceDefinitionV2Dot1Contact cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceDefinitionV2Dot1Contact() { + super("oneOf", Boolean.FALSE); + } + + public ServiceDefinitionV2Dot1Contact(ServiceDefinitionV2Dot1Email o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceDefinitionV2Dot1Contact(ServiceDefinitionV2Dot1Slack o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ServiceDefinitionV2Dot1Email", new GenericType() {}); + schemas.put("ServiceDefinitionV2Dot1Slack", new GenericType() {}); + JSON.registerDescendants( + ServiceDefinitionV2Dot1Contact.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceDefinitionV2Dot1Contact.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: ServiceDefinitionV2Dot1Email, ServiceDefinitionV2Dot1Slack + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(ServiceDefinitionV2Dot1Email.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(ServiceDefinitionV2Dot1Slack.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 ServiceDefinitionV2Dot1Email," + + " ServiceDefinitionV2Dot1Slack"); + } + + /** + * Get the actual instance, which can be the following: ServiceDefinitionV2Dot1Email, + * ServiceDefinitionV2Dot1Slack + * + * @return The actual instance (ServiceDefinitionV2Dot1Email, ServiceDefinitionV2Dot1Slack) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ServiceDefinitionV2Dot1Email`. If the actual instance is not + * `ServiceDefinitionV2Dot1Email`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot1Email` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot1Email` + */ + public ServiceDefinitionV2Dot1Email getServiceDefinitionV2Dot1Email() throws ClassCastException { + return (ServiceDefinitionV2Dot1Email) super.getActualInstance(); + } + + /** + * Get the actual instance of `ServiceDefinitionV2Dot1Slack`. If the actual instance is not + * `ServiceDefinitionV2Dot1Slack`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot1Slack` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot1Slack` + */ + public ServiceDefinitionV2Dot1Slack getServiceDefinitionV2Dot1Slack() throws ClassCastException { + return (ServiceDefinitionV2Dot1Slack) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Email.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Email.java new file mode 100644 index 00000000000..55b1374792f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Email.java @@ -0,0 +1,152 @@ +/* + * 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.v2.model; + +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.Objects; + +/** Service owner's email. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1Email.JSON_PROPERTY_CONTACT, + ServiceDefinitionV2Dot1Email.JSON_PROPERTY_NAME, + ServiceDefinitionV2Dot1Email.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Email { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONTACT = "contact"; + private String contact; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ServiceDefinitionV2Dot1EmailType type; + + public ServiceDefinitionV2Dot1Email() {} + + @JsonCreator + public ServiceDefinitionV2Dot1Email( + @JsonProperty(required = true, value = JSON_PROPERTY_CONTACT) String contact, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ServiceDefinitionV2Dot1EmailType type) { + this.contact = contact; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ServiceDefinitionV2Dot1Email contact(String contact) { + this.contact = contact; + return this; + } + + /** + * Contact value. + * + * @return contact + */ + @JsonProperty(JSON_PROPERTY_CONTACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public ServiceDefinitionV2Dot1Email name(String name) { + this.name = name; + return this; + } + + /** + * Contact email. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ServiceDefinitionV2Dot1Email type(ServiceDefinitionV2Dot1EmailType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Contact type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ServiceDefinitionV2Dot1EmailType getType() { + return type; + } + + public void setType(ServiceDefinitionV2Dot1EmailType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** Return true if this ServiceDefinitionV2Dot1Email object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Email serviceDefinitionV2Dot1Email = (ServiceDefinitionV2Dot1Email) o; + return Objects.equals(this.contact, serviceDefinitionV2Dot1Email.contact) + && Objects.equals(this.name, serviceDefinitionV2Dot1Email.name) + && Objects.equals(this.type, serviceDefinitionV2Dot1Email.type); + } + + @Override + public int hashCode() { + return Objects.hash(contact, name, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Email {\n"); + sb.append(" contact: ").append(toIndentedString(contact)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/v2/model/ServiceDefinitionV2Dot1EmailType.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1EmailType.java new file mode 100644 index 00000000000..8dd99314653 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1EmailType.java @@ -0,0 +1,95 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +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.Objects; +import java.util.Set; + +/** Contact type. */ +@JsonSerialize( + using = ServiceDefinitionV2Dot1EmailType.ServiceDefinitionV2Dot1EmailTypeSerializer.class) +public class ServiceDefinitionV2Dot1EmailType { + + public static final ServiceDefinitionV2Dot1EmailType EMAIL = + new ServiceDefinitionV2Dot1EmailType("email"); + + private static final Set allowedValues = new HashSet(Arrays.asList("email")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + ServiceDefinitionV2Dot1EmailType(String value) { + this.value = value; + } + + public static class ServiceDefinitionV2Dot1EmailTypeSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1EmailTypeSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1EmailTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1EmailType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this ServiceDefinitionV2Dot1EmailType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((ServiceDefinitionV2Dot1EmailType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ServiceDefinitionV2Dot1EmailType fromValue(String value) { + return new ServiceDefinitionV2Dot1EmailType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Integrations.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Integrations.java new file mode 100644 index 00000000000..0736907b9c6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Integrations.java @@ -0,0 +1,113 @@ +/* + * 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.v2.model; + +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.Objects; + +/** Third party integrations that Datadog supports. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1Integrations.JSON_PROPERTY_OPSGENIE, + ServiceDefinitionV2Dot1Integrations.JSON_PROPERTY_PAGERDUTY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Integrations { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OPSGENIE = "opsgenie"; + private ServiceDefinitionV2Dot1Opsgenie opsgenie; + + public static final String JSON_PROPERTY_PAGERDUTY = "pagerduty"; + private ServiceDefinitionV2Dot1Pagerduty pagerduty; + + public ServiceDefinitionV2Dot1Integrations opsgenie(ServiceDefinitionV2Dot1Opsgenie opsgenie) { + this.opsgenie = opsgenie; + this.unparsed |= opsgenie.unparsed; + return this; + } + + /** + * Opsgenie integration for the service. + * + * @return opsgenie + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OPSGENIE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ServiceDefinitionV2Dot1Opsgenie getOpsgenie() { + return opsgenie; + } + + public void setOpsgenie(ServiceDefinitionV2Dot1Opsgenie opsgenie) { + this.opsgenie = opsgenie; + } + + public ServiceDefinitionV2Dot1Integrations pagerduty(ServiceDefinitionV2Dot1Pagerduty pagerduty) { + this.pagerduty = pagerduty; + this.unparsed |= pagerduty.unparsed; + return this; + } + + /** + * PagerDuty integration for the service. + * + * @return pagerduty + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGERDUTY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ServiceDefinitionV2Dot1Pagerduty getPagerduty() { + return pagerduty; + } + + public void setPagerduty(ServiceDefinitionV2Dot1Pagerduty pagerduty) { + this.pagerduty = pagerduty; + } + + /** Return true if this ServiceDefinitionV2Dot1Integrations object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Integrations serviceDefinitionV2Dot1Integrations = + (ServiceDefinitionV2Dot1Integrations) o; + return Objects.equals(this.opsgenie, serviceDefinitionV2Dot1Integrations.opsgenie) + && Objects.equals(this.pagerduty, serviceDefinitionV2Dot1Integrations.pagerduty); + } + + @Override + public int hashCode() { + return Objects.hash(opsgenie, pagerduty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Integrations {\n"); + sb.append(" opsgenie: ").append(toIndentedString(opsgenie)).append("\n"); + sb.append(" pagerduty: ").append(toIndentedString(pagerduty)).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/v2/model/ServiceDefinitionV2Dot1Link.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Link.java new file mode 100644 index 00000000000..157414c1d04 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Link.java @@ -0,0 +1,180 @@ +/* + * 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.v2.model; + +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.Objects; + +/** Service's external links. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1Link.JSON_PROPERTY_NAME, + ServiceDefinitionV2Dot1Link.JSON_PROPERTY_PROVIDER, + ServiceDefinitionV2Dot1Link.JSON_PROPERTY_TYPE, + ServiceDefinitionV2Dot1Link.JSON_PROPERTY_URL +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Link { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_PROVIDER = "provider"; + private String provider; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ServiceDefinitionV2Dot1LinkType type; + + public static final String JSON_PROPERTY_URL = "url"; + private String url; + + public ServiceDefinitionV2Dot1Link() {} + + @JsonCreator + public ServiceDefinitionV2Dot1Link( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ServiceDefinitionV2Dot1LinkType type, + @JsonProperty(required = true, value = JSON_PROPERTY_URL) String url) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + this.url = url; + } + + public ServiceDefinitionV2Dot1Link name(String name) { + this.name = name; + return this; + } + + /** + * Link name. + * + * @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 ServiceDefinitionV2Dot1Link provider(String provider) { + this.provider = provider; + return this; + } + + /** + * Link provider. + * + * @return provider + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PROVIDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public ServiceDefinitionV2Dot1Link type(ServiceDefinitionV2Dot1LinkType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Link type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ServiceDefinitionV2Dot1LinkType getType() { + return type; + } + + public void setType(ServiceDefinitionV2Dot1LinkType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + public ServiceDefinitionV2Dot1Link url(String url) { + this.url = url; + return this; + } + + /** + * Link URL. + * + * @return url + */ + @JsonProperty(JSON_PROPERTY_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + /** Return true if this ServiceDefinitionV2Dot1Link object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Link serviceDefinitionV2Dot1Link = (ServiceDefinitionV2Dot1Link) o; + return Objects.equals(this.name, serviceDefinitionV2Dot1Link.name) + && Objects.equals(this.provider, serviceDefinitionV2Dot1Link.provider) + && Objects.equals(this.type, serviceDefinitionV2Dot1Link.type) + && Objects.equals(this.url, serviceDefinitionV2Dot1Link.url); + } + + @Override + public int hashCode() { + return Objects.hash(name, provider, type, url); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Link {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).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/v2/model/ServiceDefinitionV2Dot1LinkType.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1LinkType.java new file mode 100644 index 00000000000..e157f6ab2bb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1LinkType.java @@ -0,0 +1,104 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +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.Objects; +import java.util.Set; + +/** Link type. */ +@JsonSerialize( + using = ServiceDefinitionV2Dot1LinkType.ServiceDefinitionV2Dot1LinkTypeSerializer.class) +public class ServiceDefinitionV2Dot1LinkType { + + public static final ServiceDefinitionV2Dot1LinkType DOC = + new ServiceDefinitionV2Dot1LinkType("doc"); + public static final ServiceDefinitionV2Dot1LinkType REPO = + new ServiceDefinitionV2Dot1LinkType("repo"); + public static final ServiceDefinitionV2Dot1LinkType RUNBOOK = + new ServiceDefinitionV2Dot1LinkType("runbook"); + public static final ServiceDefinitionV2Dot1LinkType DASHBOARD = + new ServiceDefinitionV2Dot1LinkType("dashboard"); + public static final ServiceDefinitionV2Dot1LinkType OTHER = + new ServiceDefinitionV2Dot1LinkType("other"); + + private static final Set allowedValues = + new HashSet(Arrays.asList("doc", "repo", "runbook", "dashboard", "other")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + ServiceDefinitionV2Dot1LinkType(String value) { + this.value = value; + } + + public static class ServiceDefinitionV2Dot1LinkTypeSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1LinkTypeSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1LinkTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1LinkType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this ServiceDefinitionV2Dot1LinkType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((ServiceDefinitionV2Dot1LinkType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ServiceDefinitionV2Dot1LinkType fromValue(String value) { + return new ServiceDefinitionV2Dot1LinkType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Opsgenie.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Opsgenie.java new file mode 100644 index 00000000000..429fc6dfc54 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Opsgenie.java @@ -0,0 +1,123 @@ +/* + * 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.v2.model; + +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.Objects; + +/** Opsgenie integration for the service. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1Opsgenie.JSON_PROPERTY_REGION, + ServiceDefinitionV2Dot1Opsgenie.JSON_PROPERTY_SERVICE_URL +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Opsgenie { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_REGION = "region"; + private ServiceDefinitionV2Dot1OpsgenieRegion region; + + public static final String JSON_PROPERTY_SERVICE_URL = "service-url"; + private String serviceUrl; + + public ServiceDefinitionV2Dot1Opsgenie() {} + + @JsonCreator + public ServiceDefinitionV2Dot1Opsgenie( + @JsonProperty(required = true, value = JSON_PROPERTY_SERVICE_URL) String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public ServiceDefinitionV2Dot1Opsgenie region(ServiceDefinitionV2Dot1OpsgenieRegion region) { + this.region = region; + this.unparsed |= !region.isValid(); + return this; + } + + /** + * Opsgenie instance region. + * + * @return region + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_REGION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ServiceDefinitionV2Dot1OpsgenieRegion getRegion() { + return region; + } + + public void setRegion(ServiceDefinitionV2Dot1OpsgenieRegion region) { + if (!region.isValid()) { + this.unparsed = true; + } + this.region = region; + } + + public ServiceDefinitionV2Dot1Opsgenie serviceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + + /** + * Opsgenie service url. + * + * @return serviceUrl + */ + @JsonProperty(JSON_PROPERTY_SERVICE_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + /** Return true if this ServiceDefinitionV2Dot1Opsgenie object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Opsgenie serviceDefinitionV2Dot1Opsgenie = + (ServiceDefinitionV2Dot1Opsgenie) o; + return Objects.equals(this.region, serviceDefinitionV2Dot1Opsgenie.region) + && Objects.equals(this.serviceUrl, serviceDefinitionV2Dot1Opsgenie.serviceUrl); + } + + @Override + public int hashCode() { + return Objects.hash(region, serviceUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Opsgenie {\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" serviceUrl: ").append(toIndentedString(serviceUrl)).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/v2/model/ServiceDefinitionV2Dot1OpsgenieRegion.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1OpsgenieRegion.java new file mode 100644 index 00000000000..7a5f30c8c23 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1OpsgenieRegion.java @@ -0,0 +1,101 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +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.Objects; +import java.util.Set; + +/** Opsgenie instance region. */ +@JsonSerialize( + using = + ServiceDefinitionV2Dot1OpsgenieRegion.ServiceDefinitionV2Dot1OpsgenieRegionSerializer.class) +public class ServiceDefinitionV2Dot1OpsgenieRegion { + + public static final ServiceDefinitionV2Dot1OpsgenieRegion US = + new ServiceDefinitionV2Dot1OpsgenieRegion("US"); + public static final ServiceDefinitionV2Dot1OpsgenieRegion EU = + new ServiceDefinitionV2Dot1OpsgenieRegion("EU"); + + private static final Set allowedValues = new HashSet(Arrays.asList("US", "EU")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + ServiceDefinitionV2Dot1OpsgenieRegion(String value) { + this.value = value; + } + + public static class ServiceDefinitionV2Dot1OpsgenieRegionSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1OpsgenieRegionSerializer( + Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1OpsgenieRegionSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1OpsgenieRegion value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this ServiceDefinitionV2Dot1OpsgenieRegion object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((ServiceDefinitionV2Dot1OpsgenieRegion) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ServiceDefinitionV2Dot1OpsgenieRegion fromValue(String value) { + return new ServiceDefinitionV2Dot1OpsgenieRegion(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Pagerduty.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Pagerduty.java new file mode 100644 index 00000000000..767abe0144a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Pagerduty.java @@ -0,0 +1,82 @@ +/* + * 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.v2.model; + +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.Objects; + +/** PagerDuty integration for the service. */ +@JsonPropertyOrder({ServiceDefinitionV2Dot1Pagerduty.JSON_PROPERTY_SERVICE_URL}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Pagerduty { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_SERVICE_URL = "service-url"; + private String serviceUrl; + + public ServiceDefinitionV2Dot1Pagerduty serviceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + return this; + } + + /** + * PagerDuty service url. + * + * @return serviceUrl + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SERVICE_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + /** Return true if this ServiceDefinitionV2Dot1Pagerduty object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Pagerduty serviceDefinitionV2Dot1Pagerduty = + (ServiceDefinitionV2Dot1Pagerduty) o; + return Objects.equals(this.serviceUrl, serviceDefinitionV2Dot1Pagerduty.serviceUrl); + } + + @Override + public int hashCode() { + return Objects.hash(serviceUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Pagerduty {\n"); + sb.append(" serviceUrl: ").append(toIndentedString(serviceUrl)).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/v2/model/ServiceDefinitionV2Dot1Slack.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Slack.java new file mode 100644 index 00000000000..bd6b587d06f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Slack.java @@ -0,0 +1,152 @@ +/* + * 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.v2.model; + +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.Objects; + +/** Service owner's Slack channel. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot1Slack.JSON_PROPERTY_CONTACT, + ServiceDefinitionV2Dot1Slack.JSON_PROPERTY_NAME, + ServiceDefinitionV2Dot1Slack.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot1Slack { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONTACT = "contact"; + private String contact; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ServiceDefinitionV2Dot1SlackType type; + + public ServiceDefinitionV2Dot1Slack() {} + + @JsonCreator + public ServiceDefinitionV2Dot1Slack( + @JsonProperty(required = true, value = JSON_PROPERTY_CONTACT) String contact, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ServiceDefinitionV2Dot1SlackType type) { + this.contact = contact; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ServiceDefinitionV2Dot1Slack contact(String contact) { + this.contact = contact; + return this; + } + + /** + * Slack Channel. + * + * @return contact + */ + @JsonProperty(JSON_PROPERTY_CONTACT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public ServiceDefinitionV2Dot1Slack name(String name) { + this.name = name; + return this; + } + + /** + * Contact Slack. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ServiceDefinitionV2Dot1Slack type(ServiceDefinitionV2Dot1SlackType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Contact type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ServiceDefinitionV2Dot1SlackType getType() { + return type; + } + + public void setType(ServiceDefinitionV2Dot1SlackType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** Return true if this ServiceDefinitionV2Dot1Slack object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot1Slack serviceDefinitionV2Dot1Slack = (ServiceDefinitionV2Dot1Slack) o; + return Objects.equals(this.contact, serviceDefinitionV2Dot1Slack.contact) + && Objects.equals(this.name, serviceDefinitionV2Dot1Slack.name) + && Objects.equals(this.type, serviceDefinitionV2Dot1Slack.type); + } + + @Override + public int hashCode() { + return Objects.hash(contact, name, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot1Slack {\n"); + sb.append(" contact: ").append(toIndentedString(contact)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/v2/model/ServiceDefinitionV2Dot1SlackType.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1SlackType.java new file mode 100644 index 00000000000..3b6562a6991 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1SlackType.java @@ -0,0 +1,95 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +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.Objects; +import java.util.Set; + +/** Contact type. */ +@JsonSerialize( + using = ServiceDefinitionV2Dot1SlackType.ServiceDefinitionV2Dot1SlackTypeSerializer.class) +public class ServiceDefinitionV2Dot1SlackType { + + public static final ServiceDefinitionV2Dot1SlackType SLACK = + new ServiceDefinitionV2Dot1SlackType("slack"); + + private static final Set allowedValues = new HashSet(Arrays.asList("slack")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + ServiceDefinitionV2Dot1SlackType(String value) { + this.value = value; + } + + public static class ServiceDefinitionV2Dot1SlackTypeSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1SlackTypeSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1SlackTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1SlackType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this ServiceDefinitionV2Dot1SlackType object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((ServiceDefinitionV2Dot1SlackType) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ServiceDefinitionV2Dot1SlackType fromValue(String value) { + return new ServiceDefinitionV2Dot1SlackType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Version.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Version.java new file mode 100644 index 00000000000..bc3c2b91185 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot1Version.java @@ -0,0 +1,95 @@ +/* + * 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.v2.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +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.Objects; +import java.util.Set; + +/** Schema version being used. */ +@JsonSerialize( + using = ServiceDefinitionV2Dot1Version.ServiceDefinitionV2Dot1VersionSerializer.class) +public class ServiceDefinitionV2Dot1Version { + + public static final ServiceDefinitionV2Dot1Version V2_1 = + new ServiceDefinitionV2Dot1Version("v2.1"); + + private static final Set allowedValues = new HashSet(Arrays.asList("v2.1")); + + private String value; + + public boolean isValid() { + return allowedValues.contains(this.value); + } + + ServiceDefinitionV2Dot1Version(String value) { + this.value = value; + } + + public static class ServiceDefinitionV2Dot1VersionSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot1VersionSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot1VersionSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot1Version value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + /** Return true if this ServiceDefinitionV2Dot1Version object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return this.value.equals(((ServiceDefinitionV2Dot1Version) o).value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ServiceDefinitionV2Dot1Version fromValue(String value) { + return new ServiceDefinitionV2Dot1Version(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionsCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionsCreateRequest.java index 362823e478b..d530c74b3ce 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionsCreateRequest.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionsCreateRequest.java @@ -83,6 +83,51 @@ public ServiceDefinitionsCreateRequest deserialize(JsonParser jp, Deserializatio boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); int match = 0; JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize ServiceDefinitionV2Dot1 + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot1.class.equals(Integer.class) + || ServiceDefinitionV2Dot1.class.equals(Long.class) + || ServiceDefinitionV2Dot1.class.equals(Float.class) + || ServiceDefinitionV2Dot1.class.equals(Double.class) + || ServiceDefinitionV2Dot1.class.equals(Boolean.class) + || ServiceDefinitionV2Dot1.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot1.class.equals(Integer.class) + || ServiceDefinitionV2Dot1.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot1.class.equals(Float.class) + || ServiceDefinitionV2Dot1.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot1.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot1.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot1.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 (!((ServiceDefinitionV2Dot1) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot1'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot1'", e); + } + // deserialize ServiceDefinitionV2 try { boolean attemptParsing = true; @@ -198,6 +243,11 @@ public ServiceDefinitionsCreateRequest() { super("oneOf", Boolean.FALSE); } + public ServiceDefinitionsCreateRequest(ServiceDefinitionV2Dot1 o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + public ServiceDefinitionsCreateRequest(ServiceDefinitionV2 o) { super("oneOf", Boolean.FALSE); setActualInstance(o); @@ -209,6 +259,7 @@ public ServiceDefinitionsCreateRequest(String o) { } static { + schemas.put("ServiceDefinitionV2Dot1", new GenericType() {}); schemas.put("ServiceDefinitionV2", new GenericType() {}); schemas.put("String", new GenericType() {}); JSON.registerDescendants( @@ -222,13 +273,17 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: ServiceDefinitionV2, String + * against the oneOf child schemas: ServiceDefinitionV2Dot1, ServiceDefinitionV2, String * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). */ @Override public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(ServiceDefinitionV2Dot1.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(ServiceDefinitionV2.class, instance, new HashSet>())) { super.setActualInstance(instance); return; @@ -242,19 +297,32 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } - throw new RuntimeException("Invalid instance type. Must be ServiceDefinitionV2, String"); + throw new RuntimeException( + "Invalid instance type. Must be ServiceDefinitionV2Dot1, ServiceDefinitionV2, String"); } /** - * Get the actual instance, which can be the following: ServiceDefinitionV2, String + * Get the actual instance, which can be the following: ServiceDefinitionV2Dot1, + * ServiceDefinitionV2, String * - * @return The actual instance (ServiceDefinitionV2, String) + * @return The actual instance (ServiceDefinitionV2Dot1, ServiceDefinitionV2, String) */ @Override public Object getActualInstance() { return super.getActualInstance(); } + /** + * Get the actual instance of `ServiceDefinitionV2Dot1`. If the actual instance is not + * `ServiceDefinitionV2Dot1`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot1` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot1` + */ + public ServiceDefinitionV2Dot1 getServiceDefinitionV2Dot1() throws ClassCastException { + return (ServiceDefinitionV2Dot1) super.getActualInstance(); + } + /** * Get the actual instance of `ServiceDefinitionV2`. If the actual instance is not * `ServiceDefinitionV2`, the ClassCastException will be thrown. diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.freeze b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.freeze index be705da1fc7..7135c3fee48 100644 --- a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.freeze +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.freeze @@ -1 +1 @@ -2022-11-10T21:14:44.544Z \ No newline at end of file +2023-03-24T18:06:23.874Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.json b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.json index 5c8826600ba..4b446d8f258 100644 --- a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.json +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_returns_CREATED_response.json @@ -3,7 +3,7 @@ "httpRequest": { "body": { "type": "JSON", - "json": "{\"contacts\":[{\"contact\":\"contact@datadoghq.com\",\"name\":\"Team Email\",\"type\":\"email\"}],\"dd-service\":\"service-Test-Create_or_update_service_definition_returns_CREATED_response-1668114884\",\"dd-team\":\"my-team\",\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"extensions\":{\"myorgextension\":\"extensionvalue\"},\"integrations\":{\"opsgenie\":{\"region\":\"US\",\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\"},\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"schema-version\":\"v2\",\"tags\":[\"my:tag\",\"service:tag\"],\"team\":\"my-team\"}" + "json": "{\"contacts\":[{\"contact\":\"contact@datadoghq.com\",\"name\":\"Team Email\",\"type\":\"email\"}],\"dd-service\":\"service-testcreateorupdateservicedefinitionreturnscreatedresponse1679681183\",\"dd-team\":\"my-team\",\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"extensions\":{\"myorgextension\":\"extensionvalue\"},\"integrations\":{\"opsgenie\":{\"region\":\"US\",\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\"},\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"schema-version\":\"v2\",\"tags\":[\"my:tag\",\"service:tag\"],\"team\":\"my-team\"}" }, "headers": {}, "method": "POST", @@ -12,7 +12,7 @@ "secure": true }, "httpResponse": { - "body": "{\"data\":[{\"type\":\"service-definition\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2022-11-10T21:14:45.52228008Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"warnings\":[],\"ingested-schema-version\":\"v2\"},\"schema\":{\"schema-version\":\"v2\",\"dd-service\":\"service-test-create_or_update_service_definition_returns_created_response-1668114884\",\"dd-team\":\"my-team\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\",\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}}]}\n", + "body": "{\"data\":[{\"type\":\"service-definition\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2023-03-24T18:06:24.041193351Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"unknown\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2\"},\"schema\":{\"schema-version\":\"v2\",\"dd-service\":\"service-testcreateorupdateservicedefinitionreturnscreatedresponse1679681183\",\"dd-team\":\"my-team\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\",\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}}]}\n", "headers": { "Content-Type": [ "application/json" @@ -27,13 +27,13 @@ "timeToLive": { "unlimited": true }, - "id": "b5aa6928-e06a-8df2-c5c8-ff06a6bdb3f1" + "id": "754cd889-a8eb-2e3f-8542-e52601a9df38" }, { "httpRequest": { "headers": {}, "method": "DELETE", - "path": "/api/v2/services/definitions/service-test-create_or_update_service_definition_returns_created_response-1668114884", + "path": "/api/v2/services/definitions/service-testcreateorupdateservicedefinitionreturnscreatedresponse1679681183", "keepAlive": false, "secure": true }, @@ -53,6 +53,6 @@ "timeToLive": { "unlimited": true }, - "id": "8da7c885-e895-edd3-27ae-d527f50e4817" + "id": "523a43d4-8270-84ff-aa9c-26d789d5c1da" } ] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.freeze b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.freeze new file mode 100644 index 00000000000..cf656770f53 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2023-03-28T20:28:44.080Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.json b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.json new file mode 100644 index 00000000000..6ffd300a205 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"contacts\":[{\"contact\":\"contact@datadoghq.com\",\"name\":\"Team Email\",\"type\":\"email\"}],\"dd-service\":\"service-Test-Create_or_update_service_definition_using_schema_v2_1_returns_CREATED_response-1680035324\",\"extensions\":{\"myorgextension\":\"extensionvalue\"},\"integrations\":{\"opsgenie\":{\"region\":\"US\",\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\"pagerduty\":{\"service-url\":\"https://my-org.pagerduty.com/service-directory/PMyService\"}},\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"},{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"type\":\"repo\",\"url\":\"https://github.com/DataDog/schema\"},{\"name\":\"Architecture\",\"provider\":\"Gigoogle drivetHub\",\"type\":\"doc\",\"url\":\"https://my-runbook\"}],\"schema-version\":\"v2.1\",\"tags\":[\"my:tag\",\"service:tag\"],\"team\":\"my-team\"}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/services/definitions", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"type\":\"service-definition\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2023-03-28T20:28:44.264527027Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"unknown\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2.1\"},\"schema\":{\"schema-version\":\"v2.1\",\"dd-service\":\"service-test-create_or_update_service_definition_using_schema_v2_1_returns_created_response-1680035324\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"},{\"name\":\"Source Code\",\"type\":\"repo\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"},{\"name\":\"Architecture\",\"type\":\"doc\",\"provider\":\"Gigoogle drivetHub\",\"url\":\"https://my-runbook\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":{\"service-url\":\"https://my-org.pagerduty.com/service-directory/PMyService\"},\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "72ca4737-2ba9-f530-cc11-4beb453c24c0" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/services/definitions/service-test-create_or_update_service_definition_using_schema_v2_1_returns_created_response-1680035324", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Not Found\"],\"error_details\":[{}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "095fc5c1-35d5-6086-29c0-cfcf585c5370" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.freeze b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.freeze new file mode 100644 index 00000000000..99e42221149 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2023-03-24T19:21:51.782Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.json b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.json new file mode 100644 index 00000000000..d22f014f9de --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_returns_CREATED_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"contacts\":[{\"contact\":\"contact@datadoghq.com\",\"name\":\"Team Email\",\"type\":\"email\"}],\"dd-service\":\"service-testcreateorupdateservicedefinitionusingschemav2returnscreatedresponse1679685711\",\"dd-team\":\"my-team\",\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"extensions\":{\"myorgextension\":\"extensionvalue\"},\"integrations\":{\"opsgenie\":{\"region\":\"US\",\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\"},\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"schema-version\":\"v2\",\"tags\":[\"my:tag\",\"service:tag\"],\"team\":\"my-team\"}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/services/definitions", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":[{\"type\":\"service-definition\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2023-03-24T19:21:52.44477064Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"unknown\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2\"},\"schema\":{\"schema-version\":\"v2\",\"dd-service\":\"service-testcreateorupdateservicedefinitionusingschemav2returnscreatedresponse1679685711\",\"dd-team\":\"my-team\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\",\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "2a1248a6-e815-cd1e-3c06-7c0c75897ad1" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/services/definitions/service-testcreateorupdateservicedefinitionusingschemav2returnscreatedresponse1679685711", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Not Found\"],\"error_details\":[{}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 404, + "reasonPhrase": "Not Found" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "50c7a101-31bf-6212-1179-27d0dd7e15af" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index 4d110816609..868c8c12e3d 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -448,7 +448,7 @@ "parameters": [ { "name": "body", - "value": "{\n \"dd-service\": \"service-{{ unique}}\",\n \"dd-team\": \"my-team\",\n \"docs\": [{\"name\": \"Architecture\",\n \"provider\": \"google drive\",\n \"url\": \"https://gdrive/mygivedoc\"}],\n \"extensions\": {\"frogextension\": \"extensionfrogvalue\"},\n \"integrations\": {\"opsgenie\": {\"region\": \"US\",\n \"service-url\": \"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\n \"pagerduty\": \"https://my-org.pagerduty.com/service-directory/PMyService\"},\n \"links\": [{\"name\": \"Runbook\", \"type\": \"runbook\", \"url\": \"https://my-runbook\"}],\n \"repos\": [{\"name\": \"Source Code\",\n \"provider\": \"GitHub\",\n \"url\": \"https://github.com/DataDog/given\"}],\n \"schema-version\": \"v2\",\n \"tags\": [\"this:tag\", \"service:tag\"],\n \"team\": \"super-team\"\n}" + "value": "{\n \"dd-service\": \"service-{{ unique_lower_alnum }}\",\n \"dd-team\": \"my-team\",\n \"docs\": [{\"name\": \"Architecture\",\n \"provider\": \"google drive\",\n \"url\": \"https://gdrive/mygivedoc\"}],\n \"extensions\": {\"frogextension\": \"extensionfrogvalue\"},\n \"integrations\": {\"opsgenie\": {\"region\": \"US\",\n \"service-url\": \"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\"},\n \"pagerduty\": \"https://my-org.pagerduty.com/service-directory/PMyService\"},\n \"links\": [{\"name\": \"Runbook\", \"type\": \"runbook\", \"url\": \"https://my-runbook\"}],\n \"repos\": [{\"name\": \"Source Code\",\n \"provider\": \"GitHub\",\n \"url\": \"https://github.com/DataDog/given\"}],\n \"schema-version\": \"v2\",\n \"tags\": [\"this:tag\", \"service:tag\"],\n \"team\": \"super-team\"\n}" } ], "step": "there is a valid \"service_definition\" in the system", diff --git a/src/test/resources/com/datadog/api/client/v2/api/service_definition.feature b/src/test/resources/com/datadog/api/client/v2/api/service_definition.feature index be57dce43bf..e2571848daf 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/service_definition.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/service_definition.feature @@ -7,37 +7,53 @@ Feature: Service Definition And a valid "appKeyAuth" key in the system And an instance of "ServiceDefinition" API - @generated @skip @team:DataDog/apm-insights + @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "Bad Request" response Given new "CreateOrUpdateServiceDefinitions" request - And body with value {"contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "my-service", "dd-team": "my-team", "docs": [{"name": "Architecture", "provider": "google drive", "url": "https://gdrive/mydoc"}], "extensions": {"myorg/extension": "extensionValue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": "https://my-org.pagerduty.com/service-directory/PMyService"}, "links": [{"name": "Runbook", "type": "runbook", "url": "https://my-runbook"}], "repos": [{"name": "Source Code", "provider": "GitHub", "url": "https://github.com/DataDog/schema"}], "schema-version": "v2", "tags": ["my:tag", "service:tag"], "team": "my-team"} + And body with value {"application": "my-app", "contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "my-service", "description": "My service description", "extensions": {"myorg/extension": "extensionValue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": {"service-url": "https://my-org.pagerduty.com/service-directory/PMyService"}}, "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.1", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 400 Bad Request - @team:DataDog/apm-insights + @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "CREATED" response Given new "CreateOrUpdateServiceDefinitions" request - And body with value {"contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "service-{{ unique }}", "dd-team": "my-team", "docs": [{"name": "Architecture", "provider": "google drive", "url": "https://gdrive/mydoc"}], "extensions": {"myorgextension": "extensionvalue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": "https://my-org.pagerduty.com/service-directory/PMyService"}, "links": [{"name": "Runbook", "type": "runbook", "url": "https://my-runbook"}], "repos": [{"name": "Source Code", "provider": "GitHub", "url": "https://github.com/DataDog/schema"}], "schema-version": "v2", "tags": ["my:tag", "service:tag"], "team": "my-team"} + And body with value {"application": "my-app", "contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "my-service", "description": "My service description", "extensions": {"myorg/extension": "extensionValue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": {"service-url": "https://my-org.pagerduty.com/service-directory/PMyService"}}, "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.1", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 200 CREATED - And the response "data[0].attributes.meta.ingested-schema-version" is equal to "v2" - And the response "data[0].attributes.schema.dd-service" is equal to "service-{{ unique_lower }}" - @generated @skip @team:DataDog/apm-insights + @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "Conflict" response Given new "CreateOrUpdateServiceDefinitions" request - And body with value {"contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "my-service", "dd-team": "my-team", "docs": [{"name": "Architecture", "provider": "google drive", "url": "https://gdrive/mydoc"}], "extensions": {"myorg/extension": "extensionValue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": "https://my-org.pagerduty.com/service-directory/PMyService"}, "links": [{"name": "Runbook", "type": "runbook", "url": "https://my-runbook"}], "repos": [{"name": "Source Code", "provider": "GitHub", "url": "https://github.com/DataDog/schema"}], "schema-version": "v2", "tags": ["my:tag", "service:tag"], "team": "my-team"} + And body with value {"application": "my-app", "contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "my-service", "description": "My service description", "extensions": {"myorg/extension": "extensionValue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": {"service-url": "https://my-org.pagerduty.com/service-directory/PMyService"}}, "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.1", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 409 Conflict - @generated @skip @team:DataDog/apm-insights + @team:DataDog/service-catalog + Scenario: Create or update service definition using schema v2 returns "CREATED" response + Given new "CreateOrUpdateServiceDefinitions" request + And body with value {"contacts": [{"contact": "contact@datadoghq.com", "name": "Team Email", "type": "email"}], "dd-service": "service-{{ unique_lower_alnum }}", "dd-team": "my-team", "docs": [{"name": "Architecture", "provider": "google drive", "url": "https://gdrive/mydoc"}], "extensions": {"myorgextension": "extensionvalue"}, "integrations": {"opsgenie": {"region": "US", "service-url": "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"}, "pagerduty": "https://my-org.pagerduty.com/service-directory/PMyService"}, "links": [{"name": "Runbook", "type": "runbook", "url": "https://my-runbook"}], "repos": [{"name": "Source Code", "provider": "GitHub", "url": "https://github.com/DataDog/schema"}], "schema-version": "v2", "tags": ["my:tag", "service:tag"], "team": "my-team"} + When the request is sent + Then the response status is 200 CREATED + And the response "data[0].attributes.meta.ingested-schema-version" is equal to "v2" + And the response "data[0].attributes.schema.dd-service" is equal to "service-{{ unique_lower_alnum }}" + + @team:DataDog/service-catalog + Scenario: Create or update service definition using schema v2-1 returns "CREATED" response + Given new "CreateOrUpdateServiceDefinitions" request + And body with value {"contacts":[{"contact":"contact@datadoghq.com","name":"Team Email","type":"email"}],"dd-service":"service-{{ unique }}","extensions":{"myorgextension":"extensionvalue"},"integrations":{"opsgenie":{"region":"US","service-url":"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000"},"pagerduty":{"service-url":"https://my-org.pagerduty.com/service-directory/PMyService"}},"links":[{"name":"Runbook","type":"runbook","url":"https://my-runbook"},{"name":"Source Code","type":"repo","provider":"GitHub","url":"https://github.com/DataDog/schema"},{"name":"Architecture","type":"doc","provider":"Gigoogle drivetHub","url":"https://my-runbook"}],"schema-version":"v2.1","tags":["my:tag","service:tag"],"team":"my-team"} + When the request is sent + Then the response status is 200 CREATED + And the response "data[0].attributes.meta.ingested-schema-version" is equal to "v2.1" + And the response "data[0].attributes.schema.dd-service" is equal to "service-{{ unique_lower }}" + + @generated @skip @team:DataDog/service-catalog Scenario: Delete a single service definition returns "Bad Request" response Given new "DeleteServiceDefinition" request And request contains "service_name" parameter from "REPLACE.ME" When the request is sent Then the response status is 400 Bad Request - @team:DataDog/apm-insights + @team:DataDog/service-catalog Scenario: Delete a single service definition returns "Not Found" response Given new "DeleteServiceDefinition" request And request contains "service_name" parameter with value "not-a-service" @@ -45,28 +61,28 @@ Feature: Service Definition Then the response status is 404 Not Found And the response "errors[0]" is equal to "Not Found" - @replay-only @team:DataDog/apm-insights + @replay-only @team:DataDog/service-catalog Scenario: Delete a single service definition returns "OK" response Given new "DeleteServiceDefinition" request And request contains "service_name" parameter with value "service-definition-test" When the request is sent Then the response status is 204 OK - @generated @skip @team:DataDog/apm-insights + @generated @skip @team:DataDog/service-catalog Scenario: Get a single service definition returns "Bad Request" response Given new "GetServiceDefinition" request And request contains "service_name" parameter from "REPLACE.ME" When the request is sent Then the response status is 400 Bad Request - @generated @skip @team:DataDog/apm-insights + @generated @skip @team:DataDog/service-catalog Scenario: Get a single service definition returns "Conflict" response Given new "GetServiceDefinition" request And request contains "service_name" parameter from "REPLACE.ME" When the request is sent Then the response status is 409 Conflict - @team:DataDog/apm-insights + @team:DataDog/service-catalog Scenario: Get a single service definition returns "Not Found" response Given new "GetServiceDefinition" request And request contains "service_name" parameter with value "not-a-service" @@ -74,7 +90,7 @@ Feature: Service Definition Then the response status is 404 Not Found And the response "errors[0]" is equal to "Not Found" - @team:DataDog/apm-insights + @team:DataDog/service-catalog Scenario: Get a single service definition returns "OK" response Given new "GetServiceDefinition" request And request contains "service_name" parameter with value "service-definition-test" @@ -83,7 +99,7 @@ Feature: Service Definition And the response "data.attributes.meta.ingested-schema-version" is equal to "v2" And the response "data.attributes.schema.dd-service" is equal to "service-definition-test" - @team:DataDog/apm-insights + @team:DataDog/service-catalog Scenario: Get all service definitions returns "OK" response Given new "ListServiceDefinitions" request When the request is sent