Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2023-05-23 13:54:26.726857",
"spec_repo_commit": "2ccd9d0a"
"regenerated": "2023-05-23 19:09:15.215571",
"spec_repo_commit": "d1e6ae92"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-05-23 13:54:26.739494",
"spec_repo_commit": "2ccd9d0a"
"regenerated": "2023-05-23 19:09:15.228698",
"spec_repo_commit": "d1e6ae92"
}
}
}
49 changes: 49 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5829,6 +5829,43 @@ components:
type: string
x-enum-varnames:
- USER_AGENT_PARSER
MatchingDowntime:
description: Object describing a downtime that matches this monitor.
properties:
end:
description: POSIX timestamp to end the downtime.
example: 1412792983
format: int64
nullable: true
type: integer
id:
description: The downtime ID.
example: 1625
format: int64
readOnly: true
type: integer
scope:
description: 'The scope(s) to which the downtime applies. Must be in `key:value`
format. For example, `host:app2`.

Provide multiple scopes as a comma-separated list like `env:dev,env:prod`.

The resulting downtime applies to sources that matches ALL provided scopes
(`env:dev` **AND** `env:prod`).'
example:
- env:staging
items:
description: A scope. For example, `"env:staging"`.
type: string
type: array
start:
description: POSIX timestamp to start the downtime.
example: 1412792983
format: int64
type: integer
required:
- id
type: object
MetricContentEncoding:
default: deflate
description: HTTP header used to compress the media-type.
Expand Down Expand Up @@ -6109,6 +6146,11 @@ components:
format: int64
readOnly: true
type: integer
matching_downtimes:
description: A list of active downtimes that match this monitor.
items:
$ref: '#/components/schemas/MatchingDowntime'
type: array
message:
description: A message to include with notifications for this monitor.
type: string
Expand Down Expand Up @@ -25354,6 +25396,13 @@ paths:
required: false
schema:
type: string
- description: If this argument is set to true, then the returned data includes
all current active downtimes for the monitor.
in: query
name: with_downtimes
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
5 changes: 4 additions & 1 deletion examples/v1/monitors/GetMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MonitorsApi;
import com.datadog.api.client.v1.api.MonitorsApi.GetMonitorOptionalParameters;
import com.datadog.api.client.v1.model.Monitor;

public class Example {
Expand All @@ -14,7 +15,9 @@ public static void main(String[] args) {
Long MONITOR_ID = Long.parseLong(System.getenv("MONITOR_ID"));

try {
Monitor result = apiInstance.getMonitor(MONITOR_ID);
Monitor result =
apiInstance.getMonitor(
MONITOR_ID, new GetMonitorOptionalParameters().withDowntimes(true));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#getMonitor");
Expand Down
30 changes: 30 additions & 0 deletions examples/v1/monitors/GetMonitor_2200114573.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Get a monitor's details with downtime returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.MonitorsApi;
import com.datadog.api.client.v1.api.MonitorsApi.GetMonitorOptionalParameters;
import com.datadog.api.client.v1.model.Monitor;

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

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

try {
Monitor result =
apiInstance.getMonitor(
MONITOR_ID, new GetMonitorOptionalParameters().withDowntimes(true));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MonitorsApi#getMonitor");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/datadog/api/client/v1/api/MonitorsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ public CompletableFuture<ApiResponse<DeletedMonitor>> deleteMonitorWithHttpInfoA
/** Manage optional parameters to getMonitor. */
public static class GetMonitorOptionalParameters {
private String groupStates;
private Boolean withDowntimes;

/**
* Set groupStates.
Expand All @@ -818,6 +819,18 @@ public GetMonitorOptionalParameters groupStates(String groupStates) {
this.groupStates = groupStates;
return this;
}

/**
* Set withDowntimes.
*
* @param withDowntimes If this argument is set to true, then the returned data includes all
* current active downtimes for the monitor. (optional)
* @return GetMonitorOptionalParameters
*/
public GetMonitorOptionalParameters withDowntimes(Boolean withDowntimes) {
this.withDowntimes = withDowntimes;
return this;
}
}

/**
Expand Down Expand Up @@ -910,6 +923,7 @@ public ApiResponse<Monitor> getMonitorWithHttpInfo(
400, "Missing the required parameter 'monitorId' when calling getMonitor");
}
String groupStates = parameters.groupStates;
Boolean withDowntimes = parameters.withDowntimes;
// create path and map variables
String localVarPath =
"/api/v1/monitor/{monitor_id}"
Expand All @@ -919,6 +933,7 @@ public ApiResponse<Monitor> getMonitorWithHttpInfo(
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

localVarQueryParams.addAll(apiClient.parameterToPairs("", "group_states", groupStates));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_downtimes", withDowntimes));

Invocation.Builder builder =
apiClient.createBuilder(
Expand Down Expand Up @@ -962,6 +977,7 @@ public CompletableFuture<ApiResponse<Monitor>> getMonitorWithHttpInfoAsync(
return result;
}
String groupStates = parameters.groupStates;
Boolean withDowntimes = parameters.withDowntimes;
// create path and map variables
String localVarPath =
"/api/v1/monitor/{monitor_id}"
Expand All @@ -971,6 +987,7 @@ public CompletableFuture<ApiResponse<Monitor>> getMonitorWithHttpInfoAsync(
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

localVarQueryParams.addAll(apiClient.parameterToPairs("", "group_states", groupStates));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "with_downtimes", withDowntimes));

Invocation.Builder builder;
try {
Expand Down
186 changes: 186 additions & 0 deletions src/main/java/com/datadog/api/client/v1/model/MatchingDowntime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
/*
* 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.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;
import org.openapitools.jackson.nullable.JsonNullable;

/** Object describing a downtime that matches this monitor. */
@JsonPropertyOrder({
MatchingDowntime.JSON_PROPERTY_END,
MatchingDowntime.JSON_PROPERTY_ID,
MatchingDowntime.JSON_PROPERTY_SCOPE,
MatchingDowntime.JSON_PROPERTY_START
})
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class MatchingDowntime {
@JsonIgnore public boolean unparsed = false;
public static final String JSON_PROPERTY_END = "end";
private JsonNullable<Long> end = JsonNullable.<Long>undefined();

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

public static final String JSON_PROPERTY_SCOPE = "scope";
private List<String> scope = null;

public static final String JSON_PROPERTY_START = "start";
private Long start;

public MatchingDowntime() {}

@JsonCreator
public MatchingDowntime(@JsonProperty(required = true, value = JSON_PROPERTY_ID) Long id) {
this.id = id;
}

public MatchingDowntime end(Long end) {
this.end = JsonNullable.<Long>of(end);
return this;
}

/**
* POSIX timestamp to end the downtime.
*
* @return end
*/
@jakarta.annotation.Nullable
@JsonIgnore
public Long getEnd() {
return end.orElse(null);
}

@JsonProperty(JSON_PROPERTY_END)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public JsonNullable<Long> getEnd_JsonNullable() {
return end;
}

@JsonProperty(JSON_PROPERTY_END)
public void setEnd_JsonNullable(JsonNullable<Long> end) {
this.end = end;
}

public void setEnd(Long end) {
this.end = JsonNullable.<Long>of(end);
}

/**
* The downtime ID.
*
* @return id
*/
@JsonProperty(JSON_PROPERTY_ID)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public Long getId() {
return id;
}

public MatchingDowntime scope(List<String> scope) {
this.scope = scope;
return this;
}

public MatchingDowntime addScopeItem(String scopeItem) {
if (this.scope == null) {
this.scope = new ArrayList<>();
}
this.scope.add(scopeItem);
return this;
}

/**
* The scope(s) to which the downtime applies. Must be in <code>key:value</code> format. For
* example, <code>host:app2</code>. Provide multiple scopes as a comma-separated list like <code>
* env:dev,env:prod</code>. The resulting downtime applies to sources that matches ALL provided
* scopes (<code>env:dev</code> <strong>AND</strong> <code>env:prod</code>).
*
* @return scope
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_SCOPE)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getScope() {
return scope;
}

public void setScope(List<String> scope) {
this.scope = scope;
}

public MatchingDowntime start(Long start) {
this.start = start;
return this;
}

/**
* POSIX timestamp to start the downtime.
*
* @return start
*/
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_START)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public Long getStart() {
return start;
}

public void setStart(Long start) {
this.start = start;
}

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

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

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class MatchingDowntime {\n");
sb.append(" end: ").append(toIndentedString(end)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" scope: ").append(toIndentedString(scope)).append("\n");
sb.append(" start: ").append(toIndentedString(start)).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