Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35093,7 +35093,7 @@ components:
type: object
DeploymentRuleOptionsMonitor:
additionalProperties: false
description: Monitor options for deployment rules.
description: Monitor query options for deployment rules.
properties:
duration:
description: Seconds the monitor needs to stay in OK status for the rule to pass.
Expand All @@ -35111,7 +35111,7 @@ components:
example: false
type: boolean
query:
description: Monitors that match this query are evaluated.
description: A query that selects the monitors to evaluate.
example: "service:my-service env:prod"
type: string
warmup:
Expand All @@ -35124,6 +35124,66 @@ components:
required:
- query
type: object
DeploymentRuleOptionsMonitorId:
additionalProperties: false
description: A specific monitor and the groups to evaluate for it.
properties:
groups:
description: The exact monitor group names to evaluate. An empty array evaluates all groups.
example: []
items:
description: An exact monitor group name.
minLength: 1
type: string
type: array
uniqueItems: true
id:
description: The monitor's decimal ID.
example: "123456"
pattern: "^[1-9][0-9]*$"
type: string
required:
- id
- groups
type: object
DeploymentRuleOptionsMonitorIds:
additionalProperties: false
description: Specific monitor options for deployment rules.
properties:
duration:
description: Seconds the monitors need to stay in OK status for the rule to pass.
example: 3600
format: int64
type: integer
fail_on_no_data:
default: true
description: Whether the rule should fail if a selected monitor group is in a NO DATA state.
example: false
type: boolean
fail_on_no_groups_found:
default: false
description: Whether the rule should fail if no monitor groups are found for the selected monitors.
example: false
type: boolean
monitor_ids:
description: A non-empty list of specific monitors to evaluate.
example:
- groups: []
id: "123456"
items:
$ref: '#/components/schemas/DeploymentRuleOptionsMonitorId'
minItems: 1
type: array
warmup:
default: 0
description: Seconds to wait after a deployment starts before evaluating the monitors' statuses.
example: 0
format: int64
minimum: 0
type: integer
required:
- monitor_ids
type: object
DeploymentRuleResponse:
description: Response for a deployment rule.
properties:
Expand Down Expand Up @@ -35238,6 +35298,7 @@ components:
oneOf:
- $ref: '#/components/schemas/DeploymentRuleOptionsFaultyDeploymentDetection'
- $ref: '#/components/schemas/DeploymentRuleOptionsMonitor'
- $ref: '#/components/schemas/DeploymentRuleOptionsMonitorIds'
DetachCaseRequest:
description: Request for detaching security findings from their case.
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Create monitor deployment rule with monitor IDs returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DeploymentGatesApi;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParams;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsData;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsDataAttributes;
import com.datadog.api.client.v2.model.DeploymentRuleDataType;
import com.datadog.api.client.v2.model.DeploymentRuleOptionsMonitorId;
import com.datadog.api.client.v2.model.DeploymentRuleOptionsMonitorIds;
import com.datadog.api.client.v2.model.DeploymentRuleResponse;
import com.datadog.api.client.v2.model.DeploymentRulesOptions;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.createDeploymentRule", true);
DeploymentGatesApi apiInstance = new DeploymentGatesApi(defaultClient);

// there is a valid "deployment_gate" in the system
String DEPLOYMENT_GATE_DATA_ID = System.getenv("DEPLOYMENT_GATE_DATA_ID");

// there is a valid "monitor" in the system
Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));

CreateDeploymentRuleParams body =
new CreateDeploymentRuleParams()
.data(
new CreateDeploymentRuleParamsData()
.attributes(
new CreateDeploymentRuleParamsDataAttributes()
.dryRun(false)
.name("Specific monitor deployment rule")
.options(
new DeploymentRulesOptions(
new DeploymentRuleOptionsMonitorIds()
.monitorIds(
Collections.singletonList(
new DeploymentRuleOptionsMonitorId().id("7")))))
.type("monitor"))
.type(DeploymentRuleDataType.DEPLOYMENT_RULE));

try {
DeploymentRuleResponse result =
apiInstance.createDeploymentRule(DEPLOYMENT_GATE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeploymentGatesApi#createDeploymentRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Create monitor deployment rule with query returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DeploymentGatesApi;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParams;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsData;
import com.datadog.api.client.v2.model.CreateDeploymentRuleParamsDataAttributes;
import com.datadog.api.client.v2.model.DeploymentRuleDataType;
import com.datadog.api.client.v2.model.DeploymentRuleOptionsMonitor;
import com.datadog.api.client.v2.model.DeploymentRuleResponse;
import com.datadog.api.client.v2.model.DeploymentRulesOptions;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.createDeploymentRule", true);
DeploymentGatesApi apiInstance = new DeploymentGatesApi(defaultClient);

// there is a valid "deployment_gate" in the system
String DEPLOYMENT_GATE_DATA_ID = System.getenv("DEPLOYMENT_GATE_DATA_ID");

CreateDeploymentRuleParams body =
new CreateDeploymentRuleParams()
.data(
new CreateDeploymentRuleParamsData()
.attributes(
new CreateDeploymentRuleParamsDataAttributes()
.dryRun(false)
.name("Query monitor deployment rule")
.options(
new DeploymentRulesOptions(
new DeploymentRuleOptionsMonitor()
.query("service:transaction-backend env:production")))
.type("monitor"))
.type(DeploymentRuleDataType.DEPLOYMENT_RULE));

try {
DeploymentRuleResponse result =
apiInstance.createDeploymentRule(DEPLOYMENT_GATE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeploymentGatesApi#createDeploymentRule");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.Objects;

/** Monitor options for deployment rules. */
/** Monitor query options for deployment rules. */
@JsonPropertyOrder({
DeploymentRuleOptionsMonitor.JSON_PROPERTY_DURATION,
DeploymentRuleOptionsMonitor.JSON_PROPERTY_FAIL_ON_NO_DATA,
Expand Down Expand Up @@ -117,7 +117,7 @@ public DeploymentRuleOptionsMonitor query(String query) {
}

/**
* Monitors that match this query are evaluated.
* A query that selects the monitors to evaluate.
*
* @return query
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* 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.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.List;
import java.util.Objects;

/** A specific monitor and the groups to evaluate for it. */
@JsonPropertyOrder({
DeploymentRuleOptionsMonitorId.JSON_PROPERTY_GROUPS,
DeploymentRuleOptionsMonitorId.JSON_PROPERTY_ID
})
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class DeploymentRuleOptionsMonitorId {
@JsonIgnore public boolean unparsed = false;
public static final String JSON_PROPERTY_GROUPS = "groups";
private List<String> groups = new ArrayList<>();

public static final String JSON_PROPERTY_ID = "id";
private String id;

public DeploymentRuleOptionsMonitorId() {}

@JsonCreator
public DeploymentRuleOptionsMonitorId(
@JsonProperty(required = true, value = JSON_PROPERTY_GROUPS) List<String> groups,
@JsonProperty(required = true, value = JSON_PROPERTY_ID) String id) {
this.groups = groups;
this.id = id;
}

public DeploymentRuleOptionsMonitorId groups(List<String> groups) {
this.groups = groups;
return this;
}

public DeploymentRuleOptionsMonitorId addGroupsItem(String groupsItem) {
this.groups.add(groupsItem);
return this;
}

/**
* The exact monitor group names to evaluate. An empty array evaluates all groups.
*
* @return groups
*/
@JsonProperty(JSON_PROPERTY_GROUPS)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public List<String> getGroups() {
return groups;
}

public void setGroups(List<String> groups) {
this.groups = groups;
}

public DeploymentRuleOptionsMonitorId id(String id) {
this.id = id;
return this;
}

/**
* The monitor's decimal ID.
*
* @return id
*/
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

/** Return true if this DeploymentRuleOptionsMonitorId object is equal to o. */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DeploymentRuleOptionsMonitorId deploymentRuleOptionsMonitorId =
(DeploymentRuleOptionsMonitorId) o;
return Objects.equals(this.groups, deploymentRuleOptionsMonitorId.groups)
&& Objects.equals(this.id, deploymentRuleOptionsMonitorId.id);
}

@Override
public int hashCode() {
return Objects.hash(groups, id);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeploymentRuleOptionsMonitorId {\n");
sb.append(" groups: ").append(toIndentedString(groups)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).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 ");
}
}
Loading
Loading