diff --git a/.apigentools-info b/.apigentools-info index a8031a26ebe..67ddb52faa5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-02 18:58:13.273150", - "spec_repo_commit": "aee9e14a" + "regenerated": "2023-10-04 17:33:04.961391", + "spec_repo_commit": "adf28ce4" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-02 18:58:13.288015", - "spec_repo_commit": "aee9e14a" + "regenerated": "2023-10-04 17:33:04.978253", + "spec_repo_commit": "adf28ce4" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 15061f9e125..8f64477c474 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -9085,6 +9085,86 @@ components: maxItems: 2 minItems: 2 type: array + PowerpackTemplateVariableContents: + description: Powerpack template variable contents. + properties: + name: + description: The name of the variable. + example: host1 + type: string + prefix: + description: The tag prefix associated with the variable. + type: string + values: + description: One or many template variable values within the saved view, + which will be unioned together using `OR` if more than one is specified. + example: + - my-host + - host1 + - host2 + items: + description: One or more possible values of the template variable. + minLength: 1 + type: string + type: array + required: + - name + - values + type: object + PowerpackTemplateVariables: + description: Powerpack template variables. + properties: + controlled_by_powerpack: + description: Template variables controlled at the powerpack level. + items: + $ref: '#/components/schemas/PowerpackTemplateVariableContents' + type: array + controlled_externally: + description: Template variables controlled by the external resource, such + as the dashboard this powerpack is on. + items: + $ref: '#/components/schemas/PowerpackTemplateVariableContents' + type: array + type: object + PowerpackWidgetDefinition: + description: The powerpack widget allows you to keep similar graphs together + on your timeboard. Each group has a custom header, can hold one to many graphs, + and is collapsible. + properties: + background_color: + description: Background color of the powerpack title. + type: string + banner_img: + description: URL of image to display as a banner for the powerpack. + type: string + powerpack_id: + description: UUID of the associated powerpack. + example: df43cf2a-6475-490d-b686-6fbc6cb9a49c + type: string + show_title: + default: true + description: Whether to show the title or not. + type: boolean + template_variables: + $ref: '#/components/schemas/PowerpackTemplateVariables' + title: + description: Title of the widget. + type: string + type: + $ref: '#/components/schemas/PowerpackWidgetDefinitionType' + required: + - type + - powerpack_id + type: object + PowerpackWidgetDefinitionType: + default: powerpack + description: Type of the powerpack widget. + enum: + - powerpack + example: powerpack + type: string + x-enum-varnames: + - POWERPACK ProcessQueryDefinition: description: The process query to use in the widget. properties: @@ -19975,6 +20055,7 @@ components: - $ref: '#/components/schemas/LogStreamWidgetDefinition' - $ref: '#/components/schemas/MonitorSummaryWidgetDefinition' - $ref: '#/components/schemas/NoteWidgetDefinition' + - $ref: '#/components/schemas/PowerpackWidgetDefinition' - $ref: '#/components/schemas/QueryValueWidgetDefinition' - $ref: '#/components/schemas/RunWorkflowWidgetDefinition' - $ref: '#/components/schemas/SLOListWidgetDefinition' diff --git a/examples/v1/dashboards/CreateDashboard_1754992756.java b/examples/v1/dashboards/CreateDashboard_1754992756.java new file mode 100644 index 00000000000..628b6bbe29f --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1754992756.java @@ -0,0 +1,69 @@ +// Create a new dashboard with powerpack widget + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.DashboardsApi; +import com.datadog.api.client.v1.model.Dashboard; +import com.datadog.api.client.v1.model.DashboardLayoutType; +import com.datadog.api.client.v1.model.PowerpackTemplateVariableContents; +import com.datadog.api.client.v1.model.PowerpackTemplateVariables; +import com.datadog.api.client.v1.model.PowerpackWidgetDefinition; +import com.datadog.api.client.v1.model.PowerpackWidgetDefinitionType; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetDefinition; +import com.datadog.api.client.v1.model.WidgetLayout; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + // there is a valid "powerpack" in the system + String POWERPACK_DATA_ID = System.getenv("POWERPACK_DATA_ID"); + + Dashboard body = + new Dashboard() + .title("Example-Dashboard with powerpack widget") + .layoutType(DashboardLayoutType.ORDERED) + .widgets( + Collections.singletonList( + new Widget() + .definition( + new WidgetDefinition( + new PowerpackWidgetDefinition() + .type(PowerpackWidgetDefinitionType.POWERPACK) + .powerpackId(POWERPACK_DATA_ID) + .templateVariables( + new PowerpackTemplateVariables() + .controlledByPowerpack( + Collections.singletonList( + new PowerpackTemplateVariableContents() + .name("foo") + .prefix("bar") + .values( + Arrays.asList( + "baz", "qux", "quuz"))))))) + .layout( + new WidgetLayout() + .x(1L) + .y(1L) + .width(2L) + .height(2L) + .isColumnBreak(false)))) + .description("description") + .isReadOnly(false); + + try { + Dashboard result = apiInstance.createDashboard(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#createDashboard"); + 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/v1/model/PowerpackTemplateVariableContents.java b/src/main/java/com/datadog/api/client/v1/model/PowerpackTemplateVariableContents.java new file mode 100644 index 00000000000..91f419bb948 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/PowerpackTemplateVariableContents.java @@ -0,0 +1,210 @@ +/* + * 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.v1.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; + +/** Powerpack template variable contents. */ +@JsonPropertyOrder({ + PowerpackTemplateVariableContents.JSON_PROPERTY_NAME, + PowerpackTemplateVariableContents.JSON_PROPERTY_PREFIX, + PowerpackTemplateVariableContents.JSON_PROPERTY_VALUES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PowerpackTemplateVariableContents { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_PREFIX = "prefix"; + private String prefix; + + public static final String JSON_PROPERTY_VALUES = "values"; + private List values = new ArrayList<>(); + + public PowerpackTemplateVariableContents() {} + + @JsonCreator + public PowerpackTemplateVariableContents( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUES) List values) { + this.name = name; + this.values = values; + } + + public PowerpackTemplateVariableContents name(String name) { + this.name = name; + return this; + } + + /** + * The name of the variable. + * + * @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 PowerpackTemplateVariableContents prefix(String prefix) { + this.prefix = prefix; + return this; + } + + /** + * The tag prefix associated with the variable. + * + * @return prefix + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PREFIX) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public PowerpackTemplateVariableContents values(List values) { + this.values = values; + return this; + } + + public PowerpackTemplateVariableContents addValuesItem(String valuesItem) { + this.values.add(valuesItem); + return this; + } + + /** + * One or many template variable values within the saved view, which will be unioned together + * using OR if more than one is specified. + * + * @return values + */ + @JsonProperty(JSON_PROPERTY_VALUES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + /** + * 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 PowerpackTemplateVariableContents + */ + @JsonAnySetter + public PowerpackTemplateVariableContents 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 PowerpackTemplateVariableContents object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PowerpackTemplateVariableContents powerpackTemplateVariableContents = + (PowerpackTemplateVariableContents) o; + return Objects.equals(this.name, powerpackTemplateVariableContents.name) + && Objects.equals(this.prefix, powerpackTemplateVariableContents.prefix) + && Objects.equals(this.values, powerpackTemplateVariableContents.values) + && Objects.equals( + this.additionalProperties, powerpackTemplateVariableContents.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, prefix, values, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PowerpackTemplateVariableContents {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" prefix: ").append(toIndentedString(prefix)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).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/v1/model/PowerpackTemplateVariables.java b/src/main/java/com/datadog/api/client/v1/model/PowerpackTemplateVariables.java new file mode 100644 index 00000000000..942cfb8de2a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/PowerpackTemplateVariables.java @@ -0,0 +1,204 @@ +/* + * 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.v1.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; + +/** Powerpack template variables. */ +@JsonPropertyOrder({ + PowerpackTemplateVariables.JSON_PROPERTY_CONTROLLED_BY_POWERPACK, + PowerpackTemplateVariables.JSON_PROPERTY_CONTROLLED_EXTERNALLY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PowerpackTemplateVariables { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONTROLLED_BY_POWERPACK = "controlled_by_powerpack"; + private List controlledByPowerpack = null; + + public static final String JSON_PROPERTY_CONTROLLED_EXTERNALLY = "controlled_externally"; + private List controlledExternally = null; + + public PowerpackTemplateVariables controlledByPowerpack( + List controlledByPowerpack) { + this.controlledByPowerpack = controlledByPowerpack; + for (PowerpackTemplateVariableContents item : controlledByPowerpack) { + this.unparsed |= item.unparsed; + } + return this; + } + + public PowerpackTemplateVariables addControlledByPowerpackItem( + PowerpackTemplateVariableContents controlledByPowerpackItem) { + if (this.controlledByPowerpack == null) { + this.controlledByPowerpack = new ArrayList<>(); + } + this.controlledByPowerpack.add(controlledByPowerpackItem); + this.unparsed |= controlledByPowerpackItem.unparsed; + return this; + } + + /** + * Template variables controlled at the powerpack level. + * + * @return controlledByPowerpack + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTROLLED_BY_POWERPACK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getControlledByPowerpack() { + return controlledByPowerpack; + } + + public void setControlledByPowerpack( + List controlledByPowerpack) { + this.controlledByPowerpack = controlledByPowerpack; + } + + public PowerpackTemplateVariables controlledExternally( + List controlledExternally) { + this.controlledExternally = controlledExternally; + for (PowerpackTemplateVariableContents item : controlledExternally) { + this.unparsed |= item.unparsed; + } + return this; + } + + public PowerpackTemplateVariables addControlledExternallyItem( + PowerpackTemplateVariableContents controlledExternallyItem) { + if (this.controlledExternally == null) { + this.controlledExternally = new ArrayList<>(); + } + this.controlledExternally.add(controlledExternallyItem); + this.unparsed |= controlledExternallyItem.unparsed; + return this; + } + + /** + * Template variables controlled by the external resource, such as the dashboard this powerpack is + * on. + * + * @return controlledExternally + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTROLLED_EXTERNALLY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getControlledExternally() { + return controlledExternally; + } + + public void setControlledExternally( + List controlledExternally) { + this.controlledExternally = controlledExternally; + } + + /** + * 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 PowerpackTemplateVariables + */ + @JsonAnySetter + public PowerpackTemplateVariables 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 PowerpackTemplateVariables object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PowerpackTemplateVariables powerpackTemplateVariables = (PowerpackTemplateVariables) o; + return Objects.equals( + this.controlledByPowerpack, powerpackTemplateVariables.controlledByPowerpack) + && Objects.equals( + this.controlledExternally, powerpackTemplateVariables.controlledExternally) + && Objects.equals( + this.additionalProperties, powerpackTemplateVariables.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(controlledByPowerpack, controlledExternally, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PowerpackTemplateVariables {\n"); + sb.append(" controlledByPowerpack: ") + .append(toIndentedString(controlledByPowerpack)) + .append("\n"); + sb.append(" controlledExternally: ") + .append(toIndentedString(controlledExternally)) + .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/v1/model/PowerpackWidgetDefinition.java b/src/main/java/com/datadog/api/client/v1/model/PowerpackWidgetDefinition.java new file mode 100644 index 00000000000..ab1b5ba9b60 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/PowerpackWidgetDefinition.java @@ -0,0 +1,327 @@ +/* + * 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.v1.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 powerpack widget allows you to keep similar graphs together on your timeboard. Each group has + * a custom header, can hold one to many graphs, and is collapsible. + */ +@JsonPropertyOrder({ + PowerpackWidgetDefinition.JSON_PROPERTY_BACKGROUND_COLOR, + PowerpackWidgetDefinition.JSON_PROPERTY_BANNER_IMG, + PowerpackWidgetDefinition.JSON_PROPERTY_POWERPACK_ID, + PowerpackWidgetDefinition.JSON_PROPERTY_SHOW_TITLE, + PowerpackWidgetDefinition.JSON_PROPERTY_TEMPLATE_VARIABLES, + PowerpackWidgetDefinition.JSON_PROPERTY_TITLE, + PowerpackWidgetDefinition.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PowerpackWidgetDefinition { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_BACKGROUND_COLOR = "background_color"; + private String backgroundColor; + + public static final String JSON_PROPERTY_BANNER_IMG = "banner_img"; + private String bannerImg; + + public static final String JSON_PROPERTY_POWERPACK_ID = "powerpack_id"; + private String powerpackId; + + public static final String JSON_PROPERTY_SHOW_TITLE = "show_title"; + private Boolean showTitle = true; + + public static final String JSON_PROPERTY_TEMPLATE_VARIABLES = "template_variables"; + private PowerpackTemplateVariables templateVariables; + + public static final String JSON_PROPERTY_TITLE = "title"; + private String title; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PowerpackWidgetDefinitionType type = PowerpackWidgetDefinitionType.POWERPACK; + + public PowerpackWidgetDefinition() {} + + @JsonCreator + public PowerpackWidgetDefinition( + @JsonProperty(required = true, value = JSON_PROPERTY_POWERPACK_ID) String powerpackId, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + PowerpackWidgetDefinitionType type) { + this.powerpackId = powerpackId; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public PowerpackWidgetDefinition backgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + return this; + } + + /** + * Background color of the powerpack title. + * + * @return backgroundColor + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_BACKGROUND_COLOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBackgroundColor() { + return backgroundColor; + } + + public void setBackgroundColor(String backgroundColor) { + this.backgroundColor = backgroundColor; + } + + public PowerpackWidgetDefinition bannerImg(String bannerImg) { + this.bannerImg = bannerImg; + return this; + } + + /** + * URL of image to display as a banner for the powerpack. + * + * @return bannerImg + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_BANNER_IMG) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBannerImg() { + return bannerImg; + } + + public void setBannerImg(String bannerImg) { + this.bannerImg = bannerImg; + } + + public PowerpackWidgetDefinition powerpackId(String powerpackId) { + this.powerpackId = powerpackId; + return this; + } + + /** + * UUID of the associated powerpack. + * + * @return powerpackId + */ + @JsonProperty(JSON_PROPERTY_POWERPACK_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getPowerpackId() { + return powerpackId; + } + + public void setPowerpackId(String powerpackId) { + this.powerpackId = powerpackId; + } + + public PowerpackWidgetDefinition showTitle(Boolean showTitle) { + this.showTitle = showTitle; + return this; + } + + /** + * Whether to show the title or not. + * + * @return showTitle + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SHOW_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getShowTitle() { + return showTitle; + } + + public void setShowTitle(Boolean showTitle) { + this.showTitle = showTitle; + } + + public PowerpackWidgetDefinition templateVariables(PowerpackTemplateVariables templateVariables) { + this.templateVariables = templateVariables; + this.unparsed |= templateVariables.unparsed; + return this; + } + + /** + * Powerpack template variables. + * + * @return templateVariables + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEMPLATE_VARIABLES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PowerpackTemplateVariables getTemplateVariables() { + return templateVariables; + } + + public void setTemplateVariables(PowerpackTemplateVariables templateVariables) { + this.templateVariables = templateVariables; + } + + public PowerpackWidgetDefinition title(String title) { + this.title = title; + return this; + } + + /** + * Title of the widget. + * + * @return title + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TITLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public PowerpackWidgetDefinition type(PowerpackWidgetDefinitionType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of the powerpack widget. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PowerpackWidgetDefinitionType getType() { + return type; + } + + public void setType(PowerpackWidgetDefinitionType 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 PowerpackWidgetDefinition + */ + @JsonAnySetter + public PowerpackWidgetDefinition 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 PowerpackWidgetDefinition object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PowerpackWidgetDefinition powerpackWidgetDefinition = (PowerpackWidgetDefinition) o; + return Objects.equals(this.backgroundColor, powerpackWidgetDefinition.backgroundColor) + && Objects.equals(this.bannerImg, powerpackWidgetDefinition.bannerImg) + && Objects.equals(this.powerpackId, powerpackWidgetDefinition.powerpackId) + && Objects.equals(this.showTitle, powerpackWidgetDefinition.showTitle) + && Objects.equals(this.templateVariables, powerpackWidgetDefinition.templateVariables) + && Objects.equals(this.title, powerpackWidgetDefinition.title) + && Objects.equals(this.type, powerpackWidgetDefinition.type) + && Objects.equals( + this.additionalProperties, powerpackWidgetDefinition.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + backgroundColor, + bannerImg, + powerpackId, + showTitle, + templateVariables, + title, + type, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PowerpackWidgetDefinition {\n"); + sb.append(" backgroundColor: ").append(toIndentedString(backgroundColor)).append("\n"); + sb.append(" bannerImg: ").append(toIndentedString(bannerImg)).append("\n"); + sb.append(" powerpackId: ").append(toIndentedString(powerpackId)).append("\n"); + sb.append(" showTitle: ").append(toIndentedString(showTitle)).append("\n"); + sb.append(" templateVariables: ").append(toIndentedString(templateVariables)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).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/v1/model/PowerpackWidgetDefinitionType.java b/src/main/java/com/datadog/api/client/v1/model/PowerpackWidgetDefinitionType.java new file mode 100644 index 00000000000..3dcef0fe3e8 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/PowerpackWidgetDefinitionType.java @@ -0,0 +1,56 @@ +/* + * 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.v1.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; + +/** Type of the powerpack widget. */ +@JsonSerialize(using = PowerpackWidgetDefinitionType.PowerpackWidgetDefinitionTypeSerializer.class) +public class PowerpackWidgetDefinitionType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("powerpack")); + + public static final PowerpackWidgetDefinitionType POWERPACK = + new PowerpackWidgetDefinitionType("powerpack"); + + PowerpackWidgetDefinitionType(String value) { + super(value, allowedValues); + } + + public static class PowerpackWidgetDefinitionTypeSerializer + extends StdSerializer { + public PowerpackWidgetDefinitionTypeSerializer(Class t) { + super(t); + } + + public PowerpackWidgetDefinitionTypeSerializer() { + this(null); + } + + @Override + public void serialize( + PowerpackWidgetDefinitionType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static PowerpackWidgetDefinitionType fromValue(String value) { + return new PowerpackWidgetDefinitionType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/WidgetDefinition.java b/src/main/java/com/datadog/api/client/v1/model/WidgetDefinition.java index a1df7998c80..7bd6b9a257c 100644 --- a/src/main/java/com/datadog/api/client/v1/model/WidgetDefinition.java +++ b/src/main/java/com/datadog/api/client/v1/model/WidgetDefinition.java @@ -933,6 +933,51 @@ public WidgetDefinition deserialize(JsonParser jp, DeserializationContext ctxt) log.log(Level.FINER, "Input data does not match schema 'NoteWidgetDefinition'", e); } + // deserialize PowerpackWidgetDefinition + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (PowerpackWidgetDefinition.class.equals(Integer.class) + || PowerpackWidgetDefinition.class.equals(Long.class) + || PowerpackWidgetDefinition.class.equals(Float.class) + || PowerpackWidgetDefinition.class.equals(Double.class) + || PowerpackWidgetDefinition.class.equals(Boolean.class) + || PowerpackWidgetDefinition.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((PowerpackWidgetDefinition.class.equals(Integer.class) + || PowerpackWidgetDefinition.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((PowerpackWidgetDefinition.class.equals(Float.class) + || PowerpackWidgetDefinition.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (PowerpackWidgetDefinition.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (PowerpackWidgetDefinition.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(PowerpackWidgetDefinition.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 (!((PowerpackWidgetDefinition) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'PowerpackWidgetDefinition'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PowerpackWidgetDefinition'", e); + } + // deserialize QueryValueWidgetDefinition try { boolean attemptParsing = true; @@ -1686,6 +1731,11 @@ public WidgetDefinition(NoteWidgetDefinition o) { setActualInstance(o); } + public WidgetDefinition(PowerpackWidgetDefinition o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + public WidgetDefinition(QueryValueWidgetDefinition o) { super("oneOf", Boolean.FALSE); setActualInstance(o); @@ -1778,6 +1828,7 @@ public WidgetDefinition(TreeMapWidgetDefinition o) { schemas.put( "MonitorSummaryWidgetDefinition", new GenericType() {}); schemas.put("NoteWidgetDefinition", new GenericType() {}); + schemas.put("PowerpackWidgetDefinition", new GenericType() {}); schemas.put("QueryValueWidgetDefinition", new GenericType() {}); schemas.put("RunWorkflowWidgetDefinition", new GenericType() {}); schemas.put("SLOListWidgetDefinition", new GenericType() {}); @@ -1809,11 +1860,12 @@ public Map getSchemas() { * FunnelWidgetDefinition, GeomapWidgetDefinition, GroupWidgetDefinition, HeatMapWidgetDefinition, * HostMapWidgetDefinition, IFrameWidgetDefinition, ImageWidgetDefinition, * ListStreamWidgetDefinition, LogStreamWidgetDefinition, MonitorSummaryWidgetDefinition, - * NoteWidgetDefinition, QueryValueWidgetDefinition, RunWorkflowWidgetDefinition, - * SLOListWidgetDefinition, SLOWidgetDefinition, ScatterPlotWidgetDefinition, - * ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition, - * SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition, - * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition + * NoteWidgetDefinition, PowerpackWidgetDefinition, QueryValueWidgetDefinition, + * RunWorkflowWidgetDefinition, SLOListWidgetDefinition, SLOWidgetDefinition, + * ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, + * SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition, + * TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition, + * TreeMapWidgetDefinition * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -1897,6 +1949,10 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf(PowerpackWidgetDefinition.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(QueryValueWidgetDefinition.class, instance, new HashSet>())) { super.setActualInstance(instance); return; @@ -1967,11 +2023,12 @@ public void setActualInstance(Object instance) { + " GroupWidgetDefinition, HeatMapWidgetDefinition, HostMapWidgetDefinition," + " IFrameWidgetDefinition, ImageWidgetDefinition, ListStreamWidgetDefinition," + " LogStreamWidgetDefinition, MonitorSummaryWidgetDefinition, NoteWidgetDefinition," - + " QueryValueWidgetDefinition, RunWorkflowWidgetDefinition, SLOListWidgetDefinition," - + " SLOWidgetDefinition, ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition," - + " ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition," - + " SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition," - + " ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition"); + + " PowerpackWidgetDefinition, QueryValueWidgetDefinition, RunWorkflowWidgetDefinition," + + " SLOListWidgetDefinition, SLOWidgetDefinition, ScatterPlotWidgetDefinition," + + " ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition," + + " SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition," + + " TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition," + + " TreeMapWidgetDefinition"); } /** @@ -1982,11 +2039,11 @@ public void setActualInstance(Object instance) { * GroupWidgetDefinition, HeatMapWidgetDefinition, HostMapWidgetDefinition, * IFrameWidgetDefinition, ImageWidgetDefinition, ListStreamWidgetDefinition, * LogStreamWidgetDefinition, MonitorSummaryWidgetDefinition, NoteWidgetDefinition, - * QueryValueWidgetDefinition, RunWorkflowWidgetDefinition, SLOListWidgetDefinition, - * SLOWidgetDefinition, ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition, - * ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition, SunburstWidgetDefinition, - * TableWidgetDefinition, TimeseriesWidgetDefinition, ToplistWidgetDefinition, - * TopologyMapWidgetDefinition, TreeMapWidgetDefinition + * PowerpackWidgetDefinition, QueryValueWidgetDefinition, RunWorkflowWidgetDefinition, + * SLOListWidgetDefinition, SLOWidgetDefinition, ScatterPlotWidgetDefinition, + * ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition, + * SunburstWidgetDefinition, TableWidgetDefinition, TimeseriesWidgetDefinition, + * ToplistWidgetDefinition, TopologyMapWidgetDefinition, TreeMapWidgetDefinition * * @return The actual instance (AlertGraphWidgetDefinition, AlertValueWidgetDefinition, * ChangeWidgetDefinition, CheckStatusWidgetDefinition, DistributionWidgetDefinition, @@ -1994,12 +2051,12 @@ public void setActualInstance(Object instance) { * FunnelWidgetDefinition, GeomapWidgetDefinition, GroupWidgetDefinition, * HeatMapWidgetDefinition, HostMapWidgetDefinition, IFrameWidgetDefinition, * ImageWidgetDefinition, ListStreamWidgetDefinition, LogStreamWidgetDefinition, - * MonitorSummaryWidgetDefinition, NoteWidgetDefinition, QueryValueWidgetDefinition, - * RunWorkflowWidgetDefinition, SLOListWidgetDefinition, SLOWidgetDefinition, - * ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition, ServiceSummaryWidgetDefinition, - * SplitGraphWidgetDefinition, SunburstWidgetDefinition, TableWidgetDefinition, - * TimeseriesWidgetDefinition, ToplistWidgetDefinition, TopologyMapWidgetDefinition, - * TreeMapWidgetDefinition) + * MonitorSummaryWidgetDefinition, NoteWidgetDefinition, PowerpackWidgetDefinition, + * QueryValueWidgetDefinition, RunWorkflowWidgetDefinition, SLOListWidgetDefinition, + * SLOWidgetDefinition, ScatterPlotWidgetDefinition, ServiceMapWidgetDefinition, + * ServiceSummaryWidgetDefinition, SplitGraphWidgetDefinition, SunburstWidgetDefinition, + * TableWidgetDefinition, TimeseriesWidgetDefinition, ToplistWidgetDefinition, + * TopologyMapWidgetDefinition, TreeMapWidgetDefinition) */ @Override public Object getActualInstance() { @@ -2217,6 +2274,17 @@ public NoteWidgetDefinition getNoteWidgetDefinition() throws ClassCastException return (NoteWidgetDefinition) super.getActualInstance(); } + /** + * Get the actual instance of `PowerpackWidgetDefinition`. If the actual instance is not + * `PowerpackWidgetDefinition`, the ClassCastException will be thrown. + * + * @return The actual instance of `PowerpackWidgetDefinition` + * @throws ClassCastException if the instance is not `PowerpackWidgetDefinition` + */ + public PowerpackWidgetDefinition getPowerpackWidgetDefinition() throws ClassCastException { + return (PowerpackWidgetDefinition) super.getActualInstance(); + } + /** * Get the actual instance of `QueryValueWidgetDefinition`. If the actual instance is not * `QueryValueWidgetDefinition`, the ClassCastException will be thrown. diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.freeze new file mode 100644 index 00000000000..e9f7b08fe2d --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.freeze @@ -0,0 +1 @@ +2023-09-26T21:29:30.230Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.json new file mode 100644 index 00000000000..17e881dbb9c --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_powerpack_widget.json @@ -0,0 +1,113 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"description\":\"Sample powerpack\",\"group_widget\":{\"definition\":{\"layout_type\":\"ordered\",\"show_title\":true,\"title\":\"Sample Powerpack\",\"type\":\"group\",\"widgets\":[{\"definition\":{\"content\":\"test\",\"type\":\"note\"}}]},\"layout\":{\"height\":3,\"width\":12,\"x\":0,\"y\":0}},\"name\":\"Sample Powerpack\",\"tags\":[\"tag:sample\"],\"template_variables\":[{\"defaults\":[\"*\"],\"name\":\"sample\"}]},\"type\":\"powerpack\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/powerpacks", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"type\":\"powerpack\",\"id\":\"c71559ce-5cb3-11ee-9164-da7ad0900002\",\"attributes\":{\"name\":\"Sample Powerpack\",\"description\":\"Sample powerpack\",\"group_widget\":{\"definition\":{\"layout_type\":\"ordered\",\"show_title\":true,\"title\":\"Sample Powerpack\",\"type\":\"group\",\"widgets\":[{\"definition\":{\"content\":\"test\",\"type\":\"note\"},\"id\":8492163139927418}]},\"layout\":{\"height\":3,\"width\":12,\"x\":0,\"y\":0}},\"template_variables\":[{\"defaults\":[\"*\"],\"name\":\"sample\"}],\"tags\":[\"tag:sample\"]},\"relationships\":{\"author\":{\"data\":{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\"}}}},\"included\":[{\"type\":\"users\",\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"attributes\":{\"name\":null,\"email\":\"frog@datadoghq.com\"}}]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8305fb37-79a4-03a2-aa69-f085c06f0597" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"description\":\"description\",\"is_read_only\":false,\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_powerpack_widget-1695763770 with powerpack widget\",\"widgets\":[{\"definition\":{\"powerpack_id\":\"c71559ce-5cb3-11ee-9164-da7ad0900002\",\"template_variables\":{\"controlled_by_powerpack\":[{\"name\":\"foo\",\"prefix\":\"bar\",\"values\":[\"baz\",\"qux\",\"quuz\"]}],\"controlled_externally\":[]},\"type\":\"powerpack\"},\"layout\":{\"height\":2,\"is_column_break\":false,\"width\":2,\"x\":1,\"y\":1}}]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"qk3-bn8-9pa\",\"title\":\"Test-Create_a_new_dashboard_with_powerpack_widget-1695763770 with powerpack widget\",\"description\":\"description\",\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/qk3-bn8-9pa/test-createanewdashboardwithpowerpackwidget-1695763770-with-powerpack-widget\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"powerpack_id\":\"c71559ce-5cb3-11ee-9164-da7ad0900002\",\"template_variables\":{\"controlled_by_powerpack\":[{\"name\":\"foo\",\"prefix\":\"bar\",\"values\":[\"baz\",\"qux\",\"quuz\"]}],\"controlled_externally\":[]},\"type\":\"powerpack\"},\"layout\":{\"height\":2,\"is_column_break\":false,\"width\":2,\"x\":1,\"y\":1},\"id\":5618921727592736}],\"notify_list\":null,\"created_at\":\"2023-09-26T21:29:30.677263+00:00\",\"modified_at\":\"2023-09-26T21:29:30.677263+00:00\",\"restricted_roles\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d8ab6413-2eff-6052-7bbe-0ca82fcf0d6c" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/dashboard/qk3-bn8-9pa", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"qk3-bn8-9pa\"}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "665b2997-a64f-af9f-4780-24ce79a28eef" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/powerpacks/c71559ce-5cb3-11ee-9164-da7ad0900002", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d8baa7c8-cbe4-b53a-5784-7782abf4c72e" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Create_a_new_powerpack_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Create_a_new_powerpack_returns_OK_response.json index c6763aad562..b8e5100d8a5 100644 --- a/src/test/resources/cassettes/features/v2/Create_a_new_powerpack_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Create_a_new_powerpack_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f059b" + "id": "8305fb37-79a4-03a2-aa69-f085c06f059c" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Delete_a_powerpack_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Delete_a_powerpack_returns_OK_response.json index e4dda2c7dad..ffe0b876601 100644 --- a/src/test/resources/cassettes/features/v2/Delete_a_powerpack_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Delete_a_powerpack_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f0599" + "id": "8305fb37-79a4-03a2-aa69-f085c06f059a" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_a_Powerpack_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_a_Powerpack_returns_OK_response.json index 5074df372d2..c0e2f9f15d8 100644 --- a/src/test/resources/cassettes/features/v2/Get_a_Powerpack_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Get_a_Powerpack_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f0597" + "id": "8305fb37-79a4-03a2-aa69-f085c06f0598" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_all_powerpacks_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_all_powerpacks_returns_OK_response.json index 744d403782b..0bcb99750d5 100644 --- a/src/test/resources/cassettes/features/v2/Get_all_powerpacks_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Get_all_powerpacks_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f059a" + "id": "8305fb37-79a4-03a2-aa69-f085c06f059b" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_Bad_Request_response.json index a6a1a1b9756..e13d90a9bc7 100644 --- a/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_Bad_Request_response.json +++ b/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_Bad_Request_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f059c" + "id": "8305fb37-79a4-03a2-aa69-f085c06f059d" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_OK_response.json index 7242b3d457f..6a154f1159c 100644 --- a/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Update_a_powerpack_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "8305fb37-79a4-03a2-aa69-f085c06f0598" + "id": "8305fb37-79a4-03a2-aa69-f085c06f0599" }, { "httpRequest": { diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature index 2889132a64c..4d2a81f53de 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature @@ -541,6 +541,16 @@ Feature: Dashboards And the response "widgets[0].definition.type" is equal to "note" And the response "widgets[0].definition.content" is equal to "# Example Note" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with powerpack widget + Given new "CreateDashboard" request + And there is a valid "powerpack" in the system + And body from file "dashboards_json_payload/powerpack_widget.json" + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.type" is equal to "powerpack" + And the response "widgets[0].definition.powerpack_id" has the same value as "powerpack.data.id" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with query_table widget Given new "CreateDashboard" request diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/powerpack_widget.json b/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/powerpack_widget.json new file mode 100644 index 00000000000..de34784a687 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards_json_payload/powerpack_widget.json @@ -0,0 +1,29 @@ +{ + "title": "{{ unique }} with powerpack widget", + "layout_type": "ordered", + "widgets": [ + { + "definition": { + "type": "powerpack", + "powerpack_id": "{{ powerpack.data.id }}", + "template_variables": { + "controlled_externally": [], + "controlled_by_powerpack": [{ + "name": "foo", + "prefix": "bar", + "values": ["baz", "qux", "quuz"] + }] + } + }, + "layout": { + "x": 1, + "y": 1, + "width": 2, + "height": 2, + "is_column_break": false + } + } + ], + "description": "description", + "is_read_only": false +} \ No newline at end of file