diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 1c6fb51af7e..bfb67197915 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -36150,6 +36150,8 @@ components: $ref: "#/components/schemas/DowntimeNotifyEndStates" notify_end_types: $ref: "#/components/schemas/DowntimeNotifyEndTypes" + run_as: + $ref: "#/components/schemas/DowntimeRunAs" schedule: $ref: "#/components/schemas/DowntimeScheduleResponse" scope: @@ -36176,6 +36178,49 @@ components: oneOf: - $ref: "#/components/schemas/User" - $ref: "#/components/schemas/DowntimeMonitorIncludedItem" + DowntimeRunAs: + description: |- + The principals (users, roles, or teams) allowed to act on behalf of the downtime. + + **Note**: This feature is currently in Preview and may not be available for all organizations. + items: + $ref: "#/components/schemas/DowntimeRunAsItem" + readOnly: true + type: array + DowntimeRunAsItem: + description: A set of principals allowed to act on behalf of the downtime. + properties: + principals: + description: List of principals allowed to act on behalf of the downtime. + items: + $ref: "#/components/schemas/DowntimeRunAsPrincipal" + type: array + type: object + DowntimeRunAsPrincipal: + description: A principal (user, role, or team) allowed to act on behalf of the downtime. + properties: + id: + description: The ID of the principal. + example: "00000000-0000-1234-0000-000000000000" + type: string + type: + $ref: "#/components/schemas/DowntimeRunAsPrincipalType" + required: + - id + - type + type: object + DowntimeRunAsPrincipalType: + description: The type of principal allowed to act on behalf of the downtime. + enum: + - user + - role + - team + example: "user" + type: string + x-enum-varnames: + - USER + - ROLE + - TEAM DowntimeScheduleCreateRequest: description: Schedule for the downtime. oneOf: @@ -153062,6 +153107,17 @@ paths: schema: example: "created_by,monitor" type: string + - description: |- + If `true`, include the `run_as` attribute in the response, which lists the principals allowed to + act on behalf of the downtime. + + **Note**: This feature is currently in Preview and may not be available for all organizations. + in: query + name: with_run_as + required: false + schema: + default: false + type: boolean responses: "200": content: diff --git a/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java b/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java index 34719e71704..7c86f14c560 100644 --- a/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/DowntimesApi.java @@ -324,6 +324,7 @@ public CompletableFuture> createDowntimeWithHttpIn /** Manage optional parameters to getDowntime. */ public static class GetDowntimeOptionalParameters { private String include; + private Boolean withRunAs; /** * Set include. @@ -337,6 +338,20 @@ public GetDowntimeOptionalParameters include(String include) { this.include = include; return this; } + + /** + * Set withRunAs. + * + * @param withRunAs If true, include the run_as attribute in the + * response, which lists the principals allowed to act on behalf of the downtime. + * Note: This feature is currently in Preview and may not be available for + * all organizations. (optional, default to false) + * @return GetDowntimeOptionalParameters + */ + public GetDowntimeOptionalParameters withRunAs(Boolean withRunAs) { + this.withRunAs = withRunAs; + return this; + } } /** @@ -429,6 +444,7 @@ public ApiResponse getDowntimeWithHttpInfo( 400, "Missing the required parameter 'downtimeId' when calling getDowntime"); } String include = parameters.include; + Boolean withRunAs = parameters.withRunAs; // create path and map variables String localVarPath = "/api/v2/downtime/{downtime_id}" @@ -439,6 +455,7 @@ public ApiResponse getDowntimeWithHttpInfo( Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_run_as", withRunAs)); Invocation.Builder builder = apiClient.createBuilder( @@ -482,6 +499,7 @@ public CompletableFuture> getDowntimeWithHttpInfoA return result; } String include = parameters.include; + Boolean withRunAs = parameters.withRunAs; // create path and map variables String localVarPath = "/api/v2/downtime/{downtime_id}" @@ -492,6 +510,7 @@ public CompletableFuture> getDowntimeWithHttpInfoA Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "include", include)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_run_as", withRunAs)); Invocation.Builder builder; try { diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java index e56c7dd7edc..fe8c99cb026 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeResponseAttributes.java @@ -31,6 +31,7 @@ DowntimeResponseAttributes.JSON_PROPERTY_MUTE_FIRST_RECOVERY_NOTIFICATION, DowntimeResponseAttributes.JSON_PROPERTY_NOTIFY_END_STATES, DowntimeResponseAttributes.JSON_PROPERTY_NOTIFY_END_TYPES, + DowntimeResponseAttributes.JSON_PROPERTY_RUN_AS, DowntimeResponseAttributes.JSON_PROPERTY_SCHEDULE, DowntimeResponseAttributes.JSON_PROPERTY_SCOPE, DowntimeResponseAttributes.JSON_PROPERTY_STATUS @@ -67,6 +68,9 @@ public class DowntimeResponseAttributes { public static final String JSON_PROPERTY_NOTIFY_END_TYPES = "notify_end_types"; private List notifyEndTypes = null; + public static final String JSON_PROPERTY_RUN_AS = "run_as"; + private List runAs = null; + public static final String JSON_PROPERTY_SCHEDULE = "schedule"; private DowntimeScheduleResponse schedule; @@ -326,6 +330,21 @@ public void setNotifyEndTypes(List notifyEndTypes this.notifyEndTypes = notifyEndTypes; } + /** + * The principals (users, roles, or teams) allowed to act on behalf of the downtime. + * + *

Note: This feature is currently in Preview and may not be available for all + * organizations. + * + * @return runAs + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RUN_AS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getRunAs() { + return runAs; + } + public DowntimeResponseAttributes schedule(DowntimeScheduleResponse schedule) { this.schedule = schedule; this.unparsed |= schedule.unparsed; @@ -467,6 +486,7 @@ public boolean equals(Object o) { downtimeResponseAttributes.muteFirstRecoveryNotification) && Objects.equals(this.notifyEndStates, downtimeResponseAttributes.notifyEndStates) && Objects.equals(this.notifyEndTypes, downtimeResponseAttributes.notifyEndTypes) + && Objects.equals(this.runAs, downtimeResponseAttributes.runAs) && Objects.equals(this.schedule, downtimeResponseAttributes.schedule) && Objects.equals(this.scope, downtimeResponseAttributes.scope) && Objects.equals(this.status, downtimeResponseAttributes.status) @@ -486,6 +506,7 @@ public int hashCode() { muteFirstRecoveryNotification, notifyEndStates, notifyEndTypes, + runAs, schedule, scope, status, @@ -507,6 +528,7 @@ public String toString() { .append("\n"); sb.append(" notifyEndStates: ").append(toIndentedString(notifyEndStates)).append("\n"); sb.append(" notifyEndTypes: ").append(toIndentedString(notifyEndTypes)).append("\n"); + sb.append(" runAs: ").append(toIndentedString(runAs)).append("\n"); sb.append(" schedule: ").append(toIndentedString(schedule)).append("\n"); sb.append(" scope: ").append(toIndentedString(scope)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsItem.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsItem.java new file mode 100644 index 00000000000..a9aacb875c8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsItem.java @@ -0,0 +1,156 @@ +/* + * 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; + +/** A set of principals allowed to act on behalf of the downtime. */ +@JsonPropertyOrder({DowntimeRunAsItem.JSON_PROPERTY_PRINCIPALS}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRunAsItem { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PRINCIPALS = "principals"; + private List principals = null; + + public DowntimeRunAsItem principals(List principals) { + this.principals = principals; + if (principals != null) { + for (DowntimeRunAsPrincipal item : principals) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public DowntimeRunAsItem addPrincipalsItem(DowntimeRunAsPrincipal principalsItem) { + if (this.principals == null) { + this.principals = new ArrayList<>(); + } + this.principals.add(principalsItem); + this.unparsed |= principalsItem.unparsed; + return this; + } + + /** + * List of principals allowed to act on behalf of the downtime. + * + * @return principals + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PRINCIPALS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getPrincipals() { + return principals; + } + + public void setPrincipals(List principals) { + this.principals = principals; + if (principals != null) { + for (DowntimeRunAsPrincipal item : principals) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * 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 DowntimeRunAsItem + */ + @JsonAnySetter + public DowntimeRunAsItem 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 DowntimeRunAsItem object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRunAsItem downtimeRunAsItem = (DowntimeRunAsItem) o; + return Objects.equals(this.principals, downtimeRunAsItem.principals) + && Objects.equals(this.additionalProperties, downtimeRunAsItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(principals, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRunAsItem {\n"); + sb.append(" principals: ").append(toIndentedString(principals)).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/DowntimeRunAsPrincipal.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsPrincipal.java new file mode 100644 index 00000000000..9998d8b9929 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsPrincipal.java @@ -0,0 +1,178 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A principal (user, role, or team) allowed to act on behalf of the downtime. */ +@JsonPropertyOrder({ + DowntimeRunAsPrincipal.JSON_PROPERTY_ID, + DowntimeRunAsPrincipal.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DowntimeRunAsPrincipal { + @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 DowntimeRunAsPrincipalType type; + + public DowntimeRunAsPrincipal() {} + + @JsonCreator + public DowntimeRunAsPrincipal( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DowntimeRunAsPrincipalType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DowntimeRunAsPrincipal id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the principal. + * + * @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 DowntimeRunAsPrincipal type(DowntimeRunAsPrincipalType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of principal allowed to act on behalf of the downtime. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DowntimeRunAsPrincipalType getType() { + return type; + } + + public void setType(DowntimeRunAsPrincipalType 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 DowntimeRunAsPrincipal + */ + @JsonAnySetter + public DowntimeRunAsPrincipal 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 DowntimeRunAsPrincipal object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DowntimeRunAsPrincipal downtimeRunAsPrincipal = (DowntimeRunAsPrincipal) o; + return Objects.equals(this.id, downtimeRunAsPrincipal.id) + && Objects.equals(this.type, downtimeRunAsPrincipal.type) + && Objects.equals(this.additionalProperties, downtimeRunAsPrincipal.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DowntimeRunAsPrincipal {\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/DowntimeRunAsPrincipalType.java b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsPrincipalType.java new file mode 100644 index 00000000000..4ee2d278cbb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DowntimeRunAsPrincipalType.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; + +/** The type of principal allowed to act on behalf of the downtime. */ +@JsonSerialize(using = DowntimeRunAsPrincipalType.DowntimeRunAsPrincipalTypeSerializer.class) +public class DowntimeRunAsPrincipalType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("user", "role", "team")); + + public static final DowntimeRunAsPrincipalType USER = new DowntimeRunAsPrincipalType("user"); + public static final DowntimeRunAsPrincipalType ROLE = new DowntimeRunAsPrincipalType("role"); + public static final DowntimeRunAsPrincipalType TEAM = new DowntimeRunAsPrincipalType("team"); + + DowntimeRunAsPrincipalType(String value) { + super(value, allowedValues); + } + + public static class DowntimeRunAsPrincipalTypeSerializer + extends StdSerializer { + public DowntimeRunAsPrincipalTypeSerializer(Class t) { + super(t); + } + + public DowntimeRunAsPrincipalTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DowntimeRunAsPrincipalType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DowntimeRunAsPrincipalType fromValue(String value) { + return new DowntimeRunAsPrincipalType(value); + } +}