diff --git a/.apigentools-info b/.apigentools-info index 34374357b2f..241a5c8737e 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-10 07:51:59.438918", - "spec_repo_commit": "6482b048" + "regenerated": "2023-10-10 13:47:40.326078", + "spec_repo_commit": "afb48804" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-10 07:51:59.459329", - "spec_repo_commit": "6482b048" + "regenerated": "2023-10-10 13:47:40.346011", + "spec_repo_commit": "afb48804" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 0eca5ce93f5..2975fa2f445 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -14994,6 +14994,7 @@ components: - $ref: '#/components/schemas/ServiceDefinitionV1' - $ref: '#/components/schemas/ServiceDefinitionV2' - $ref: '#/components/schemas/ServiceDefinitionV2Dot1' + - $ref: '#/components/schemas/ServiceDefinitionV2Dot2' type: object ServiceDefinitionSchemaVersions: description: Schema versions @@ -15001,11 +15002,13 @@ components: - v1 - v2 - v2.1 + - v2.2 type: string x-enum-varnames: - V1 - V2 - V2_1 + - V2_2 ServiceDefinitionV1: deprecated: true description: Deprecated - Service definition V1 for providing additional service @@ -15466,6 +15469,181 @@ components: type: string x-enum-varnames: - V2_1 + ServiceDefinitionV2Dot2: + description: Service definition v2.2 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/ServiceDefinitionV2Dot2Contact' + 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.2 schema. + example: + myorg/extension: extensionValue + type: object + integrations: + $ref: '#/components/schemas/ServiceDefinitionV2Dot2Integrations' + langauges: + description: 'The service''s programming language. Datadog recognizes the + following languages: `dotnet`, `go`, `java`, `js`, `php`, `python`, `ruby`, + and `c++`.' + example: + - dotnet + - go + - java + - js + - php + - python + - ruby + - c++ + items: + type: string + type: array + 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/ServiceDefinitionV2Dot2Link' + type: array + schema-version: + $ref: '#/components/schemas/ServiceDefinitionV2Dot2Version' + service-type: + description: 'The type of service. Datadog recognizes the following service + types: `database`, `cache`, `function`, `web`, `browser`, and `mobile`.' + example: web + type: string + 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 + ServiceDefinitionV2Dot2Contact: + description: Service owner's contacts information. + properties: + contact: + description: Contact value. + example: https://teams.microsoft.com/myteam + type: string + name: + description: Contact Name. + example: My team channel + type: string + type: + description: 'Contact type. Datadog recognizes the following types: `email`, + `slack`, and `microsoft-teams`.' + example: slack + type: string + required: + - type + - contact + type: object + ServiceDefinitionV2Dot2Integrations: + description: Third party integrations that Datadog supports. + properties: + opsgenie: + $ref: '#/components/schemas/ServiceDefinitionV2Dot2Opsgenie' + pagerduty: + $ref: '#/components/schemas/ServiceDefinitionV2Dot2Pagerduty' + type: object + ServiceDefinitionV2Dot2Link: + description: Service's external links. + properties: + name: + description: Link name. + example: Runbook + type: string + provider: + description: Link provider. + example: Github + type: string + type: + description: 'Link type. Datadog recognizes the following types: `runbook`, + `doc`, `repo`, `dashboard`, and `other`.' + example: runbook + type: string + url: + description: Link URL. + example: https://my-runbook + type: string + required: + - name + - type + - url + type: object + ServiceDefinitionV2Dot2Opsgenie: + description: Opsgenie integration for the service. + properties: + region: + $ref: '#/components/schemas/ServiceDefinitionV2Dot2OpsgenieRegion' + 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 + ServiceDefinitionV2Dot2OpsgenieRegion: + description: Opsgenie instance region. + enum: + - US + - EU + example: US + type: string + x-enum-varnames: + - US + - EU + ServiceDefinitionV2Dot2Pagerduty: + 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 + ServiceDefinitionV2Dot2Version: + default: v2.2 + description: Schema version being used. + enum: + - v2.2 + example: v2.2 + type: string + x-enum-varnames: + - V2_2 ServiceDefinitionV2Email: description: Service owner's email. properties: @@ -15649,6 +15827,7 @@ components: ServiceDefinitionsCreateRequest: description: Create service definitions request. oneOf: + - $ref: '#/components/schemas/ServiceDefinitionV2Dot2' - $ref: '#/components/schemas/ServiceDefinitionV2Dot1' - $ref: '#/components/schemas/ServiceDefinitionV2' - $ref: '#/components/schemas/ServiceDefinitionRaw' diff --git a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java index 8677319775c..830b9caefe7 100644 --- a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java +++ b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions.java @@ -4,17 +4,14 @@ 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.ServiceDefinitionV2Dot2; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Contact; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Integrations; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Link; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Opsgenie; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2OpsgenieRegion; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Pagerduty; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Version; import com.datadog.api.client.v2.model.ServiceDefinitionsCreateRequest; import java.util.Arrays; import java.util.Collections; @@ -27,38 +24,40 @@ public static void main(String[] args) { ServiceDefinitionsCreateRequest body = new ServiceDefinitionsCreateRequest( - new ServiceDefinitionV2Dot1() + new ServiceDefinitionV2Dot2() .application("my-app") .contacts( Collections.singletonList( - new ServiceDefinitionV2Dot1Contact( - new ServiceDefinitionV2Dot1Email() - .contact("contact@datadoghq.com") - .name("Team Email") - .type(ServiceDefinitionV2Dot1EmailType.EMAIL)))) + new ServiceDefinitionV2Dot2Contact() + .contact("https://teams.microsoft.com/myteam") + .name("My team channel") + .type("slack"))) .ddService("my-service") .description("My service description") .extensions(Map.ofEntries(Map.entry("myorg/extension", "extensionValue"))) .integrations( - new ServiceDefinitionV2Dot1Integrations() + new ServiceDefinitionV2Dot2Integrations() .opsgenie( - new ServiceDefinitionV2Dot1Opsgenie() - .region(ServiceDefinitionV2Dot1OpsgenieRegion.US) + new ServiceDefinitionV2Dot2Opsgenie() + .region(ServiceDefinitionV2Dot2OpsgenieRegion.US) .serviceUrl( "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000")) .pagerduty( - new ServiceDefinitionV2Dot1Pagerduty() + new ServiceDefinitionV2Dot2Pagerduty() .serviceUrl( "https://my-org.pagerduty.com/service-directory/PMyService"))) + .langauges( + Arrays.asList("dotnet", "go", "java", "js", "php", "python", "ruby", "c++")) .lifecycle("sandbox") .links( Collections.singletonList( - new ServiceDefinitionV2Dot1Link() + new ServiceDefinitionV2Dot2Link() .name("Runbook") .provider("Github") - .type(ServiceDefinitionV2Dot1LinkType.RUNBOOK) + .type("runbook") .url("https://my-runbook"))) - .schemaVersion(ServiceDefinitionV2Dot1Version.V2_1) + .schemaVersion(ServiceDefinitionV2Dot2Version.V2_2) + .serviceType("web") .tags(Arrays.asList("my:tag", "service:tag")) .team("my-team") .tier("High")); diff --git a/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2621709423.java b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2621709423.java new file mode 100644 index 00000000000..7b0a7c58a95 --- /dev/null +++ b/examples/v2/service-definition/CreateOrUpdateServiceDefinitions_2621709423.java @@ -0,0 +1,79 @@ +// Create or update service definition using schema v2-2 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.ServiceDefinitionV2Dot2; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Contact; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Integrations; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Link; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Opsgenie; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2OpsgenieRegion; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Pagerduty; +import com.datadog.api.client.v2.model.ServiceDefinitionV2Dot2Version; +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 ServiceDefinitionV2Dot2() + .contacts( + Collections.singletonList( + new ServiceDefinitionV2Dot2Contact() + .contact("contact@datadoghq.com") + .name("Team Email") + .type("email"))) + .ddService("service-exampleservicedefinition") + .extensions(Map.ofEntries(Map.entry("myorgextension", "extensionvalue"))) + .integrations( + new ServiceDefinitionV2Dot2Integrations() + .opsgenie( + new ServiceDefinitionV2Dot2Opsgenie() + .region(ServiceDefinitionV2Dot2OpsgenieRegion.US) + .serviceUrl( + "https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000")) + .pagerduty( + new ServiceDefinitionV2Dot2Pagerduty() + .serviceUrl( + "https://my-org.pagerduty.com/service-directory/PMyService"))) + .links( + Arrays.asList( + new ServiceDefinitionV2Dot2Link() + .name("Runbook") + .type("runbook") + .url("https://my-runbook"), + new ServiceDefinitionV2Dot2Link() + .name("Source Code") + .type("repo") + .provider("GitHub") + .url("https://github.com/DataDog/schema"), + new ServiceDefinitionV2Dot2Link() + .name("Architecture") + .type("doc") + .provider("Gigoogle drivetHub") + .url("https://my-runbook"))) + .schemaVersion(ServiceDefinitionV2Dot2Version.V2_2) + .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 5aa7a7c0b25..7fe2b3d7df3 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 @@ -213,6 +213,51 @@ public ServiceDefinitionSchema deserialize(JsonParser jp, DeserializationContext log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot1'", e); } + // deserialize ServiceDefinitionV2Dot2 + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot2.class.equals(Integer.class) + || ServiceDefinitionV2Dot2.class.equals(Long.class) + || ServiceDefinitionV2Dot2.class.equals(Float.class) + || ServiceDefinitionV2Dot2.class.equals(Double.class) + || ServiceDefinitionV2Dot2.class.equals(Boolean.class) + || ServiceDefinitionV2Dot2.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot2.class.equals(Integer.class) + || ServiceDefinitionV2Dot2.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot2.class.equals(Float.class) + || ServiceDefinitionV2Dot2.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot2.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot2.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot2.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 (!((ServiceDefinitionV2Dot2) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot2'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot2'", e); + } + ServiceDefinitionSchema ret = new ServiceDefinitionSchema(); if (match == 1) { ret.setActualInstance(deserialized); @@ -257,10 +302,16 @@ public ServiceDefinitionSchema(ServiceDefinitionV2Dot1 o) { setActualInstance(o); } + public ServiceDefinitionSchema(ServiceDefinitionV2Dot2 o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("ServiceDefinitionV1", new GenericType() {}); schemas.put("ServiceDefinitionV2", new GenericType() {}); schemas.put("ServiceDefinitionV2Dot1", new GenericType() {}); + schemas.put("ServiceDefinitionV2Dot2", new GenericType() {}); JSON.registerDescendants(ServiceDefinitionSchema.class, Collections.unmodifiableMap(schemas)); } @@ -272,7 +323,7 @@ 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, - * ServiceDefinitionV2Dot1 + * ServiceDefinitionV2Dot1, ServiceDefinitionV2Dot2 * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -291,6 +342,10 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(ServiceDefinitionV2Dot2.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); @@ -298,14 +353,15 @@ public void setActualInstance(Object instance) { } throw new RuntimeException( "Invalid instance type. Must be ServiceDefinitionV1, ServiceDefinitionV2," - + " ServiceDefinitionV2Dot1"); + + " ServiceDefinitionV2Dot1, ServiceDefinitionV2Dot2"); } /** * Get the actual instance, which can be the following: ServiceDefinitionV1, ServiceDefinitionV2, - * ServiceDefinitionV2Dot1 + * ServiceDefinitionV2Dot1, ServiceDefinitionV2Dot2 * - * @return The actual instance (ServiceDefinitionV1, ServiceDefinitionV2, ServiceDefinitionV2Dot1) + * @return The actual instance (ServiceDefinitionV1, ServiceDefinitionV2, ServiceDefinitionV2Dot1, + * ServiceDefinitionV2Dot2) */ @Override public Object getActualInstance() { @@ -344,4 +400,15 @@ public ServiceDefinitionV2 getServiceDefinitionV2() throws ClassCastException { public ServiceDefinitionV2Dot1 getServiceDefinitionV2Dot1() throws ClassCastException { return (ServiceDefinitionV2Dot1) super.getActualInstance(); } + + /** + * Get the actual instance of `ServiceDefinitionV2Dot2`. If the actual instance is not + * `ServiceDefinitionV2Dot2`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot2` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot2` + */ + public ServiceDefinitionV2Dot2 getServiceDefinitionV2Dot2() throws ClassCastException { + return (ServiceDefinitionV2Dot2) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchemaVersions.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchemaVersions.java index 8c3a7d77b96..3bde44ca628 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchemaVersions.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionSchemaVersions.java @@ -24,7 +24,7 @@ public class ServiceDefinitionSchemaVersions extends ModelEnum { private static final Set allowedValues = - new HashSet(Arrays.asList("v1", "v2", "v2.1")); + new HashSet(Arrays.asList("v1", "v2", "v2.1", "v2.2")); public static final ServiceDefinitionSchemaVersions V1 = new ServiceDefinitionSchemaVersions("v1"); @@ -32,6 +32,8 @@ public class ServiceDefinitionSchemaVersions extends ModelEnum { new ServiceDefinitionSchemaVersions("v2"); public static final ServiceDefinitionSchemaVersions V2_1 = new ServiceDefinitionSchemaVersions("v2.1"); + public static final ServiceDefinitionSchemaVersions V2_2 = + new ServiceDefinitionSchemaVersions("v2.2"); ServiceDefinitionSchemaVersions(String value) { super(value, allowedValues); diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2.java new file mode 100644 index 00000000000..7a6d445f70e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2.java @@ -0,0 +1,575 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Service definition v2.2 for providing service metadata and integrations. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot2.JSON_PROPERTY_APPLICATION, + ServiceDefinitionV2Dot2.JSON_PROPERTY_CONTACTS, + ServiceDefinitionV2Dot2.JSON_PROPERTY_DD_SERVICE, + ServiceDefinitionV2Dot2.JSON_PROPERTY_DESCRIPTION, + ServiceDefinitionV2Dot2.JSON_PROPERTY_EXTENSIONS, + ServiceDefinitionV2Dot2.JSON_PROPERTY_INTEGRATIONS, + ServiceDefinitionV2Dot2.JSON_PROPERTY_LANGAUGES, + ServiceDefinitionV2Dot2.JSON_PROPERTY_LIFECYCLE, + ServiceDefinitionV2Dot2.JSON_PROPERTY_LINKS, + ServiceDefinitionV2Dot2.JSON_PROPERTY_SCHEMA_VERSION, + ServiceDefinitionV2Dot2.JSON_PROPERTY_SERVICE_TYPE, + ServiceDefinitionV2Dot2.JSON_PROPERTY_TAGS, + ServiceDefinitionV2Dot2.JSON_PROPERTY_TEAM, + ServiceDefinitionV2Dot2.JSON_PROPERTY_TIER +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2 { + @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 ServiceDefinitionV2Dot2Integrations integrations; + + public static final String JSON_PROPERTY_LANGAUGES = "langauges"; + private List langauges = null; + + 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 ServiceDefinitionV2Dot2Version schemaVersion = ServiceDefinitionV2Dot2Version.V2_2; + + public static final String JSON_PROPERTY_SERVICE_TYPE = "service-type"; + private String serviceType; + + 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 ServiceDefinitionV2Dot2() {} + + @JsonCreator + public ServiceDefinitionV2Dot2( + @JsonProperty(required = true, value = JSON_PROPERTY_DD_SERVICE) String ddService, + @JsonProperty(required = true, value = JSON_PROPERTY_SCHEMA_VERSION) + ServiceDefinitionV2Dot2Version schemaVersion) { + this.ddService = ddService; + this.schemaVersion = schemaVersion; + this.unparsed |= !schemaVersion.isValid(); + } + + public ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 contacts(List contacts) { + this.contacts = contacts; + for (ServiceDefinitionV2Dot2Contact item : contacts) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ServiceDefinitionV2Dot2 addContactsItem(ServiceDefinitionV2Dot2Contact 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 ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 extensions(Map extensions) { + this.extensions = extensions; + return this; + } + + public ServiceDefinitionV2Dot2 putExtensionsItem(String key, Object extensionsItem) { + if (this.extensions == null) { + this.extensions = new HashMap<>(); + } + this.extensions.put(key, extensionsItem); + return this; + } + + /** + * Extensions to v2.2 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 ServiceDefinitionV2Dot2 integrations(ServiceDefinitionV2Dot2Integrations 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 ServiceDefinitionV2Dot2Integrations getIntegrations() { + return integrations; + } + + public void setIntegrations(ServiceDefinitionV2Dot2Integrations integrations) { + this.integrations = integrations; + } + + public ServiceDefinitionV2Dot2 langauges(List langauges) { + this.langauges = langauges; + return this; + } + + public ServiceDefinitionV2Dot2 addLangaugesItem(String langaugesItem) { + if (this.langauges == null) { + this.langauges = new ArrayList<>(); + } + this.langauges.add(langaugesItem); + return this; + } + + /** + * The service's programming language. Datadog recognizes the following languages: dotnet + * , go, java, js, php, python + * , ruby, and c++. + * + * @return langauges + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LANGAUGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLangauges() { + return langauges; + } + + public void setLangauges(List langauges) { + this.langauges = langauges; + } + + public ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 links(List links) { + this.links = links; + for (ServiceDefinitionV2Dot2Link item : links) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ServiceDefinitionV2Dot2 addLinksItem(ServiceDefinitionV2Dot2Link 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 ServiceDefinitionV2Dot2 schemaVersion(ServiceDefinitionV2Dot2Version 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 ServiceDefinitionV2Dot2Version getSchemaVersion() { + return schemaVersion; + } + + public void setSchemaVersion(ServiceDefinitionV2Dot2Version schemaVersion) { + if (!schemaVersion.isValid()) { + this.unparsed = true; + } + this.schemaVersion = schemaVersion; + } + + public ServiceDefinitionV2Dot2 serviceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + /** + * The type of service. Datadog recognizes the following service types: database, + * cache, function, web, browser, and + * mobile. + * + * @return serviceType + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SERVICE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public ServiceDefinitionV2Dot2 tags(List tags) { + this.tags = tags; + return this; + } + + public ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 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 ServiceDefinitionV2Dot2 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; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2 + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2 object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2 serviceDefinitionV2Dot2 = (ServiceDefinitionV2Dot2) o; + return Objects.equals(this.application, serviceDefinitionV2Dot2.application) + && Objects.equals(this.contacts, serviceDefinitionV2Dot2.contacts) + && Objects.equals(this.ddService, serviceDefinitionV2Dot2.ddService) + && Objects.equals(this.description, serviceDefinitionV2Dot2.description) + && Objects.equals(this.extensions, serviceDefinitionV2Dot2.extensions) + && Objects.equals(this.integrations, serviceDefinitionV2Dot2.integrations) + && Objects.equals(this.langauges, serviceDefinitionV2Dot2.langauges) + && Objects.equals(this.lifecycle, serviceDefinitionV2Dot2.lifecycle) + && Objects.equals(this.links, serviceDefinitionV2Dot2.links) + && Objects.equals(this.schemaVersion, serviceDefinitionV2Dot2.schemaVersion) + && Objects.equals(this.serviceType, serviceDefinitionV2Dot2.serviceType) + && Objects.equals(this.tags, serviceDefinitionV2Dot2.tags) + && Objects.equals(this.team, serviceDefinitionV2Dot2.team) + && Objects.equals(this.tier, serviceDefinitionV2Dot2.tier) + && Objects.equals(this.additionalProperties, serviceDefinitionV2Dot2.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + application, + contacts, + ddService, + description, + extensions, + integrations, + langauges, + lifecycle, + links, + schemaVersion, + serviceType, + tags, + team, + tier, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2 {\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(" langauges: ").append(toIndentedString(langauges)).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(" serviceType: ").append(toIndentedString(serviceType)).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(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Contact.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Contact.java new file mode 100644 index 00000000000..7fb81aa0997 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Contact.java @@ -0,0 +1,203 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Service owner's contacts information. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot2Contact.JSON_PROPERTY_CONTACT, + ServiceDefinitionV2Dot2Contact.JSON_PROPERTY_NAME, + ServiceDefinitionV2Dot2Contact.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2Contact { + @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 String type; + + public ServiceDefinitionV2Dot2Contact() {} + + @JsonCreator + public ServiceDefinitionV2Dot2Contact( + @JsonProperty(required = true, value = JSON_PROPERTY_CONTACT) String contact, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type) { + this.contact = contact; + this.type = type; + } + + public ServiceDefinitionV2Dot2Contact 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 ServiceDefinitionV2Dot2Contact name(String name) { + this.name = name; + return this; + } + + /** + * Contact Name. + * + * @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 ServiceDefinitionV2Dot2Contact type(String type) { + this.type = type; + return this; + } + + /** + * Contact type. Datadog recognizes the following types: email, slack, + * and microsoft-teams. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2Contact + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2Contact putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2Contact object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2Contact serviceDefinitionV2Dot2Contact = + (ServiceDefinitionV2Dot2Contact) o; + return Objects.equals(this.contact, serviceDefinitionV2Dot2Contact.contact) + && Objects.equals(this.name, serviceDefinitionV2Dot2Contact.name) + && Objects.equals(this.type, serviceDefinitionV2Dot2Contact.type) + && Objects.equals( + this.additionalProperties, serviceDefinitionV2Dot2Contact.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(contact, name, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2Contact {\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(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Integrations.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Integrations.java new file mode 100644 index 00000000000..0c9f1def95d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Integrations.java @@ -0,0 +1,168 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Third party integrations that Datadog supports. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot2Integrations.JSON_PROPERTY_OPSGENIE, + ServiceDefinitionV2Dot2Integrations.JSON_PROPERTY_PAGERDUTY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2Integrations { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OPSGENIE = "opsgenie"; + private ServiceDefinitionV2Dot2Opsgenie opsgenie; + + public static final String JSON_PROPERTY_PAGERDUTY = "pagerduty"; + private ServiceDefinitionV2Dot2Pagerduty pagerduty; + + public ServiceDefinitionV2Dot2Integrations opsgenie(ServiceDefinitionV2Dot2Opsgenie 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 ServiceDefinitionV2Dot2Opsgenie getOpsgenie() { + return opsgenie; + } + + public void setOpsgenie(ServiceDefinitionV2Dot2Opsgenie opsgenie) { + this.opsgenie = opsgenie; + } + + public ServiceDefinitionV2Dot2Integrations pagerduty(ServiceDefinitionV2Dot2Pagerduty 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 ServiceDefinitionV2Dot2Pagerduty getPagerduty() { + return pagerduty; + } + + public void setPagerduty(ServiceDefinitionV2Dot2Pagerduty pagerduty) { + this.pagerduty = pagerduty; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2Integrations + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2Integrations putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2Integrations object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2Integrations serviceDefinitionV2Dot2Integrations = + (ServiceDefinitionV2Dot2Integrations) o; + return Objects.equals(this.opsgenie, serviceDefinitionV2Dot2Integrations.opsgenie) + && Objects.equals(this.pagerduty, serviceDefinitionV2Dot2Integrations.pagerduty) + && Objects.equals( + this.additionalProperties, serviceDefinitionV2Dot2Integrations.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(opsgenie, pagerduty, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2Integrations {\n"); + sb.append(" opsgenie: ").append(toIndentedString(opsgenie)).append("\n"); + sb.append(" pagerduty: ").append(toIndentedString(pagerduty)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Link.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Link.java new file mode 100644 index 00000000000..aca72a11db6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Link.java @@ -0,0 +1,230 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Service's external links. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot2Link.JSON_PROPERTY_NAME, + ServiceDefinitionV2Dot2Link.JSON_PROPERTY_PROVIDER, + ServiceDefinitionV2Dot2Link.JSON_PROPERTY_TYPE, + ServiceDefinitionV2Dot2Link.JSON_PROPERTY_URL +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2Link { + @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 String type; + + public static final String JSON_PROPERTY_URL = "url"; + private String url; + + public ServiceDefinitionV2Dot2Link() {} + + @JsonCreator + public ServiceDefinitionV2Dot2Link( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type, + @JsonProperty(required = true, value = JSON_PROPERTY_URL) String url) { + this.name = name; + this.type = type; + this.url = url; + } + + public ServiceDefinitionV2Dot2Link 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 ServiceDefinitionV2Dot2Link 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 ServiceDefinitionV2Dot2Link type(String type) { + this.type = type; + return this; + } + + /** + * Link type. Datadog recognizes the following types: runbook, doc, + * repo, dashboard, and other. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ServiceDefinitionV2Dot2Link 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; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2Link + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2Link putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2Link object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2Link serviceDefinitionV2Dot2Link = (ServiceDefinitionV2Dot2Link) o; + return Objects.equals(this.name, serviceDefinitionV2Dot2Link.name) + && Objects.equals(this.provider, serviceDefinitionV2Dot2Link.provider) + && Objects.equals(this.type, serviceDefinitionV2Dot2Link.type) + && Objects.equals(this.url, serviceDefinitionV2Dot2Link.url) + && Objects.equals( + this.additionalProperties, serviceDefinitionV2Dot2Link.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, provider, type, url, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2Link {\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(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Opsgenie.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Opsgenie.java new file mode 100644 index 00000000000..6d118c694fc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Opsgenie.java @@ -0,0 +1,178 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Opsgenie integration for the service. */ +@JsonPropertyOrder({ + ServiceDefinitionV2Dot2Opsgenie.JSON_PROPERTY_REGION, + ServiceDefinitionV2Dot2Opsgenie.JSON_PROPERTY_SERVICE_URL +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2Opsgenie { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_REGION = "region"; + private ServiceDefinitionV2Dot2OpsgenieRegion region; + + public static final String JSON_PROPERTY_SERVICE_URL = "service-url"; + private String serviceUrl; + + public ServiceDefinitionV2Dot2Opsgenie() {} + + @JsonCreator + public ServiceDefinitionV2Dot2Opsgenie( + @JsonProperty(required = true, value = JSON_PROPERTY_SERVICE_URL) String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public ServiceDefinitionV2Dot2Opsgenie region(ServiceDefinitionV2Dot2OpsgenieRegion 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 ServiceDefinitionV2Dot2OpsgenieRegion getRegion() { + return region; + } + + public void setRegion(ServiceDefinitionV2Dot2OpsgenieRegion region) { + if (!region.isValid()) { + this.unparsed = true; + } + this.region = region; + } + + public ServiceDefinitionV2Dot2Opsgenie 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; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2Opsgenie + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2Opsgenie putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2Opsgenie object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2Opsgenie serviceDefinitionV2Dot2Opsgenie = + (ServiceDefinitionV2Dot2Opsgenie) o; + return Objects.equals(this.region, serviceDefinitionV2Dot2Opsgenie.region) + && Objects.equals(this.serviceUrl, serviceDefinitionV2Dot2Opsgenie.serviceUrl) + && Objects.equals( + this.additionalProperties, serviceDefinitionV2Dot2Opsgenie.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(region, serviceUrl, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2Opsgenie {\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" serviceUrl: ").append(toIndentedString(serviceUrl)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2OpsgenieRegion.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2OpsgenieRegion.java new file mode 100644 index 00000000000..780fd33f1a2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2OpsgenieRegion.java @@ -0,0 +1,63 @@ +/* + * 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.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Opsgenie instance region. */ +@JsonSerialize( + using = + ServiceDefinitionV2Dot2OpsgenieRegion.ServiceDefinitionV2Dot2OpsgenieRegionSerializer.class) +public class ServiceDefinitionV2Dot2OpsgenieRegion extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("US", "EU")); + + public static final ServiceDefinitionV2Dot2OpsgenieRegion US = + new ServiceDefinitionV2Dot2OpsgenieRegion("US"); + public static final ServiceDefinitionV2Dot2OpsgenieRegion EU = + new ServiceDefinitionV2Dot2OpsgenieRegion("EU"); + + ServiceDefinitionV2Dot2OpsgenieRegion(String value) { + super(value, allowedValues); + } + + public static class ServiceDefinitionV2Dot2OpsgenieRegionSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot2OpsgenieRegionSerializer( + Class t) { + super(t); + } + + public ServiceDefinitionV2Dot2OpsgenieRegionSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot2OpsgenieRegion value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ServiceDefinitionV2Dot2OpsgenieRegion fromValue(String value) { + return new ServiceDefinitionV2Dot2OpsgenieRegion(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Pagerduty.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Pagerduty.java new file mode 100644 index 00000000000..2bc89faa424 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Pagerduty.java @@ -0,0 +1,137 @@ +/* + * 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.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** PagerDuty integration for the service. */ +@JsonPropertyOrder({ServiceDefinitionV2Dot2Pagerduty.JSON_PROPERTY_SERVICE_URL}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ServiceDefinitionV2Dot2Pagerduty { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_SERVICE_URL = "service-url"; + private String serviceUrl; + + public ServiceDefinitionV2Dot2Pagerduty 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; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ServiceDefinitionV2Dot2Pagerduty + */ + @JsonAnySetter + public ServiceDefinitionV2Dot2Pagerduty putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ServiceDefinitionV2Dot2Pagerduty object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceDefinitionV2Dot2Pagerduty serviceDefinitionV2Dot2Pagerduty = + (ServiceDefinitionV2Dot2Pagerduty) o; + return Objects.equals(this.serviceUrl, serviceDefinitionV2Dot2Pagerduty.serviceUrl) + && Objects.equals( + this.additionalProperties, serviceDefinitionV2Dot2Pagerduty.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(serviceUrl, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceDefinitionV2Dot2Pagerduty {\n"); + sb.append(" serviceUrl: ").append(toIndentedString(serviceUrl)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Version.java b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Version.java new file mode 100644 index 00000000000..fa1420cb08d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceDefinitionV2Dot2Version.java @@ -0,0 +1,57 @@ +/* + * 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.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Schema version being used. */ +@JsonSerialize( + using = ServiceDefinitionV2Dot2Version.ServiceDefinitionV2Dot2VersionSerializer.class) +public class ServiceDefinitionV2Dot2Version extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("v2.2")); + + public static final ServiceDefinitionV2Dot2Version V2_2 = + new ServiceDefinitionV2Dot2Version("v2.2"); + + ServiceDefinitionV2Dot2Version(String value) { + super(value, allowedValues); + } + + public static class ServiceDefinitionV2Dot2VersionSerializer + extends StdSerializer { + public ServiceDefinitionV2Dot2VersionSerializer(Class t) { + super(t); + } + + public ServiceDefinitionV2Dot2VersionSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceDefinitionV2Dot2Version value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ServiceDefinitionV2Dot2Version fromValue(String value) { + return new ServiceDefinitionV2Dot2Version(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 d530c74b3ce..30453626bf7 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 ServiceDefinitionV2Dot2 + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ServiceDefinitionV2Dot2.class.equals(Integer.class) + || ServiceDefinitionV2Dot2.class.equals(Long.class) + || ServiceDefinitionV2Dot2.class.equals(Float.class) + || ServiceDefinitionV2Dot2.class.equals(Double.class) + || ServiceDefinitionV2Dot2.class.equals(Boolean.class) + || ServiceDefinitionV2Dot2.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ServiceDefinitionV2Dot2.class.equals(Integer.class) + || ServiceDefinitionV2Dot2.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ServiceDefinitionV2Dot2.class.equals(Float.class) + || ServiceDefinitionV2Dot2.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ServiceDefinitionV2Dot2.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ServiceDefinitionV2Dot2.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ServiceDefinitionV2Dot2.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 (!((ServiceDefinitionV2Dot2) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ServiceDefinitionV2Dot2'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ServiceDefinitionV2Dot2'", e); + } + // deserialize ServiceDefinitionV2Dot1 try { boolean attemptParsing = true; @@ -243,6 +288,11 @@ public ServiceDefinitionsCreateRequest() { super("oneOf", Boolean.FALSE); } + public ServiceDefinitionsCreateRequest(ServiceDefinitionV2Dot2 o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + public ServiceDefinitionsCreateRequest(ServiceDefinitionV2Dot1 o) { super("oneOf", Boolean.FALSE); setActualInstance(o); @@ -259,6 +309,7 @@ public ServiceDefinitionsCreateRequest(String o) { } static { + schemas.put("ServiceDefinitionV2Dot2", new GenericType() {}); schemas.put("ServiceDefinitionV2Dot1", new GenericType() {}); schemas.put("ServiceDefinitionV2", new GenericType() {}); schemas.put("String", new GenericType() {}); @@ -273,13 +324,18 @@ public Map getSchemas() { /** * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: ServiceDefinitionV2Dot1, ServiceDefinitionV2, String + * against the oneOf child schemas: ServiceDefinitionV2Dot2, 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(ServiceDefinitionV2Dot2.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(ServiceDefinitionV2Dot1.class, instance, new HashSet>())) { super.setActualInstance(instance); return; @@ -298,20 +354,33 @@ public void setActualInstance(Object instance) { return; } throw new RuntimeException( - "Invalid instance type. Must be ServiceDefinitionV2Dot1, ServiceDefinitionV2, String"); + "Invalid instance type. Must be ServiceDefinitionV2Dot2, ServiceDefinitionV2Dot1," + + " ServiceDefinitionV2, String"); } /** - * Get the actual instance, which can be the following: ServiceDefinitionV2Dot1, - * ServiceDefinitionV2, String + * Get the actual instance, which can be the following: ServiceDefinitionV2Dot2, + * ServiceDefinitionV2Dot1, ServiceDefinitionV2, String * - * @return The actual instance (ServiceDefinitionV2Dot1, ServiceDefinitionV2, String) + * @return The actual instance (ServiceDefinitionV2Dot2, ServiceDefinitionV2Dot1, + * ServiceDefinitionV2, String) */ @Override public Object getActualInstance() { return super.getActualInstance(); } + /** + * Get the actual instance of `ServiceDefinitionV2Dot2`. If the actual instance is not + * `ServiceDefinitionV2Dot2`, the ClassCastException will be thrown. + * + * @return The actual instance of `ServiceDefinitionV2Dot2` + * @throws ClassCastException if the instance is not `ServiceDefinitionV2Dot2` + */ + public ServiceDefinitionV2Dot2 getServiceDefinitionV2Dot2() throws ClassCastException { + return (ServiceDefinitionV2Dot2) super.getActualInstance(); + } + /** * Get the actual instance of `ServiceDefinitionV2Dot1`. If the actual instance is not * `ServiceDefinitionV2Dot1`, the ClassCastException will be thrown. diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_returns_CREATED_response.freeze b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_returns_CREATED_response.freeze new file mode 100644 index 00000000000..9c222dc6f5a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2023-10-06T18:44:31.430Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_returns_CREATED_response.json b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_returns_CREATED_response.json new file mode 100644 index 00000000000..7d59f370be1 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Create_or_update_service_definition_using_schema_v2_2_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-testcreateorupdateservicedefinitionusingschemav22returnscreatedresponse1696617871\",\"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.2\",\"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-10-06T18:44:32.076834625Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"unknown\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2.2\"},\"schema\":{\"schema-version\":\"v2.2\",\"dd-service\":\"service-testcreateorupdateservicedefinitionusingschemav22returnscreatedresponse1696617871\",\"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": "9fecc08c-e646-b6f0-2234-2c5a3e0f60ee" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/services/definitions/service-testcreateorupdateservicedefinitionusingschemav22returnscreatedresponse1696617871", + "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": "da8b7ea8-fd56-3236-8dc0-1b71951fcebb" + } +] \ No newline at end of file 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 68c55606532..9fbc2c65579 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 @@ -10,21 +10,21 @@ Feature: Service Definition @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "Bad Request" response Given new "CreateOrUpdateServiceDefinitions" request - 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"} + And body with value {"application": "my-app", "contacts": [{"contact": "https://teams.microsoft.com/myteam", "name": "My team channel", "type": "slack"}], "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"}}, "langauges": ["dotnet", "go", "java", "js", "php", "python", "ruby", "c++"], "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.2", "service-type": "web", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "CREATED" response Given new "CreateOrUpdateServiceDefinitions" request - 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"} + And body with value {"application": "my-app", "contacts": [{"contact": "https://teams.microsoft.com/myteam", "name": "My team channel", "type": "slack"}], "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"}}, "langauges": ["dotnet", "go", "java", "js", "php", "python", "ruby", "c++"], "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.2", "service-type": "web", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 200 CREATED @generated @skip @team:DataDog/service-catalog Scenario: Create or update service definition returns "Conflict" response Given new "CreateOrUpdateServiceDefinitions" request - 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"} + And body with value {"application": "my-app", "contacts": [{"contact": "https://teams.microsoft.com/myteam", "name": "My team channel", "type": "slack"}], "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"}}, "langauges": ["dotnet", "go", "java", "js", "php", "python", "ruby", "c++"], "lifecycle": "sandbox", "links": [{"name": "Runbook", "provider": "Github", "type": "runbook", "url": "https://my-runbook"}], "schema-version": "v2.2", "service-type": "web", "tags": ["my:tag", "service:tag"], "team": "my-team", "tier": "High"} When the request is sent Then the response status is 409 Conflict @@ -46,6 +46,15 @@ Feature: Service Definition 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_alnum }}" + @team:DataDog/service-catalog + Scenario: Create or update service definition using schema v2-2 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 }}","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.2","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.2" + And the response "data[0].attributes.schema.dd-service" is equal to "service-{{ unique_lower_alnum }}" + @generated @skip @team:DataDog/service-catalog Scenario: Delete a single service definition returns "Bad Request" response Given new "DeleteServiceDefinition" request