diff --git a/.apigentools-info b/.apigentools-info index e28d205a18f..6e5702b4260 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-12 09:40:18.860888", - "spec_repo_commit": "c4d0aeef" + "regenerated": "2025-05-13 01:19:32.866177", + "spec_repo_commit": "dc3b522f" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-12 09:40:18.876442", - "spec_repo_commit": "c4d0aeef" + "regenerated": "2025-05-13 01:19:32.881522", + "spec_repo_commit": "dc3b522f" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index cd58a11bc08..0c89c420427 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -36060,6 +36060,115 @@ components: description: Link to the Incident created on ServiceNow type: string type: object + Shift: + description: The definition of `Shift` object. + example: + data: + attributes: + end: '2025-05-07T03:53:01.206662873Z' + start: '2025-05-07T02:53:01.206662814Z' + id: 00000000-0000-0000-0000-000000000000 + relationships: + user: + data: + id: 00000000-aba1-0000-0000-000000000000 + type: users + type: shifts + included: + - attributes: + email: foo@bar.com + name: User 1 + status: '' + id: 00000000-aba1-0000-0000-000000000000 + type: users + properties: + data: + $ref: '#/components/schemas/ShiftData' + nullable: true + included: + description: The `Shift` `included`. + items: + $ref: '#/components/schemas/ShiftIncluded' + type: array + type: object + ShiftData: + description: The definition of `ShiftData` object. + properties: + attributes: + $ref: '#/components/schemas/ShiftDataAttributes' + id: + description: The `ShiftData` `id`. + type: string + relationships: + $ref: '#/components/schemas/ShiftDataRelationships' + type: + $ref: '#/components/schemas/ShiftDataType' + required: + - type + type: object + ShiftDataAttributes: + description: The definition of `ShiftDataAttributes` object. + properties: + end: + description: The end time of the shift. + format: date-time + type: string + start: + description: The start time of the shift. + format: date-time + type: string + type: object + ShiftDataRelationships: + description: The definition of `ShiftDataRelationships` object. + properties: + user: + $ref: '#/components/schemas/ShiftDataRelationshipsUser' + type: object + ShiftDataRelationshipsUser: + description: Defines the relationship between a shift and the user who is working + that shift. + properties: + data: + $ref: '#/components/schemas/ShiftDataRelationshipsUserData' + required: + - data + type: object + ShiftDataRelationshipsUserData: + description: Represents a reference to the user assigned to this shift, containing + the user's ID and resource type. + properties: + id: + description: Specifies the unique identifier of the user. + example: 00000000-0000-0000-0000-000000000000 + type: string + type: + $ref: '#/components/schemas/ShiftDataRelationshipsUserDataType' + required: + - type + - id + type: object + ShiftDataRelationshipsUserDataType: + default: users + description: Indicates that the related resource is of type 'users'. + enum: + - users + example: users + type: string + x-enum-varnames: + - USERS + ShiftDataType: + default: shifts + description: Indicates that the resource is of type 'shifts'. + enum: + - shifts + example: shifts + type: string + x-enum-varnames: + - SHIFTS + ShiftIncluded: + description: The definition of `ShiftIncluded` object. + oneOf: + - $ref: '#/components/schemas/ScheduleUser' SingleAggregatedConnectionResponseArray: description: List of aggregated connections. example: @@ -51922,6 +52031,56 @@ paths: operator: AND permissions: - on_call_write + /api/v2/on-call/schedules/{schedule_id}/on-call: + get: + description: Retrieves the user who is on-call for the specified schedule at + a given time. + operationId: GetScheduleOnCallUser + parameters: + - description: 'Specifies related resources to include in the response as a + comma-separated list. Allowed value: `user`.' + in: query + name: include + schema: + type: string + - description: The ID of the schedule. + in: path + name: schedule_id + required: true + schema: + example: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d + type: string + - description: Retrieves the on-call user at the given timestamp (ISO-8601). + Defaults to the current time if omitted." + in: query + name: filter[at_ts] + schema: + example: '2025-05-07T02:53:01Z' + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Shift' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get the schedule of an on-call user + tags: + - On-Call /api/v2/on-call/teams/{team_id}/routing-rules: get: description: Get a team's on-call routing rules diff --git a/examples/v2/on-call/GetScheduleOnCallUser.java b/examples/v2/on-call/GetScheduleOnCallUser.java new file mode 100644 index 00000000000..62141bbc29f --- /dev/null +++ b/examples/v2/on-call/GetScheduleOnCallUser.java @@ -0,0 +1,27 @@ +// Get the schedule of an on-call user returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.OnCallApi; +import com.datadog.api.client.v2.model.Shift; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + OnCallApi apiInstance = new OnCallApi(defaultClient); + + // there is a valid "schedule" in the system + String SCHEDULE_DATA_ID = System.getenv("SCHEDULE_DATA_ID"); + + try { + Shift result = apiInstance.getScheduleOnCallUser(SCHEDULE_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling OnCallApi#getScheduleOnCallUser"); + 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/OnCallApi.java b/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java index 6c97443bbd4..ba92830760f 100644 --- a/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/OnCallApi.java @@ -10,6 +10,7 @@ import com.datadog.api.client.v2.model.Schedule; import com.datadog.api.client.v2.model.ScheduleCreateRequest; import com.datadog.api.client.v2.model.ScheduleUpdateRequest; +import com.datadog.api.client.v2.model.Shift; import com.datadog.api.client.v2.model.TeamRoutingRules; import com.datadog.api.client.v2.model.TeamRoutingRulesRequest; import jakarta.ws.rs.client.Invocation; @@ -1325,6 +1326,226 @@ public ApiResponse getOnCallTeamRoutingRulesWithHttpInfo( new GenericType() {}); } + /** Manage optional parameters to getScheduleOnCallUser. */ + public static class GetScheduleOnCallUserOptionalParameters { + private String include; + private String filterAtTs; + + /** + * Set include. + * + * @param include Specifies related resources to include in the response as a comma-separated + * list. Allowed value: user. (optional) + * @return GetScheduleOnCallUserOptionalParameters + */ + public GetScheduleOnCallUserOptionalParameters include(String include) { + this.include = include; + return this; + } + + /** + * Set filterAtTs. + * + * @param filterAtTs Retrieves the on-call user at the given timestamp (ISO-8601). Defaults to + * the current time if omitted." (optional) + * @return GetScheduleOnCallUserOptionalParameters + */ + public GetScheduleOnCallUserOptionalParameters filterAtTs(String filterAtTs) { + this.filterAtTs = filterAtTs; + return this; + } + } + + /** + * Get the schedule of an on-call user. + * + *

See {@link #getScheduleOnCallUserWithHttpInfo}. + * + * @param scheduleId The ID of the schedule. (required) + * @return Shift + * @throws ApiException if fails to make API call + */ + public Shift getScheduleOnCallUser(String scheduleId) throws ApiException { + return getScheduleOnCallUserWithHttpInfo( + scheduleId, new GetScheduleOnCallUserOptionalParameters()) + .getData(); + } + + /** + * Get the schedule of an on-call user. + * + *

See {@link #getScheduleOnCallUserWithHttpInfoAsync}. + * + * @param scheduleId The ID of the schedule. (required) + * @return CompletableFuture<Shift> + */ + public CompletableFuture getScheduleOnCallUserAsync(String scheduleId) { + return getScheduleOnCallUserWithHttpInfoAsync( + scheduleId, new GetScheduleOnCallUserOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get the schedule of an on-call user. + * + *

See {@link #getScheduleOnCallUserWithHttpInfo}. + * + * @param scheduleId The ID of the schedule. (required) + * @param parameters Optional parameters for the request. + * @return Shift + * @throws ApiException if fails to make API call + */ + public Shift getScheduleOnCallUser( + String scheduleId, GetScheduleOnCallUserOptionalParameters parameters) throws ApiException { + return getScheduleOnCallUserWithHttpInfo(scheduleId, parameters).getData(); + } + + /** + * Get the schedule of an on-call user. + * + *

See {@link #getScheduleOnCallUserWithHttpInfoAsync}. + * + * @param scheduleId The ID of the schedule. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<Shift> + */ + public CompletableFuture getScheduleOnCallUserAsync( + String scheduleId, GetScheduleOnCallUserOptionalParameters parameters) { + return getScheduleOnCallUserWithHttpInfoAsync(scheduleId, parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Retrieves the user who is on-call for the specified schedule at a given time. + * + * @param scheduleId The ID of the schedule. (required) + * @param parameters Optional parameters for the request. + * @return ApiResponse<Shift> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getScheduleOnCallUserWithHttpInfo( + String scheduleId, GetScheduleOnCallUserOptionalParameters parameters) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'scheduleId' is set + if (scheduleId == null) { + throw new ApiException( + 400, "Missing the required parameter 'scheduleId' when calling getScheduleOnCallUser"); + } + String include = parameters.include; + String filterAtTs = parameters.filterAtTs; + // create path and map variables + String localVarPath = + "/api/v2/on-call/schedules/{schedule_id}/on-call" + .replaceAll( + "\\{" + "schedule_id" + "\\}", apiClient.escapeString(scheduleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[at_ts]", filterAtTs)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.OnCallApi.getScheduleOnCallUser", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get the schedule of an on-call user. + * + *

See {@link #getScheduleOnCallUserWithHttpInfo}. + * + * @param scheduleId The ID of the schedule. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<Shift>> + */ + public CompletableFuture> getScheduleOnCallUserWithHttpInfoAsync( + String scheduleId, GetScheduleOnCallUserOptionalParameters parameters) { + Object localVarPostBody = null; + + // verify the required parameter 'scheduleId' is set + if (scheduleId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'scheduleId' when calling getScheduleOnCallUser")); + return result; + } + String include = parameters.include; + String filterAtTs = parameters.filterAtTs; + // create path and map variables + String localVarPath = + "/api/v2/on-call/schedules/{schedule_id}/on-call" + .replaceAll( + "\\{" + "schedule_id" + "\\}", apiClient.escapeString(scheduleId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[at_ts]", filterAtTs)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.OnCallApi.getScheduleOnCallUser", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"AuthZ", "apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to setOnCallTeamRoutingRules. */ public static class SetOnCallTeamRoutingRulesOptionalParameters { private String include; diff --git a/src/main/java/com/datadog/api/client/v2/model/Shift.java b/src/main/java/com/datadog/api/client/v2/model/Shift.java new file mode 100644 index 00000000000..e36331a5b78 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/Shift.java @@ -0,0 +1,176 @@ +/* + * 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The definition of Shift object. */ +@JsonPropertyOrder({Shift.JSON_PROPERTY_DATA, Shift.JSON_PROPERTY_INCLUDED}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class Shift { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ShiftData data; + + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + + public Shift data(ShiftData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The definition of ShiftData object. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ShiftData getData() { + return data; + } + + public void setData(ShiftData data) { + this.data = data; + } + + public Shift included(List included) { + this.included = included; + for (ShiftIncluded item : included) { + this.unparsed |= item.unparsed; + } + return this; + } + + public Shift addIncludedItem(ShiftIncluded includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * The Shift included. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + } + + /** + * 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 Shift + */ + @JsonAnySetter + public Shift 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 Shift object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Shift shift = (Shift) o; + return Objects.equals(this.data, shift.data) + && Objects.equals(this.included, shift.included) + && Objects.equals(this.additionalProperties, shift.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, included, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Shift {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).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/ShiftData.java b/src/main/java/com/datadog/api/client/v2/model/ShiftData.java new file mode 100644 index 00000000000..edb3a2c9b4b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftData.java @@ -0,0 +1,232 @@ +/* + * 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; + +/** The definition of ShiftData object. */ +@JsonPropertyOrder({ + ShiftData.JSON_PROPERTY_ATTRIBUTES, + ShiftData.JSON_PROPERTY_ID, + ShiftData.JSON_PROPERTY_RELATIONSHIPS, + ShiftData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ShiftData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ShiftDataAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private ShiftDataRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ShiftDataType type = ShiftDataType.SHIFTS; + + public ShiftData() {} + + @JsonCreator + public ShiftData(@JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ShiftDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ShiftData attributes(ShiftDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * The definition of ShiftDataAttributes object. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ShiftDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ShiftDataAttributes attributes) { + this.attributes = attributes; + } + + public ShiftData id(String id) { + this.id = id; + return this; + } + + /** + * The ShiftData 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; + } + + public ShiftData relationships(ShiftDataRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * The definition of ShiftDataRelationships object. + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ShiftDataRelationships getRelationships() { + return relationships; + } + + public void setRelationships(ShiftDataRelationships relationships) { + this.relationships = relationships; + } + + public ShiftData type(ShiftDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the resource is of type 'shifts'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ShiftDataType getType() { + return type; + } + + public void setType(ShiftDataType 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 ShiftData + */ + @JsonAnySetter + public ShiftData 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 ShiftData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ShiftData shiftData = (ShiftData) o; + return Objects.equals(this.attributes, shiftData.attributes) + && Objects.equals(this.id, shiftData.id) + && Objects.equals(this.relationships, shiftData.relationships) + && Objects.equals(this.type, shiftData.type) + && Objects.equals(this.additionalProperties, shiftData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShiftData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).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/ShiftDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataAttributes.java new file mode 100644 index 00000000000..03166ba1795 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataAttributes.java @@ -0,0 +1,162 @@ +/* + * 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.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The definition of ShiftDataAttributes object. */ +@JsonPropertyOrder({ShiftDataAttributes.JSON_PROPERTY_END, ShiftDataAttributes.JSON_PROPERTY_START}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ShiftDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END = "end"; + private OffsetDateTime end; + + public static final String JSON_PROPERTY_START = "start"; + private OffsetDateTime start; + + public ShiftDataAttributes end(OffsetDateTime end) { + this.end = end; + return this; + } + + /** + * The end time of the shift. + * + * @return end + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_END) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getEnd() { + return end; + } + + public void setEnd(OffsetDateTime end) { + this.end = end; + } + + public ShiftDataAttributes start(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * The start time of the shift. + * + * @return start + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_START) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getStart() { + return start; + } + + public void setStart(OffsetDateTime start) { + this.start = start; + } + + /** + * 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 ShiftDataAttributes + */ + @JsonAnySetter + public ShiftDataAttributes 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 ShiftDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ShiftDataAttributes shiftDataAttributes = (ShiftDataAttributes) o; + return Objects.equals(this.end, shiftDataAttributes.end) + && Objects.equals(this.start, shiftDataAttributes.start) + && Objects.equals(this.additionalProperties, shiftDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(end, start, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShiftDataAttributes {\n"); + sb.append(" end: ").append(toIndentedString(end)).append("\n"); + sb.append(" start: ").append(toIndentedString(start)).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/ShiftDataRelationships.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationships.java new file mode 100644 index 00000000000..a5a4f5535c2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationships.java @@ -0,0 +1,136 @@ +/* + * 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; + +/** The definition of ShiftDataRelationships object. */ +@JsonPropertyOrder({ShiftDataRelationships.JSON_PROPERTY_USER}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ShiftDataRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_USER = "user"; + private ShiftDataRelationshipsUser user; + + public ShiftDataRelationships user(ShiftDataRelationshipsUser user) { + this.user = user; + this.unparsed |= user.unparsed; + return this; + } + + /** + * Defines the relationship between a shift and the user who is working that shift. + * + * @return user + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_USER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ShiftDataRelationshipsUser getUser() { + return user; + } + + public void setUser(ShiftDataRelationshipsUser user) { + this.user = user; + } + + /** + * 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 ShiftDataRelationships + */ + @JsonAnySetter + public ShiftDataRelationships 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 ShiftDataRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ShiftDataRelationships shiftDataRelationships = (ShiftDataRelationships) o; + return Objects.equals(this.user, shiftDataRelationships.user) + && Objects.equals(this.additionalProperties, shiftDataRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(user, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShiftDataRelationships {\n"); + sb.append(" user: ").append(toIndentedString(user)).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/ShiftDataRelationshipsUser.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUser.java new file mode 100644 index 00000000000..093e9458697 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUser.java @@ -0,0 +1,148 @@ +/* + * 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; + +/** Defines the relationship between a shift and the user who is working that shift. */ +@JsonPropertyOrder({ShiftDataRelationshipsUser.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ShiftDataRelationshipsUser { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ShiftDataRelationshipsUserData data; + + public ShiftDataRelationshipsUser() {} + + @JsonCreator + public ShiftDataRelationshipsUser( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + ShiftDataRelationshipsUserData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public ShiftDataRelationshipsUser data(ShiftDataRelationshipsUserData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Represents a reference to the user assigned to this shift, containing the user's ID and + * resource type. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ShiftDataRelationshipsUserData getData() { + return data; + } + + public void setData(ShiftDataRelationshipsUserData 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 ShiftDataRelationshipsUser + */ + @JsonAnySetter + public ShiftDataRelationshipsUser 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 ShiftDataRelationshipsUser object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ShiftDataRelationshipsUser shiftDataRelationshipsUser = (ShiftDataRelationshipsUser) o; + return Objects.equals(this.data, shiftDataRelationshipsUser.data) + && Objects.equals( + this.additionalProperties, shiftDataRelationshipsUser.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShiftDataRelationshipsUser {\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/ShiftDataRelationshipsUserData.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUserData.java new file mode 100644 index 00000000000..d266a29fd84 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUserData.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; + +/** + * Represents a reference to the user assigned to this shift, containing the user's ID and resource + * type. + */ +@JsonPropertyOrder({ + ShiftDataRelationshipsUserData.JSON_PROPERTY_ID, + ShiftDataRelationshipsUserData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ShiftDataRelationshipsUserData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ShiftDataRelationshipsUserDataType type = ShiftDataRelationshipsUserDataType.USERS; + + public ShiftDataRelationshipsUserData() {} + + @JsonCreator + public ShiftDataRelationshipsUserData( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ShiftDataRelationshipsUserDataType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ShiftDataRelationshipsUserData id(String id) { + this.id = id; + return this; + } + + /** + * Specifies the unique identifier of the user. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ShiftDataRelationshipsUserData type(ShiftDataRelationshipsUserDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the related resource is of type 'users'. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ShiftDataRelationshipsUserDataType getType() { + return type; + } + + public void setType(ShiftDataRelationshipsUserDataType 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 ShiftDataRelationshipsUserData + */ + @JsonAnySetter + public ShiftDataRelationshipsUserData 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 ShiftDataRelationshipsUserData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ShiftDataRelationshipsUserData shiftDataRelationshipsUserData = + (ShiftDataRelationshipsUserData) o; + return Objects.equals(this.id, shiftDataRelationshipsUserData.id) + && Objects.equals(this.type, shiftDataRelationshipsUserData.type) + && Objects.equals( + this.additionalProperties, shiftDataRelationshipsUserData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShiftDataRelationshipsUserData {\n"); + sb.append(" id: ").append(toIndentedString(id)).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/ShiftDataRelationshipsUserDataType.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUserDataType.java new file mode 100644 index 00000000000..5a52c5f25ee --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataRelationshipsUserDataType.java @@ -0,0 +1,58 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.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; + +/** Indicates that the related resource is of type 'users'. */ +@JsonSerialize( + using = ShiftDataRelationshipsUserDataType.ShiftDataRelationshipsUserDataTypeSerializer.class) +public class ShiftDataRelationshipsUserDataType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("users")); + + public static final ShiftDataRelationshipsUserDataType USERS = + new ShiftDataRelationshipsUserDataType("users"); + + ShiftDataRelationshipsUserDataType(String value) { + super(value, allowedValues); + } + + public static class ShiftDataRelationshipsUserDataTypeSerializer + extends StdSerializer { + public ShiftDataRelationshipsUserDataTypeSerializer( + Class t) { + super(t); + } + + public ShiftDataRelationshipsUserDataTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ShiftDataRelationshipsUserDataType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ShiftDataRelationshipsUserDataType fromValue(String value) { + return new ShiftDataRelationshipsUserDataType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ShiftDataType.java b/src/main/java/com/datadog/api/client/v2/model/ShiftDataType.java new file mode 100644 index 00000000000..17fe7c45430 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftDataType.java @@ -0,0 +1,53 @@ +/* + * 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; + +/** Indicates that the resource is of type 'shifts'. */ +@JsonSerialize(using = ShiftDataType.ShiftDataTypeSerializer.class) +public class ShiftDataType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("shifts")); + + public static final ShiftDataType SHIFTS = new ShiftDataType("shifts"); + + ShiftDataType(String value) { + super(value, allowedValues); + } + + public static class ShiftDataTypeSerializer extends StdSerializer { + public ShiftDataTypeSerializer(Class t) { + super(t); + } + + public ShiftDataTypeSerializer() { + this(null); + } + + @Override + public void serialize(ShiftDataType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ShiftDataType fromValue(String value) { + return new ShiftDataType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ShiftIncluded.java b/src/main/java/com/datadog/api/client/v2/model/ShiftIncluded.java new file mode 100644 index 00000000000..1097e5e7537 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ShiftIncluded.java @@ -0,0 +1,206 @@ +/* + * 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 = ShiftIncluded.ShiftIncludedDeserializer.class) +@JsonSerialize(using = ShiftIncluded.ShiftIncludedSerializer.class) +public class ShiftIncluded extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ShiftIncluded.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ShiftIncludedSerializer extends StdSerializer { + public ShiftIncludedSerializer(Class t) { + super(t); + } + + public ShiftIncludedSerializer() { + this(null); + } + + @Override + public void serialize(ShiftIncluded value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ShiftIncludedDeserializer extends StdDeserializer { + public ShiftIncludedDeserializer() { + this(ShiftIncluded.class); + } + + public ShiftIncludedDeserializer(Class vc) { + super(vc); + } + + @Override + public ShiftIncluded 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 ScheduleUser + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ScheduleUser.class.equals(Integer.class) + || ScheduleUser.class.equals(Long.class) + || ScheduleUser.class.equals(Float.class) + || ScheduleUser.class.equals(Double.class) + || ScheduleUser.class.equals(Boolean.class) + || ScheduleUser.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ScheduleUser.class.equals(Integer.class) || ScheduleUser.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ScheduleUser.class.equals(Float.class) || ScheduleUser.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ScheduleUser.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ScheduleUser.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(ScheduleUser.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 (!((ScheduleUser) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'ScheduleUser'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ScheduleUser'", e); + } + + ShiftIncluded ret = new ShiftIncluded(); + 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 ShiftIncluded getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "ShiftIncluded cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ShiftIncluded() { + super("oneOf", Boolean.FALSE); + } + + public ShiftIncluded(ScheduleUser o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ScheduleUser", new GenericType() {}); + JSON.registerDescendants(ShiftIncluded.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ShiftIncluded.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: ScheduleUser + * + *

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(ScheduleUser.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 ScheduleUser"); + } + + /** + * Get the actual instance, which can be the following: ScheduleUser + * + * @return The actual instance (ScheduleUser) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ScheduleUser`. If the actual instance is not `ScheduleUser`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `ScheduleUser` + * @throws ClassCastException if the instance is not `ScheduleUser` + */ + public ScheduleUser getScheduleUser() throws ClassCastException { + return (ScheduleUser) super.getActualInstance(); + } +} diff --git a/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.freeze new file mode 100644 index 00000000000..4546b536bae --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-05-13T00:41:58.620Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.json new file mode 100644 index 00000000000..c232a4e7b1f --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_the_schedule_of_an_on_call_user_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"layers\":[{\"effective_date\":\"2025-05-03T00:41:58.620Z\",\"end_date\":\"2025-05-23T00:41:58.620Z\",\"interval\":{\"days\":1},\"members\":[{\"user\":{\"id\":\"890f29d4-0b7a-11f0-aeb2-760fcae4f596\"}}],\"name\":\"Layer 1\",\"restrictions\":[{\"end_day\":\"friday\",\"end_time\":\"17:00:00\",\"start_day\":\"monday\",\"start_time\":\"09:00:00\"}],\"rotation_start\":\"2025-05-08T00:41:58.620Z\"}],\"name\":\"Test-Get_the_schedule_of_an_on_call_user_returns_OK_response-1747096918\",\"tags\":[\"tag1\",\"tag2\"],\"time_zone\":\"America/New_York\"},\"relationships\":{\"teams\":{\"data\":[{\"id\":\"65aea9d0-941c-4607-bf8a-14fc0dac2820\",\"type\":\"teams\"}]}},\"type\":\"schedules\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/on-call/schedules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"a69018b0-28a9-4ec1-ad13-dd74bb82ad3c\",\"type\":\"schedules\",\"attributes\":{\"name\":\"Test-Get_the_schedule_of_an_on_call_user_returns_OK_response-1747096918\",\"tags\":[\"tag1\",\"tag2\"],\"time_zone\":\"America/New_York\"},\"relationships\":{\"layers\":{\"data\":[{\"id\":\"133a579b-0b88-4732-91bd-7eb4a75271ab\",\"type\":\"layers\"}]},\"teams\":{\"data\":[{\"id\":\"65aea9d0-941c-4607-bf8a-14fc0dac2820\",\"type\":\"teams\"}]}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 201, + "reasonPhrase": "Created" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7554e566-6835-8a89-b7c9-41cae81fa1a5" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/on-call/schedules/a69018b0-28a9-4ec1-ad13-dd74bb82ad3c/on-call", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"890f29d4-0b7a-11f0-aeb2-760fcae4f596-2025-05-12T20:41:59-04:00-2025-05-13T20:41:58-04:00\",\"type\":\"shifts\",\"attributes\":{\"end\":\"2025-05-13T20:41:58-04:00\",\"start\":\"2025-05-12T20:41:59.394997-04:00\"},\"relationships\":{\"user\":{\"data\":{\"id\":\"890f29d4-0b7a-11f0-aeb2-760fcae4f596\",\"type\":\"users\"}}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "949e4e7b-2572-9405-116d-d9cf1f7caa6d" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/on-call/schedules/a69018b0-28a9-4ec1-ad13-dd74bb82ad3c", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "efca463a-bd71-f6a8-b326-56f203b69b7d" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/on-call.feature b/src/test/resources/com/datadog/api/client/v2/api/on-call.feature index 0597e0b99f2..9725e2ac77a 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/on-call.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/on-call.feature @@ -122,6 +122,28 @@ Feature: On-Call When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/bugle + Scenario: Get the schedule of an on-call user returns "Bad Request" response + Given new "GetScheduleOnCallUser" request + And request contains "schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/bugle + Scenario: Get the schedule of an on-call user returns "Not Found" response + Given new "GetScheduleOnCallUser" request + And request contains "schedule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/bugle + Scenario: Get the schedule of an on-call user returns "OK" response + Given new "GetScheduleOnCallUser" request + And there is a valid "schedule" in the system + And request contains "schedule_id" parameter from "schedule.data.id" + When the request is sent + Then the response status is 200 OK + @skip-python @team:DataDog/bugle Scenario: Set on-call team routing rules returns "OK" response Given new "SetOnCallTeamRoutingRules" request 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 2b53228c62d..b9ea72c1d00 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 @@ -1943,6 +1943,12 @@ "type": "idempotent" } }, + "GetScheduleOnCallUser": { + "tag": "On-Call", + "undo": { + "type": "safe" + } + }, "GetOnCallTeamRoutingRules": { "tag": "On-Call", "undo": {