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
36 changes: 30 additions & 6 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83346,6 +83346,8 @@ components:
$ref: "#/components/schemas/MonitorNotificationRuleName"
recipients:
$ref: "#/components/schemas/MonitorNotificationRuleRecipients"
rule_options:
$ref: "#/components/schemas/MonitorNotificationRuleOptions"
required: [name]
type: object
MonitorNotificationRuleBundleConfig:
Expand Down Expand Up @@ -83486,6 +83488,17 @@ components:
maxLength: 1000
minLength: 1
type: string
MonitorNotificationRuleOptions:
description: Additional options for the monitor notification rule.
properties:
is_threaded:
description: |-
Whether notifications from this rule are threaded. When `true`, follow-up notifications for the same monitor alert are posted in Slack as replies to the first notification.
Cannot be `true` when `bundle_config` is set.
example: true
type: boolean
required: [is_threaded]
type: object
MonitorNotificationRuleRecipients:
description: |-
A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'. Cannot be used with `conditional_recipients`.
Expand Down Expand Up @@ -83563,6 +83576,8 @@ components:
$ref: "#/components/schemas/MonitorNotificationRuleName"
recipients:
$ref: "#/components/schemas/MonitorNotificationRuleRecipients"
rule_options:
$ref: "#/components/schemas/MonitorNotificationRuleOptions"
type: object
MonitorNotificationRuleResponseIncludedItem:
description: An object related to a monitor notification rule.
Expand Down Expand Up @@ -139454,6 +139469,10 @@ components:
properties:
attributes:
$ref: "#/components/schemas/TimeseriesResponseAttributes"
id:
description: The identifier of the timeseries response resource.
example: "0"
type: string
type:
$ref: "#/components/schemas/TimeseriesFormulaResponseType"
type: object
Expand Down Expand Up @@ -140312,24 +140331,29 @@ components:
properties:
family:
description: Unit family, allows for conversion between units of the same family, for scaling.
example: time
example: percentage
type: string
id:
description: The identifier of the unit.
example: 17
format: int64
type: integer
name:
description: Unit name
example: minute
description: Unit name.
example: percent
type: string
plural:
description: Plural form of the unit name.
example: minutes
example: percent
type: string
scale_factor:
description: Factor for scaling between units of the same family.
example: 60.0
example: 1.0
format: double
type: number
short_name:
description: Abbreviation of the unit.
example: min
example: "%"
type: string
type: object
UnitCostCreateRequest:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Create a monitor notification rule with rule options returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MonitorsApi;
import com.datadog.api.client.v2.model.MonitorNotificationRuleAttributes;
import com.datadog.api.client.v2.model.MonitorNotificationRuleCreateRequest;
import com.datadog.api.client.v2.model.MonitorNotificationRuleCreateRequestData;
import com.datadog.api.client.v2.model.MonitorNotificationRuleFilter;
import com.datadog.api.client.v2.model.MonitorNotificationRuleFilterTags;
import com.datadog.api.client.v2.model.MonitorNotificationRuleOptions;
import com.datadog.api.client.v2.model.MonitorNotificationRuleResourceType;
import com.datadog.api.client.v2.model.MonitorNotificationRuleResponse;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MonitorsApi apiInstance = new MonitorsApi(defaultClient);

MonitorNotificationRuleCreateRequest body =
new MonitorNotificationRuleCreateRequest()
.data(
new MonitorNotificationRuleCreateRequestData()
.attributes(
new MonitorNotificationRuleAttributes()
.filter(
new MonitorNotificationRuleFilter(
new MonitorNotificationRuleFilterTags()
.tags(Collections.singletonList("test:example-monitor"))))
.name("test rule")
.recipients(Collections.singletonList("slack-test-channel"))
.ruleOptions(new MonitorNotificationRuleOptions().isThreaded(true)))
.type(MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE));

try {
MonitorNotificationRuleResponse result = apiInstance.createMonitorNotificationRule(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#createMonitorNotificationRule");
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,53 @@
// Update a monitor notification rule with rule options returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.MonitorsApi;
import com.datadog.api.client.v2.model.MonitorNotificationRuleAttributes;
import com.datadog.api.client.v2.model.MonitorNotificationRuleFilter;
import com.datadog.api.client.v2.model.MonitorNotificationRuleFilterTags;
import com.datadog.api.client.v2.model.MonitorNotificationRuleOptions;
import com.datadog.api.client.v2.model.MonitorNotificationRuleResourceType;
import com.datadog.api.client.v2.model.MonitorNotificationRuleResponse;
import com.datadog.api.client.v2.model.MonitorNotificationRuleUpdateRequest;
import com.datadog.api.client.v2.model.MonitorNotificationRuleUpdateRequestData;
import java.util.Collections;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
MonitorsApi apiInstance = new MonitorsApi(defaultClient);

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

MonitorNotificationRuleUpdateRequest body =
new MonitorNotificationRuleUpdateRequest()
.data(
new MonitorNotificationRuleUpdateRequestData()
.attributes(
new MonitorNotificationRuleAttributes()
.filter(
new MonitorNotificationRuleFilter(
new MonitorNotificationRuleFilterTags()
.tags(Collections.singletonList("test:example-monitor"))))
.name("updated rule")
.recipients(Collections.singletonList("slack-test-channel"))
.ruleOptions(new MonitorNotificationRuleOptions().isThreaded(false)))
.id(MONITOR_NOTIFICATION_RULE_DATA_ID)
.type(MonitorNotificationRuleResourceType.MONITOR_NOTIFICATION_RULE));

try {
MonitorNotificationRuleResponse result =
apiInstance.updateMonitorNotificationRule(MONITOR_NOTIFICATION_RULE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#updateMonitorNotificationRule");
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 @@ -21,7 +21,8 @@
MonitorNotificationRuleAttributes.JSON_PROPERTY_CONDITIONAL_RECIPIENTS,
MonitorNotificationRuleAttributes.JSON_PROPERTY_FILTER,
MonitorNotificationRuleAttributes.JSON_PROPERTY_NAME,
MonitorNotificationRuleAttributes.JSON_PROPERTY_RECIPIENTS
MonitorNotificationRuleAttributes.JSON_PROPERTY_RECIPIENTS,
MonitorNotificationRuleAttributes.JSON_PROPERTY_RULE_OPTIONS
})
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
Expand All @@ -42,6 +43,9 @@ public class MonitorNotificationRuleAttributes {
public static final String JSON_PROPERTY_RECIPIENTS = "recipients";
private List<String> recipients = null;

public static final String JSON_PROPERTY_RULE_OPTIONS = "rule_options";
private MonitorNotificationRuleOptions ruleOptions;

public MonitorNotificationRuleAttributes() {}

@JsonCreator
Expand Down Expand Up @@ -181,6 +185,31 @@ public void setRecipients(List<String> recipients) {
this.recipients = recipients;
}

public MonitorNotificationRuleAttributes ruleOptions(MonitorNotificationRuleOptions ruleOptions) {
this.ruleOptions = ruleOptions;
this.unparsed |= ruleOptions.unparsed;
return this;
}

/**
* Additional options for the monitor notification rule.
*
* @return ruleOptions
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_RULE_OPTIONS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public MonitorNotificationRuleOptions getRuleOptions() {
return ruleOptions;
}

public void setRuleOptions(MonitorNotificationRuleOptions ruleOptions) {
this.ruleOptions = ruleOptions;
if (ruleOptions != null) {
this.unparsed |= ruleOptions.unparsed;
}
}

/** Return true if this MonitorNotificationRuleAttributes object is equal to o. */
@Override
public boolean equals(Object o) {
Expand All @@ -197,12 +226,13 @@ public boolean equals(Object o) {
this.conditionalRecipients, monitorNotificationRuleAttributes.conditionalRecipients)
&& Objects.equals(this.filter, monitorNotificationRuleAttributes.filter)
&& Objects.equals(this.name, monitorNotificationRuleAttributes.name)
&& Objects.equals(this.recipients, monitorNotificationRuleAttributes.recipients);
&& Objects.equals(this.recipients, monitorNotificationRuleAttributes.recipients)
&& Objects.equals(this.ruleOptions, monitorNotificationRuleAttributes.ruleOptions);
}

@Override
public int hashCode() {
return Objects.hash(bundleConfig, conditionalRecipients, filter, name, recipients);
return Objects.hash(bundleConfig, conditionalRecipients, filter, name, recipients, ruleOptions);
}

@Override
Expand All @@ -216,6 +246,7 @@ public String toString() {
sb.append(" filter: ").append(toIndentedString(filter)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n");
sb.append(" ruleOptions: ").append(toIndentedString(ruleOptions)).append("\n");
sb.append('}');
return sb.toString();
}
Expand Down
Loading
Loading