diff --git a/.apigentools-info b/.apigentools-info index a7115837371..e1c846f8987 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-15 19:35:12.585262", - "spec_repo_commit": "ad80112e" + "regenerated": "2024-11-18 20:56:40.713721", + "spec_repo_commit": "2fca32d9" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-15 19:35:12.605121", - "spec_repo_commit": "ad80112e" + "regenerated": "2024-11-18 20:56:40.732552", + "spec_repo_commit": "2fca32d9" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4f1a562ac59..c0bd32e67c9 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4556,6 +4556,127 @@ components: format: int64 type: integer type: object + ChangeEventCustomAttributes: + description: Object representing custom change event attributes. + properties: + author: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthor' + change_metadata: + additionalProperties: {} + description: Free form object with information related to the `change` event. + Can be arbitrarily nested and contain any valid JSON. + example: + dd: + team: datadog_team + user_email: datadog@datadog.com + user_id: datadog_user_id + user_name: datadog_username + resource_link: datadog.com/feature/fallback_payments_test + type: object + changed_resource: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResource' + impacted_resources: + description: 'A list of resources impacted by this change. It is recommended + to provide an impacted resource to display + + the change event at the right location. Only resources of type `service` + are supported.' + example: + - name: payments_api + type: service + items: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItems' + type: array + new_value: + additionalProperties: {} + description: Free form object to track new value of the changed resource. + example: + enabled: true + percentage: 50% + rule: + datacenter: devcycle.us1.prod + type: object + prev_value: + additionalProperties: {} + description: Free form object to track previous value of the changed resource. + example: + enabled: true + percentage: 10% + rule: + datacenter: devcycle.us1.prod + type: object + required: + - changed_resource + type: object + ChangeEventCustomAttributesAuthor: + description: Object representing the entity which made the change. Optional + field but if provided should include `type` and `name`. + properties: + name: + description: Author's name. Limited to 128 characters. + example: datadog@datadog.com + maxLength: 128 + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType' + required: + - name + - type + type: object + ChangeEventCustomAttributesAuthorType: + description: Author's type. + enum: + - user + - system + example: user + type: string + x-enum-varnames: + - USER + - SYSTEM + ChangeEventCustomAttributesChangedResource: + description: Object representing a uniquely identified resource. Only the resource + type `feature_flag` is supported. + properties: + name: + description: Resource's name. + example: fallback_payments_test + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType' + required: + - type + - name + type: object + ChangeEventCustomAttributesChangedResourceType: + description: Resource's type. + enum: + - feature_flag + example: feature_flag + type: string + x-enum-varnames: + - FEATURE_FLAG + ChangeEventCustomAttributesImpactedResourcesItems: + description: Object representing a uniquely identified resource. Only the resource + type `service` is supported. + properties: + name: + description: Resource's name. + example: payments_api + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType' + required: + - type + - name + type: object + ChangeEventCustomAttributesImpactedResourcesItemsType: + description: Resource's type. + enum: + - service + example: service + type: string + x-enum-varnames: + - SERVICE ChargebackBreakdown: description: Charges breakdown. properties: @@ -9335,6 +9456,125 @@ components: example: Oh boy! type: string type: object + EventCategory: + description: Event category to identify the type of event. Only the value `change` + is supported. Support for other categories are coming. please reach out to + datadog support if you're interested. + enum: + - change + example: change + type: string + x-enum-varnames: + - CHANGE + EventCreateRequest: + description: Object representing an event creation request. + properties: + attributes: + $ref: '#/components/schemas/EventPayload' + type: + $ref: '#/components/schemas/EventCreateRequestType' + type: object + EventCreateRequestPayload: + description: Payload for creating an event. + properties: + data: + $ref: '#/components/schemas/EventCreateRequest' + type: object + EventCreateRequestType: + description: Entity type. + enum: + - event + example: event + type: string + x-enum-varnames: + - EVENT + EventCreateResponse: + description: Object containing an event response. + properties: + attributes: + $ref: '#/components/schemas/EventCreateResponseAttributes' + type: + description: Event type + example: event + type: string + type: object + EventCreateResponseAttributes: + description: JSON object containing all events attributes and their associated + values. + properties: + attributes: + $ref: '#/components/schemas/EventCreateResponseAttributesAttributes' + type: object + EventCreateResponseAttributesAttributes: + description: JSON object of attributes from your events. + properties: + evt: + $ref: '#/components/schemas/EventCreateResponseAttributesAttributesEvt' + type: object + EventCreateResponseAttributesAttributesEvt: + description: JSON object of event system attributes. + properties: + id: + description: Event id + type: string + type: object + EventCreateResponsePayload: + description: Response containing information about created event. + properties: + data: + $ref: '#/components/schemas/EventCreateResponse' + type: object + EventPayload: + description: Event attributes. + properties: + aggregation_key: + description: An arbitrary string to use for aggregation when correlating + events. Limited to 100 characters. + maxLength: 100 + type: string + attributes: + $ref: '#/components/schemas/EventPayloadAttributes' + category: + $ref: '#/components/schemas/EventCategory' + message: + description: The body of the event. Limited to 4000 characters. + example: payment_processed feature flag has been enabled + maxLength: 4000 + type: string + tags: + description: 'A list of tags to apply to the event. + + Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).' + example: + - environment:test + items: + description: A tag. + type: string + type: array + timestamp: + description: 'Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) + format. + + For example `"2017-01-15T01:30:15.010000Z"`. + + Defaults to the timestamp of receipt. Limited to values no older than + 18 hours.' + type: string + title: + description: The event title. Limited to 500 characters. + example: payment_processed feature flag updated + maxLength: 500 + type: string + required: + - title + - category + - attributes + type: object + EventPayloadAttributes: + description: JSON object for custom attributes. Schema are different per each + event category. + oneOf: + - $ref: '#/components/schemas/ChangeEventCustomAttributes' EventPriority: description: The priority of the event's monitor. For example, `normal` or `low`. enum: @@ -31191,6 +31431,63 @@ paths: operator: OR permissions: - events_read + post: + description: This endpoint allows you to post events. Only events with `change` + category are under General Availability. + operationId: CreateEvent + requestBody: + content: + application/json: + examples: + json-request-body: + value: + data: + attributes: + attributes: + author: + name: datadog@datadog.com + type: user + changed_resource: + name: fallback_payments_test + type: feature_flag + impacted_resources: + - name: payments_api + type: service + new_value: {} + prev_value: {} + category: change + title: payment_processed feature flag updated + schema: + $ref: '#/components/schemas/EventCreateRequestPayload' + description: Event request object + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventCreateResponsePayload' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + summary: Post an event + tags: + - Events + x-codegen-request-body-name: body /api/v2/events/search: post: description: 'List endpoint returns events that match an events search query. diff --git a/examples/v2/events/CreateEvent.java b/examples/v2/events/CreateEvent.java new file mode 100644 index 00000000000..4cff9641a37 --- /dev/null +++ b/examples/v2/events/CreateEvent.java @@ -0,0 +1,95 @@ +// Post an event returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.EventsApi; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributes; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthor; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesAuthorType; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResource; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesChangedResourceType; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItems; +import com.datadog.api.client.v2.model.ChangeEventCustomAttributesImpactedResourcesItemsType; +import com.datadog.api.client.v2.model.EventCategory; +import com.datadog.api.client.v2.model.EventCreateRequest; +import com.datadog.api.client.v2.model.EventCreateRequestPayload; +import com.datadog.api.client.v2.model.EventCreateRequestType; +import com.datadog.api.client.v2.model.EventCreateResponsePayload; +import com.datadog.api.client.v2.model.EventPayload; +import com.datadog.api.client.v2.model.EventPayloadAttributes; +import java.util.Collections; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + EventsApi apiInstance = new EventsApi(defaultClient); + + EventCreateRequestPayload body = + new EventCreateRequestPayload() + .data( + new EventCreateRequest() + .attributes( + new EventPayload() + .attributes( + new EventPayloadAttributes( + new ChangeEventCustomAttributes() + .author( + new ChangeEventCustomAttributesAuthor() + .name("datadog@datadog.com") + .type(ChangeEventCustomAttributesAuthorType.USER)) + .changeMetadata( + Map.ofEntries( + Map.entry( + "dd", + "{'team': 'datadog_team', 'user_email':" + + " 'datadog@datadog.com', 'user_id':" + + " 'datadog_user_id', 'user_name':" + + " 'datadog_username'}"), + Map.entry( + "resource_link", + "datadog.com/feature/fallback_payments_test"))) + .changedResource( + new ChangeEventCustomAttributesChangedResource() + .name("fallback_payments_test") + .type( + ChangeEventCustomAttributesChangedResourceType + .FEATURE_FLAG)) + .impactedResources( + Collections.singletonList( + new ChangeEventCustomAttributesImpactedResourcesItems() + .name("payments_api") + .type( + ChangeEventCustomAttributesImpactedResourcesItemsType + .SERVICE))) + .newValue( + Map.ofEntries( + Map.entry("enabled", "True"), + Map.entry("percentage", "50%"), + Map.entry( + "rule", "{'datacenter': 'devcycle.us1.prod'}"))) + .prevValue( + Map.ofEntries( + Map.entry("enabled", "True"), + Map.entry("percentage", "10%"), + Map.entry( + "rule", + "{'datacenter': 'devcycle.us1.prod'}"))))) + .category(EventCategory.CHANGE) + .message("payment_processed feature flag has been enabled") + .tags(Collections.singletonList("environment:test")) + .title("payment_processed feature flag updated")) + .type(EventCreateRequestType.EVENT)); + + try { + EventCreateResponsePayload result = apiInstance.createEvent(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling EventsApi#createEvent"); + 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/api/EventsApi.java b/src/main/java/com/datadog/api/client/v2/api/EventsApi.java index 8e3ed8c253c..13f2319c92b 100644 --- a/src/main/java/com/datadog/api/client/v2/api/EventsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/EventsApi.java @@ -5,6 +5,8 @@ import com.datadog.api.client.ApiResponse; import com.datadog.api.client.PaginationIterable; import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.EventCreateRequestPayload; +import com.datadog.api.client.v2.model.EventCreateResponsePayload; import com.datadog.api.client.v2.model.EventResponse; import com.datadog.api.client.v2.model.EventsListRequest; import com.datadog.api.client.v2.model.EventsListResponse; @@ -50,6 +52,138 @@ public void setApiClient(ApiClient apiClient) { this.apiClient = apiClient; } + /** + * Post an event. + * + *

See {@link #createEventWithHttpInfo}. + * + * @param body Event request object (required) + * @return EventCreateResponsePayload + * @throws ApiException if fails to make API call + */ + public EventCreateResponsePayload createEvent(EventCreateRequestPayload body) + throws ApiException { + return createEventWithHttpInfo(body).getData(); + } + + /** + * Post an event. + * + *

See {@link #createEventWithHttpInfoAsync}. + * + * @param body Event request object (required) + * @return CompletableFuture<EventCreateResponsePayload> + */ + public CompletableFuture createEventAsync( + EventCreateRequestPayload body) { + return createEventWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * This endpoint allows you to post events. Only events with change category are + * under General Availability. + * + * @param body Event request object (required) + * @return ApiResponse<EventCreateResponsePayload> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad request -
403 Forbidden -
429 Too many requests -
+ */ + public ApiResponse createEventWithHttpInfo( + EventCreateRequestPayload body) throws ApiException { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createEvent"); + } + // create path and map variables + String localVarPath = "/api/v2/events"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.EventsApi.createEvent", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Post an event. + * + *

See {@link #createEventWithHttpInfo}. + * + * @param body Event request object (required) + * @return CompletableFuture<ApiResponse<EventCreateResponsePayload>> + */ + public CompletableFuture> createEventWithHttpInfoAsync( + EventCreateRequestPayload body) { + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(400, "Missing the required parameter 'body' when calling createEvent")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/events"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.EventsApi.createEvent", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to listEvents. */ public static class ListEventsOptionalParameters { private String filterQuery; diff --git a/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributes.java new file mode 100644 index 00000000000..aa5a9dc7193 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributes.java @@ -0,0 +1,339 @@ +/* + * 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; + +/** Object representing custom change event attributes. */ +@JsonPropertyOrder({ + ChangeEventCustomAttributes.JSON_PROPERTY_AUTHOR, + ChangeEventCustomAttributes.JSON_PROPERTY_CHANGE_METADATA, + ChangeEventCustomAttributes.JSON_PROPERTY_CHANGED_RESOURCE, + ChangeEventCustomAttributes.JSON_PROPERTY_IMPACTED_RESOURCES, + ChangeEventCustomAttributes.JSON_PROPERTY_NEW_VALUE, + ChangeEventCustomAttributes.JSON_PROPERTY_PREV_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ChangeEventCustomAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_AUTHOR = "author"; + private ChangeEventCustomAttributesAuthor author; + + public static final String JSON_PROPERTY_CHANGE_METADATA = "change_metadata"; + private Map changeMetadata = null; + + public static final String JSON_PROPERTY_CHANGED_RESOURCE = "changed_resource"; + private ChangeEventCustomAttributesChangedResource changedResource; + + public static final String JSON_PROPERTY_IMPACTED_RESOURCES = "impacted_resources"; + private List impactedResources = null; + + public static final String JSON_PROPERTY_NEW_VALUE = "new_value"; + private Map newValue = null; + + public static final String JSON_PROPERTY_PREV_VALUE = "prev_value"; + private Map prevValue = null; + + public ChangeEventCustomAttributes() {} + + @JsonCreator + public ChangeEventCustomAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_CHANGED_RESOURCE) + ChangeEventCustomAttributesChangedResource changedResource) { + this.changedResource = changedResource; + this.unparsed |= changedResource.unparsed; + } + + public ChangeEventCustomAttributes author(ChangeEventCustomAttributesAuthor author) { + this.author = author; + this.unparsed |= author.unparsed; + return this; + } + + /** + * Object representing the entity which made the change. Optional field but if provided should + * include type and name. + * + * @return author + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AUTHOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ChangeEventCustomAttributesAuthor getAuthor() { + return author; + } + + public void setAuthor(ChangeEventCustomAttributesAuthor author) { + this.author = author; + } + + public ChangeEventCustomAttributes changeMetadata(Map changeMetadata) { + this.changeMetadata = changeMetadata; + return this; + } + + public ChangeEventCustomAttributes putChangeMetadataItem(String key, Object changeMetadataItem) { + if (this.changeMetadata == null) { + this.changeMetadata = new HashMap<>(); + } + this.changeMetadata.put(key, changeMetadataItem); + return this; + } + + /** + * Free form object with information related to the change event. Can be arbitrarily + * nested and contain any valid JSON. + * + * @return changeMetadata + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CHANGE_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getChangeMetadata() { + return changeMetadata; + } + + public void setChangeMetadata(Map changeMetadata) { + this.changeMetadata = changeMetadata; + } + + public ChangeEventCustomAttributes changedResource( + ChangeEventCustomAttributesChangedResource changedResource) { + this.changedResource = changedResource; + this.unparsed |= changedResource.unparsed; + return this; + } + + /** + * Object representing a uniquely identified resource. Only the resource type feature_flag + * is supported. + * + * @return changedResource + */ + @JsonProperty(JSON_PROPERTY_CHANGED_RESOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ChangeEventCustomAttributesChangedResource getChangedResource() { + return changedResource; + } + + public void setChangedResource(ChangeEventCustomAttributesChangedResource changedResource) { + this.changedResource = changedResource; + } + + public ChangeEventCustomAttributes impactedResources( + List impactedResources) { + this.impactedResources = impactedResources; + for (ChangeEventCustomAttributesImpactedResourcesItems item : impactedResources) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ChangeEventCustomAttributes addImpactedResourcesItem( + ChangeEventCustomAttributesImpactedResourcesItems impactedResourcesItem) { + if (this.impactedResources == null) { + this.impactedResources = new ArrayList<>(); + } + this.impactedResources.add(impactedResourcesItem); + this.unparsed |= impactedResourcesItem.unparsed; + return this; + } + + /** + * A list of resources impacted by this change. It is recommended to provide an impacted resource + * to display the change event at the right location. Only resources of type service + * are supported. + * + * @return impactedResources + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_IMPACTED_RESOURCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getImpactedResources() { + return impactedResources; + } + + public void setImpactedResources( + List impactedResources) { + this.impactedResources = impactedResources; + } + + public ChangeEventCustomAttributes newValue(Map newValue) { + this.newValue = newValue; + return this; + } + + public ChangeEventCustomAttributes putNewValueItem(String key, Object newValueItem) { + if (this.newValue == null) { + this.newValue = new HashMap<>(); + } + this.newValue.put(key, newValueItem); + return this; + } + + /** + * Free form object to track new value of the changed resource. + * + * @return newValue + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NEW_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getNewValue() { + return newValue; + } + + public void setNewValue(Map newValue) { + this.newValue = newValue; + } + + public ChangeEventCustomAttributes prevValue(Map prevValue) { + this.prevValue = prevValue; + return this; + } + + public ChangeEventCustomAttributes putPrevValueItem(String key, Object prevValueItem) { + if (this.prevValue == null) { + this.prevValue = new HashMap<>(); + } + this.prevValue.put(key, prevValueItem); + return this; + } + + /** + * Free form object to track previous value of the changed resource. + * + * @return prevValue + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PREV_VALUE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getPrevValue() { + return prevValue; + } + + public void setPrevValue(Map prevValue) { + this.prevValue = prevValue; + } + + /** + * 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 ChangeEventCustomAttributes + */ + @JsonAnySetter + public ChangeEventCustomAttributes 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 ChangeEventCustomAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeEventCustomAttributes changeEventCustomAttributes = (ChangeEventCustomAttributes) o; + return Objects.equals(this.author, changeEventCustomAttributes.author) + && Objects.equals(this.changeMetadata, changeEventCustomAttributes.changeMetadata) + && Objects.equals(this.changedResource, changeEventCustomAttributes.changedResource) + && Objects.equals(this.impactedResources, changeEventCustomAttributes.impactedResources) + && Objects.equals(this.newValue, changeEventCustomAttributes.newValue) + && Objects.equals(this.prevValue, changeEventCustomAttributes.prevValue) + && Objects.equals( + this.additionalProperties, changeEventCustomAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + author, + changeMetadata, + changedResource, + impactedResources, + newValue, + prevValue, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangeEventCustomAttributes {\n"); + sb.append(" author: ").append(toIndentedString(author)).append("\n"); + sb.append(" changeMetadata: ").append(toIndentedString(changeMetadata)).append("\n"); + sb.append(" changedResource: ").append(toIndentedString(changedResource)).append("\n"); + sb.append(" impactedResources: ").append(toIndentedString(impactedResources)).append("\n"); + sb.append(" newValue: ").append(toIndentedString(newValue)).append("\n"); + sb.append(" prevValue: ").append(toIndentedString(prevValue)).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/ChangeEventCustomAttributesAuthor.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesAuthor.java new file mode 100644 index 00000000000..f291f1e4dce --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesAuthor.java @@ -0,0 +1,184 @@ +/* + * 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; + +/** + * Object representing the entity which made the change. Optional field but if provided should + * include type and name. + */ +@JsonPropertyOrder({ + ChangeEventCustomAttributesAuthor.JSON_PROPERTY_NAME, + ChangeEventCustomAttributesAuthor.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ChangeEventCustomAttributesAuthor { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ChangeEventCustomAttributesAuthorType type; + + public ChangeEventCustomAttributesAuthor() {} + + @JsonCreator + public ChangeEventCustomAttributesAuthor( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ChangeEventCustomAttributesAuthorType type) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ChangeEventCustomAttributesAuthor name(String name) { + this.name = name; + return this; + } + + /** + * Author's name. Limited to 128 characters. + * + * @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 ChangeEventCustomAttributesAuthor type(ChangeEventCustomAttributesAuthorType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Author's type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ChangeEventCustomAttributesAuthorType getType() { + return type; + } + + public void setType(ChangeEventCustomAttributesAuthorType type) { + if (!type.isValid()) { + this.unparsed = true; + } + 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 ChangeEventCustomAttributesAuthor + */ + @JsonAnySetter + public ChangeEventCustomAttributesAuthor 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 ChangeEventCustomAttributesAuthor object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeEventCustomAttributesAuthor changeEventCustomAttributesAuthor = + (ChangeEventCustomAttributesAuthor) o; + return Objects.equals(this.name, changeEventCustomAttributesAuthor.name) + && Objects.equals(this.type, changeEventCustomAttributesAuthor.type) + && Objects.equals( + this.additionalProperties, changeEventCustomAttributesAuthor.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangeEventCustomAttributesAuthor {\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/ChangeEventCustomAttributesAuthorType.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesAuthorType.java new file mode 100644 index 00000000000..c31c79d6a5f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesAuthorType.java @@ -0,0 +1,64 @@ +/* + * 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; + +/** Author's type. */ +@JsonSerialize( + using = + ChangeEventCustomAttributesAuthorType.ChangeEventCustomAttributesAuthorTypeSerializer.class) +public class ChangeEventCustomAttributesAuthorType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("user", "system")); + + public static final ChangeEventCustomAttributesAuthorType USER = + new ChangeEventCustomAttributesAuthorType("user"); + public static final ChangeEventCustomAttributesAuthorType SYSTEM = + new ChangeEventCustomAttributesAuthorType("system"); + + ChangeEventCustomAttributesAuthorType(String value) { + super(value, allowedValues); + } + + public static class ChangeEventCustomAttributesAuthorTypeSerializer + extends StdSerializer { + public ChangeEventCustomAttributesAuthorTypeSerializer( + Class t) { + super(t); + } + + public ChangeEventCustomAttributesAuthorTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ChangeEventCustomAttributesAuthorType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ChangeEventCustomAttributesAuthorType fromValue(String value) { + return new ChangeEventCustomAttributesAuthorType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesChangedResource.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesChangedResource.java new file mode 100644 index 00000000000..e9ca6512b76 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesChangedResource.java @@ -0,0 +1,187 @@ +/* + * 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; + +/** + * Object representing a uniquely identified resource. Only the resource type feature_flag + * is supported. + */ +@JsonPropertyOrder({ + ChangeEventCustomAttributesChangedResource.JSON_PROPERTY_NAME, + ChangeEventCustomAttributesChangedResource.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ChangeEventCustomAttributesChangedResource { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ChangeEventCustomAttributesChangedResourceType type; + + public ChangeEventCustomAttributesChangedResource() {} + + @JsonCreator + public ChangeEventCustomAttributesChangedResource( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ChangeEventCustomAttributesChangedResourceType type) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ChangeEventCustomAttributesChangedResource name(String name) { + this.name = name; + return this; + } + + /** + * Resource's 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 ChangeEventCustomAttributesChangedResource type( + ChangeEventCustomAttributesChangedResourceType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Resource's type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ChangeEventCustomAttributesChangedResourceType getType() { + return type; + } + + public void setType(ChangeEventCustomAttributesChangedResourceType type) { + if (!type.isValid()) { + this.unparsed = true; + } + 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 ChangeEventCustomAttributesChangedResource + */ + @JsonAnySetter + public ChangeEventCustomAttributesChangedResource 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 ChangeEventCustomAttributesChangedResource object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeEventCustomAttributesChangedResource changeEventCustomAttributesChangedResource = + (ChangeEventCustomAttributesChangedResource) o; + return Objects.equals(this.name, changeEventCustomAttributesChangedResource.name) + && Objects.equals(this.type, changeEventCustomAttributesChangedResource.type) + && Objects.equals( + this.additionalProperties, + changeEventCustomAttributesChangedResource.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangeEventCustomAttributesChangedResource {\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/ChangeEventCustomAttributesChangedResourceType.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesChangedResourceType.java new file mode 100644 index 00000000000..943d658825f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesChangedResourceType.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; + +/** Resource's type. */ +@JsonSerialize( + using = + ChangeEventCustomAttributesChangedResourceType + .ChangeEventCustomAttributesChangedResourceTypeSerializer.class) +public class ChangeEventCustomAttributesChangedResourceType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("feature_flag")); + + public static final ChangeEventCustomAttributesChangedResourceType FEATURE_FLAG = + new ChangeEventCustomAttributesChangedResourceType("feature_flag"); + + ChangeEventCustomAttributesChangedResourceType(String value) { + super(value, allowedValues); + } + + public static class ChangeEventCustomAttributesChangedResourceTypeSerializer + extends StdSerializer { + public ChangeEventCustomAttributesChangedResourceTypeSerializer( + Class t) { + super(t); + } + + public ChangeEventCustomAttributesChangedResourceTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ChangeEventCustomAttributesChangedResourceType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ChangeEventCustomAttributesChangedResourceType fromValue(String value) { + return new ChangeEventCustomAttributesChangedResourceType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesImpactedResourcesItems.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesImpactedResourcesItems.java new file mode 100644 index 00000000000..c41ea25c2b2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesImpactedResourcesItems.java @@ -0,0 +1,188 @@ +/* + * 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; + +/** + * Object representing a uniquely identified resource. Only the resource type service + * is supported. + */ +@JsonPropertyOrder({ + ChangeEventCustomAttributesImpactedResourcesItems.JSON_PROPERTY_NAME, + ChangeEventCustomAttributesImpactedResourcesItems.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ChangeEventCustomAttributesImpactedResourcesItems { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ChangeEventCustomAttributesImpactedResourcesItemsType type; + + public ChangeEventCustomAttributesImpactedResourcesItems() {} + + @JsonCreator + public ChangeEventCustomAttributesImpactedResourcesItems( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ChangeEventCustomAttributesImpactedResourcesItemsType type) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ChangeEventCustomAttributesImpactedResourcesItems name(String name) { + this.name = name; + return this; + } + + /** + * Resource's 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 ChangeEventCustomAttributesImpactedResourcesItems type( + ChangeEventCustomAttributesImpactedResourcesItemsType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Resource's type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ChangeEventCustomAttributesImpactedResourcesItemsType getType() { + return type; + } + + public void setType(ChangeEventCustomAttributesImpactedResourcesItemsType type) { + if (!type.isValid()) { + this.unparsed = true; + } + 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 ChangeEventCustomAttributesImpactedResourcesItems + */ + @JsonAnySetter + public ChangeEventCustomAttributesImpactedResourcesItems 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 ChangeEventCustomAttributesImpactedResourcesItems object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangeEventCustomAttributesImpactedResourcesItems + changeEventCustomAttributesImpactedResourcesItems = + (ChangeEventCustomAttributesImpactedResourcesItems) o; + return Objects.equals(this.name, changeEventCustomAttributesImpactedResourcesItems.name) + && Objects.equals(this.type, changeEventCustomAttributesImpactedResourcesItems.type) + && Objects.equals( + this.additionalProperties, + changeEventCustomAttributesImpactedResourcesItems.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangeEventCustomAttributesImpactedResourcesItems {\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/ChangeEventCustomAttributesImpactedResourcesItemsType.java b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesImpactedResourcesItemsType.java new file mode 100644 index 00000000000..27e2f73e067 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ChangeEventCustomAttributesImpactedResourcesItemsType.java @@ -0,0 +1,62 @@ +/* + * 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; + +/** Resource's type. */ +@JsonSerialize( + using = + ChangeEventCustomAttributesImpactedResourcesItemsType + .ChangeEventCustomAttributesImpactedResourcesItemsTypeSerializer.class) +public class ChangeEventCustomAttributesImpactedResourcesItemsType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("service")); + + public static final ChangeEventCustomAttributesImpactedResourcesItemsType SERVICE = + new ChangeEventCustomAttributesImpactedResourcesItemsType("service"); + + ChangeEventCustomAttributesImpactedResourcesItemsType(String value) { + super(value, allowedValues); + } + + public static class ChangeEventCustomAttributesImpactedResourcesItemsTypeSerializer + extends StdSerializer { + public ChangeEventCustomAttributesImpactedResourcesItemsTypeSerializer( + Class t) { + super(t); + } + + public ChangeEventCustomAttributesImpactedResourcesItemsTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ChangeEventCustomAttributesImpactedResourcesItemsType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ChangeEventCustomAttributesImpactedResourcesItemsType fromValue(String value) { + return new ChangeEventCustomAttributesImpactedResourcesItemsType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/EventCategory.java b/src/main/java/com/datadog/api/client/v2/model/EventCategory.java new file mode 100644 index 00000000000..64944dc99bb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCategory.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; + +/** + * Event category to identify the type of event. Only the value change is supported. + * Support for other categories are coming. please reach out to datadog support if you're + * interested. + */ +@JsonSerialize(using = EventCategory.EventCategorySerializer.class) +public class EventCategory extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("change")); + + public static final EventCategory CHANGE = new EventCategory("change"); + + EventCategory(String value) { + super(value, allowedValues); + } + + public static class EventCategorySerializer extends StdSerializer { + public EventCategorySerializer(Class t) { + super(t); + } + + public EventCategorySerializer() { + this(null); + } + + @Override + public void serialize(EventCategory value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static EventCategory fromValue(String value) { + return new EventCategory(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/EventCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequest.java new file mode 100644 index 00000000000..9bd04f4b675 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequest.java @@ -0,0 +1,169 @@ +/* + * 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; + +/** Object representing an event creation request. */ +@JsonPropertyOrder({ + EventCreateRequest.JSON_PROPERTY_ATTRIBUTES, + EventCreateRequest.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private EventPayload attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private EventCreateRequestType type; + + public EventCreateRequest attributes(EventPayload attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Event attributes. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventPayload getAttributes() { + return attributes; + } + + public void setAttributes(EventPayload attributes) { + this.attributes = attributes; + } + + public EventCreateRequest type(EventCreateRequestType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Entity type. + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateRequestType getType() { + return type; + } + + public void setType(EventCreateRequestType type) { + if (!type.isValid()) { + this.unparsed = true; + } + 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 EventCreateRequest + */ + @JsonAnySetter + public EventCreateRequest 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 EventCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateRequest eventCreateRequest = (EventCreateRequest) o; + return Objects.equals(this.attributes, eventCreateRequest.attributes) + && Objects.equals(this.type, eventCreateRequest.type) + && Objects.equals(this.additionalProperties, eventCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateRequest {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).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/EventCreateRequestPayload.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequestPayload.java new file mode 100644 index 00000000000..d924800054b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequestPayload.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; + +/** Payload for creating an event. */ +@JsonPropertyOrder({EventCreateRequestPayload.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateRequestPayload { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private EventCreateRequest data; + + public EventCreateRequestPayload data(EventCreateRequest data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object representing an event creation request. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateRequest getData() { + return data; + } + + public void setData(EventCreateRequest data) { + this.data = data; + } + + /** + * 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 EventCreateRequestPayload + */ + @JsonAnySetter + public EventCreateRequestPayload 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 EventCreateRequestPayload object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateRequestPayload eventCreateRequestPayload = (EventCreateRequestPayload) o; + return Objects.equals(this.data, eventCreateRequestPayload.data) + && Objects.equals( + this.additionalProperties, eventCreateRequestPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateRequestPayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).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/EventCreateRequestType.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequestType.java new file mode 100644 index 00000000000..a39a439b30c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateRequestType.java @@ -0,0 +1,55 @@ +/* + * 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; + +/** Entity type. */ +@JsonSerialize(using = EventCreateRequestType.EventCreateRequestTypeSerializer.class) +public class EventCreateRequestType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("event")); + + public static final EventCreateRequestType EVENT = new EventCreateRequestType("event"); + + EventCreateRequestType(String value) { + super(value, allowedValues); + } + + public static class EventCreateRequestTypeSerializer + extends StdSerializer { + public EventCreateRequestTypeSerializer(Class t) { + super(t); + } + + public EventCreateRequestTypeSerializer() { + this(null); + } + + @Override + public void serialize( + EventCreateRequestType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static EventCreateRequestType fromValue(String value) { + return new EventCreateRequestType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/EventCreateResponse.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponse.java new file mode 100644 index 00000000000..7d5146556b3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponse.java @@ -0,0 +1,165 @@ +/* + * 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; + +/** Object containing an event response. */ +@JsonPropertyOrder({ + EventCreateResponse.JSON_PROPERTY_ATTRIBUTES, + EventCreateResponse.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private EventCreateResponseAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public EventCreateResponse attributes(EventCreateResponseAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * JSON object containing all events attributes and their associated values. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateResponseAttributes getAttributes() { + return attributes; + } + + public void setAttributes(EventCreateResponseAttributes attributes) { + this.attributes = attributes; + } + + public EventCreateResponse type(String type) { + this.type = type; + return this; + } + + /** + * Event type + * + * @return type + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + 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 EventCreateResponse + */ + @JsonAnySetter + public EventCreateResponse 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 EventCreateResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateResponse eventCreateResponse = (EventCreateResponse) o; + return Objects.equals(this.attributes, eventCreateResponse.attributes) + && Objects.equals(this.type, eventCreateResponse.type) + && Objects.equals(this.additionalProperties, eventCreateResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponse {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).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/EventCreateResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributes.java new file mode 100644 index 00000000000..7c7069d31cb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributes.java @@ -0,0 +1,138 @@ +/* + * 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; + +/** JSON object containing all events attributes and their associated values. */ +@JsonPropertyOrder({EventCreateResponseAttributes.JSON_PROPERTY_ATTRIBUTES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateResponseAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private EventCreateResponseAttributesAttributes attributes; + + public EventCreateResponseAttributes attributes( + EventCreateResponseAttributesAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * JSON object of attributes from your events. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateResponseAttributesAttributes getAttributes() { + return attributes; + } + + public void setAttributes(EventCreateResponseAttributesAttributes attributes) { + this.attributes = attributes; + } + + /** + * 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 EventCreateResponseAttributes + */ + @JsonAnySetter + public EventCreateResponseAttributes 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 EventCreateResponseAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateResponseAttributes eventCreateResponseAttributes = (EventCreateResponseAttributes) o; + return Objects.equals(this.attributes, eventCreateResponseAttributes.attributes) + && Objects.equals( + this.additionalProperties, eventCreateResponseAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponseAttributes {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).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/EventCreateResponseAttributesAttributes.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributesAttributes.java new file mode 100644 index 00000000000..cdbfdf23e14 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributesAttributes.java @@ -0,0 +1,140 @@ +/* + * 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; + +/** JSON object of attributes from your events. */ +@JsonPropertyOrder({EventCreateResponseAttributesAttributes.JSON_PROPERTY_EVT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateResponseAttributesAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_EVT = "evt"; + private EventCreateResponseAttributesAttributesEvt evt; + + public EventCreateResponseAttributesAttributes evt( + EventCreateResponseAttributesAttributesEvt evt) { + this.evt = evt; + this.unparsed |= evt.unparsed; + return this; + } + + /** + * JSON object of event system attributes. + * + * @return evt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EVT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateResponseAttributesAttributesEvt getEvt() { + return evt; + } + + public void setEvt(EventCreateResponseAttributesAttributesEvt evt) { + this.evt = evt; + } + + /** + * 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 EventCreateResponseAttributesAttributes + */ + @JsonAnySetter + public EventCreateResponseAttributesAttributes 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 EventCreateResponseAttributesAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateResponseAttributesAttributes eventCreateResponseAttributesAttributes = + (EventCreateResponseAttributesAttributes) o; + return Objects.equals(this.evt, eventCreateResponseAttributesAttributes.evt) + && Objects.equals( + this.additionalProperties, + eventCreateResponseAttributesAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(evt, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponseAttributesAttributes {\n"); + sb.append(" evt: ").append(toIndentedString(evt)).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/EventCreateResponseAttributesAttributesEvt.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributesAttributesEvt.java new file mode 100644 index 00000000000..df56a6c16f9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponseAttributesAttributesEvt.java @@ -0,0 +1,139 @@ +/* + * 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; + +/** JSON object of event system attributes. */ +@JsonPropertyOrder({EventCreateResponseAttributesAttributesEvt.JSON_PROPERTY_ID}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateResponseAttributesAttributesEvt { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public EventCreateResponseAttributesAttributesEvt id(String id) { + this.id = id; + return this; + } + + /** + * Event id + * + * @return id + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * 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 EventCreateResponseAttributesAttributesEvt + */ + @JsonAnySetter + public EventCreateResponseAttributesAttributesEvt 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 EventCreateResponseAttributesAttributesEvt object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateResponseAttributesAttributesEvt eventCreateResponseAttributesAttributesEvt = + (EventCreateResponseAttributesAttributesEvt) o; + return Objects.equals(this.id, eventCreateResponseAttributesAttributesEvt.id) + && Objects.equals( + this.additionalProperties, + eventCreateResponseAttributesAttributesEvt.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponseAttributesAttributesEvt {\n"); + sb.append(" id: ").append(toIndentedString(id)).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/EventCreateResponsePayload.java b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponsePayload.java new file mode 100644 index 00000000000..dfd0c669635 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventCreateResponsePayload.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; + +/** Response containing information about created event. */ +@JsonPropertyOrder({EventCreateResponsePayload.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventCreateResponsePayload { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private EventCreateResponse data; + + public EventCreateResponsePayload data(EventCreateResponse data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object containing an event response. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public EventCreateResponse getData() { + return data; + } + + public void setData(EventCreateResponse data) { + this.data = data; + } + + /** + * 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 EventCreateResponsePayload + */ + @JsonAnySetter + public EventCreateResponsePayload 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 EventCreateResponsePayload object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventCreateResponsePayload eventCreateResponsePayload = (EventCreateResponsePayload) o; + return Objects.equals(this.data, eventCreateResponsePayload.data) + && Objects.equals( + this.additionalProperties, eventCreateResponsePayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponsePayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).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/EventPayload.java b/src/main/java/com/datadog/api/client/v2/model/EventPayload.java new file mode 100644 index 00000000000..3c16bacbeef --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventPayload.java @@ -0,0 +1,341 @@ +/* + * 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; + +/** Event attributes. */ +@JsonPropertyOrder({ + EventPayload.JSON_PROPERTY_AGGREGATION_KEY, + EventPayload.JSON_PROPERTY_ATTRIBUTES, + EventPayload.JSON_PROPERTY_CATEGORY, + EventPayload.JSON_PROPERTY_MESSAGE, + EventPayload.JSON_PROPERTY_TAGS, + EventPayload.JSON_PROPERTY_TIMESTAMP, + EventPayload.JSON_PROPERTY_TITLE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class EventPayload { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_AGGREGATION_KEY = "aggregation_key"; + private String aggregationKey; + + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private EventPayloadAttributes attributes; + + public static final String JSON_PROPERTY_CATEGORY = "category"; + private EventCategory category; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public static final String JSON_PROPERTY_TAGS = "tags"; + private List tags = null; + + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private String timestamp; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public EventPayload() {} + + @JsonCreator + public EventPayload( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + EventPayloadAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_CATEGORY) EventCategory category, + @JsonProperty(required = true, value = JSON_PROPERTY_TITLE) String title) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.category = category; + this.unparsed |= !category.isValid(); + this.title = title; + } + + public EventPayload aggregationKey(String aggregationKey) { + this.aggregationKey = aggregationKey; + return this; + } + + /** + * An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + * + * @return aggregationKey + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AGGREGATION_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAggregationKey() { + return aggregationKey; + } + + public void setAggregationKey(String aggregationKey) { + this.aggregationKey = aggregationKey; + } + + public EventPayload attributes(EventPayloadAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * JSON object for custom attributes. Schema are different per each event category. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public EventPayloadAttributes getAttributes() { + return attributes; + } + + public void setAttributes(EventPayloadAttributes attributes) { + this.attributes = attributes; + } + + public EventPayload category(EventCategory category) { + this.category = category; + this.unparsed |= !category.isValid(); + return this; + } + + /** + * Event category to identify the type of event. Only the value change is supported. + * Support for other categories are coming. please reach out to datadog support if you're + * interested. + * + * @return category + */ + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public EventCategory getCategory() { + return category; + } + + public void setCategory(EventCategory category) { + if (!category.isValid()) { + this.unparsed = true; + } + this.category = category; + } + + public EventPayload message(String message) { + this.message = message; + return this; + } + + /** + * The body of the event. Limited to 4000 characters. + * + * @return message + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public EventPayload tags(List tags) { + this.tags = tags; + return this; + } + + public EventPayload addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * A list of tags to apply to the event. Refer to Tags docs. + * + * @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 EventPayload timestamp(String timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Timestamp when the event occurred. Must follow ISO 8601 format. For example + * "2017-01-15T01:30:15.010000Z". Defaults to the timestamp of receipt. Limited to + * values no older than 18 hours. + * + * @return timestamp + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTimestamp() { + return timestamp; + } + + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + + public EventPayload title(String title) { + this.title = title; + return this; + } + + /** + * The event title. Limited to 500 characters. + * + * @return title + */ + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + /** + * 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 EventPayload + */ + @JsonAnySetter + public EventPayload 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 EventPayload object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EventPayload eventPayload = (EventPayload) o; + return Objects.equals(this.aggregationKey, eventPayload.aggregationKey) + && Objects.equals(this.attributes, eventPayload.attributes) + && Objects.equals(this.category, eventPayload.category) + && Objects.equals(this.message, eventPayload.message) + && Objects.equals(this.tags, eventPayload.tags) + && Objects.equals(this.timestamp, eventPayload.timestamp) + && Objects.equals(this.title, eventPayload.title) + && Objects.equals(this.additionalProperties, eventPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + aggregationKey, + attributes, + category, + message, + tags, + timestamp, + title, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventPayload {\n"); + sb.append(" aggregationKey: ").append(toIndentedString(aggregationKey)).append("\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).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/EventPayloadAttributes.java b/src/main/java/com/datadog/api/client/v2/model/EventPayloadAttributes.java new file mode 100644 index 00000000000..4a9f038ff9d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/EventPayloadAttributes.java @@ -0,0 +1,213 @@ +/* + * 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 = EventPayloadAttributes.EventPayloadAttributesDeserializer.class) +@JsonSerialize(using = EventPayloadAttributes.EventPayloadAttributesSerializer.class) +public class EventPayloadAttributes extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(EventPayloadAttributes.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class EventPayloadAttributesSerializer + extends StdSerializer { + public EventPayloadAttributesSerializer(Class t) { + super(t); + } + + public EventPayloadAttributesSerializer() { + this(null); + } + + @Override + public void serialize( + EventPayloadAttributes value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class EventPayloadAttributesDeserializer + extends StdDeserializer { + public EventPayloadAttributesDeserializer() { + this(EventPayloadAttributes.class); + } + + public EventPayloadAttributesDeserializer(Class vc) { + super(vc); + } + + @Override + public EventPayloadAttributes 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 ChangeEventCustomAttributes + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ChangeEventCustomAttributes.class.equals(Integer.class) + || ChangeEventCustomAttributes.class.equals(Long.class) + || ChangeEventCustomAttributes.class.equals(Float.class) + || ChangeEventCustomAttributes.class.equals(Double.class) + || ChangeEventCustomAttributes.class.equals(Boolean.class) + || ChangeEventCustomAttributes.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ChangeEventCustomAttributes.class.equals(Integer.class) + || ChangeEventCustomAttributes.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ChangeEventCustomAttributes.class.equals(Float.class) + || ChangeEventCustomAttributes.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ChangeEventCustomAttributes.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ChangeEventCustomAttributes.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ChangeEventCustomAttributes.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 (!((ChangeEventCustomAttributes) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ChangeEventCustomAttributes'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ChangeEventCustomAttributes'", e); + } + + EventPayloadAttributes ret = new EventPayloadAttributes(); + 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 EventPayloadAttributes getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "EventPayloadAttributes cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public EventPayloadAttributes() { + super("oneOf", Boolean.FALSE); + } + + public EventPayloadAttributes(ChangeEventCustomAttributes o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ChangeEventCustomAttributes", new GenericType() {}); + JSON.registerDescendants(EventPayloadAttributes.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return EventPayloadAttributes.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: ChangeEventCustomAttributes + * + *

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(ChangeEventCustomAttributes.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 ChangeEventCustomAttributes"); + } + + /** + * Get the actual instance, which can be the following: ChangeEventCustomAttributes + * + * @return The actual instance (ChangeEventCustomAttributes) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ChangeEventCustomAttributes`. If the actual instance is not + * `ChangeEventCustomAttributes`, the ClassCastException will be thrown. + * + * @return The actual instance of `ChangeEventCustomAttributes` + * @throws ClassCastException if the instance is not `ChangeEventCustomAttributes` + */ + public ChangeEventCustomAttributes getChangeEventCustomAttributes() throws ClassCastException { + return (ChangeEventCustomAttributes) super.getActualInstance(); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/events.feature b/src/test/resources/com/datadog/api/client/v2/api/events.feature index 9a1c79072d1..2013c242f6c 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/events.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/events.feature @@ -7,24 +7,26 @@ Feature: Events Background: Given a valid "apiKeyAuth" key in the system - And a valid "appKeyAuth" key in the system And an instance of "Events" API @generated @skip @team:DataDog/event-management Scenario: Get a list of events returns "Bad Request" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 400 Bad Request @skip-validation @team:DataDog/event-management Scenario: Get a list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 200 OK @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Get a list of events returns "OK" response with pagination - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[from]" parameter with value "now-15m" And request contains "filter[to]" parameter with value "now" And request contains "page[limit]" parameter with value 2 @@ -34,7 +36,8 @@ Feature: Events @team:DataDog/event-management Scenario: Get a quick list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[query]" parameter with value "datadog-agent" And request contains "filter[from]" parameter with value "2020-09-17T11:48:36+01:00" And request contains "filter[to]" parameter with value "2020-09-17T12:48:36+01:00" @@ -43,16 +46,32 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/event-management + Scenario: Post an event returns "Bad request" response + Given new "CreateEvent" request + And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "message": "payment_processed feature flag has been enabled", "tags": ["environment:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/event-management + Scenario: Post an event returns "OK" response + Given new "CreateEvent" request + And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "message": "payment_processed feature flag has been enabled", "tags": ["environment:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-management Scenario: Search events returns "Bad Request" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} When the request is sent Then the response status is 400 Bad Request @team:DataDog/event-management Scenario: Search events returns "OK" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"query": "datadog-agent", "from": "2020-09-17T11:48:36+01:00", "to": "2020-09-17T12:48:36+01:00"}, "sort": "timestamp", "page": {"limit": 5}} When the request is sent Then the response status is 200 OK @@ -60,7 +79,8 @@ Feature: Events @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Search events returns "OK" response with pagination - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"limit": 2}, "sort": "timestamp"} When the request with pagination is sent Then the response status is 200 OK diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index dcb4deb9a78..91f554953bd 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -608,6 +608,12 @@ "type": "safe" } }, + "CreateEvent": { + "tag": "Events", + "undo": { + "type": "unsafe" + } + }, "SearchEvents": { "tag": "Events", "undo": {