Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint for listing all downtimes for the specified monitor #730

Merged
merged 1 commit into from
Apr 5, 2021
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.4.1.dev6",
"regenerated": "2021-04-02 09:24:50.379265",
"spec_repo_commit": "cc1654e"
"regenerated": "2021-04-05 14:18:01.718746",
"spec_repo_commit": "bd111f9"
},
"v2": {
"apigentools_version": "1.4.1.dev6",
"regenerated": "2021-04-02 09:25:34.946192",
"spec_repo_commit": "cc1654e"
"regenerated": "2021-04-05 14:18:42.846431",
"spec_repo_commit": "bd111f9"
}
}
}
70 changes: 70 additions & 0 deletions api_docs/v1/DowntimesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Method | HTTP request | Description
[**createDowntime**](DowntimesApi.md#createDowntime) | **POST** /api/v1/downtime | Schedule a downtime
[**getDowntime**](DowntimesApi.md#getDowntime) | **GET** /api/v1/downtime/{downtime_id} | Get a downtime
[**listDowntimes**](DowntimesApi.md#listDowntimes) | **GET** /api/v1/downtime | Get all downtimes
[**listMonitorDowntimes**](DowntimesApi.md#listMonitorDowntimes) | **GET** /api/v1/monitor/{monitor_id}/downtimes | Get all downtimes for a monitor
[**updateDowntime**](DowntimesApi.md#updateDowntime) | **PUT** /api/v1/downtime/{downtime_id} | Update a downtime


Expand Down Expand Up @@ -360,6 +361,75 @@ Name | Type | Description | Notes
| **403** | Forbidden | - |


## listMonitorDowntimes

> List<Downtime> listMonitorDowntimes(monitorId).execute();

Get all downtimes for a monitor

Get all downtimes for the specified monitor

### Example

```java
// Import classes:
import java.util.*;
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.DowntimesApi;

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

DowntimesApi apiInstance = new DowntimesApi(defaultClient);
Long monitorId = 56L; // Long | The id of the monitor
try {
List<Downtime> result = apiInstance.listMonitorDowntimes(monitorId)
.execute();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DowntimesApi#listMonitorDowntimes");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
```

### Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**monitorId** | **Long**| The id of the monitor |

### Return type

[**List&lt;Downtime&gt;**](Downtime.md)

### Authorization

[apiKeyAuth](README.md#apiKeyAuth), [appKeyAuth](README.md#appKeyAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | OK | - |
| **400** | Bad Request | - |
| **404** | Monitor Not Found error | - |


## updateDowntime

> Downtime updateDowntime(downtimeId).body(body).execute();
Expand Down
1 change: 1 addition & 0 deletions api_docs/v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Class | Method | HTTP request | Description
*DowntimesApi* | [**createDowntime**](DowntimesApi.md#createDowntime) | **POST** /api/v1/downtime | Schedule a downtime
*DowntimesApi* | [**getDowntime**](DowntimesApi.md#getDowntime) | **GET** /api/v1/downtime/{downtime_id} | Get a downtime
*DowntimesApi* | [**listDowntimes**](DowntimesApi.md#listDowntimes) | **GET** /api/v1/downtime | Get all downtimes
*DowntimesApi* | [**listMonitorDowntimes**](DowntimesApi.md#listMonitorDowntimes) | **GET** /api/v1/monitor/{monitor_id}/downtimes | Get all downtimes for a monitor
*DowntimesApi* | [**updateDowntime**](DowntimesApi.md#updateDowntime) | **PUT** /api/v1/downtime/{downtime_id} | Update a downtime
*EventsApi* | [**getEvent**](EventsApi.md#getEvent) | **GET** /api/v1/events/{event_id} | Get an event
*EventsApi* | [**listEvents**](EventsApi.md#listEvents) | **GET** /api/v1/events | Query the event stream
Expand Down
104 changes: 104 additions & 0 deletions src/main/java/com/datadog/api/v1/client/api/DowntimesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,110 @@ public APIlistDowntimesRequest listDowntimes() throws ApiException {
return new APIlistDowntimesRequest();
}

private ApiResponse<List<Downtime>> listMonitorDowntimesWithHttpInfo(Long monitorId)
throws ApiException {
Object localVarPostBody = null;

// verify the required parameter 'monitorId' is set
if (monitorId == null) {
throw new ApiException(
400, "Missing the required parameter 'monitorId' when calling listMonitorDowntimes");
}

// create path and map variables
String localVarPath =
"/api/v1/monitor/{monitor_id}/downtimes"
.replaceAll("\\{" + "monitor_id" + "\\}", apiClient.escapeString(monitorId.toString()));

// query params
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();

// Set Operation-ID header for telemetry
localVarHeaderParams.put("DD-OPERATION-ID", "listMonitorDowntimes");

final String[] localVarAccepts = {"application/json"};
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

final String[] localVarContentTypes = {};

final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

String[] localVarAuthNames = new String[] {"apiKeyAuth", "appKeyAuth"};

GenericType<List<Downtime>> localVarReturnType = new GenericType<List<Downtime>>() {};

return apiClient.invokeAPI(
"DowntimesApi.listMonitorDowntimes",
localVarPath,
"GET",
localVarQueryParams,
localVarPostBody,
localVarHeaderParams,
localVarCookieParams,
localVarFormParams,
localVarAccept,
localVarContentType,
localVarAuthNames,
localVarReturnType,
false);
}

public class APIlistMonitorDowntimesRequest {
private Long monitorId;

private APIlistMonitorDowntimesRequest(Long monitorId) {
this.monitorId = monitorId;
}

/**
* Execute listMonitorDowntimes request
*
* @return List&lt;Downtime&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 404 </td><td> Monitor Not Found error </td><td> - </td></tr>
* </table>
*/
public List<Downtime> execute() throws ApiException {
return this.executeWithHttpInfo().getData();
}

/**
* Execute listMonitorDowntimes request with HTTP info returned
*
* @return ApiResponse&lt;List&lt;Downtime&gt;&gt;
* @throws ApiException if fails to make API call
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr>
* <tr><td> 404 </td><td> Monitor Not Found error </td><td> - </td></tr>
* </table>
*/
public ApiResponse<List<Downtime>> executeWithHttpInfo() throws ApiException {
return listMonitorDowntimesWithHttpInfo(monitorId);
}
}

/**
* Get all downtimes for a monitor Get all downtimes for the specified monitor
*
* @param monitorId The id of the monitor (required)
* @return listMonitorDowntimesRequest
* @throws ApiException if fails to make API call
*/
public APIlistMonitorDowntimesRequest listMonitorDowntimes(Long monitorId) throws ApiException {
return new APIlistMonitorDowntimesRequest(monitorId);
}

private ApiResponse<Downtime> updateDowntimeWithHttpInfo(Long downtimeId, Downtime body)
throws ApiException {
Object localVarPostBody = body;
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/datadog/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15312,6 +15312,45 @@ paths:
x-codegen-request-body-name: body
x-undo:
type: idempotent
/api/v1/monitor/{monitor_id}/downtimes:
get:
description: Get all downtimes for the specified monitor
operationId: ListMonitorDowntimes
parameters:
- description: The id of the monitor
in: path
name: monitor_id
required: true
schema:
format: int64
type: integer
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Downtime'
type: array
description: OK
'400':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Bad Request
'404':
content:
application/json:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Monitor Not Found error
summary: Get all downtimes for a monitor
tags:
- Downtimes
x-codegen-request-body-name: body
x-undo:
type: safe
/api/v1/monthly_custom_reports:
get:
description: Get monthly custom reports.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ Feature: Downtimes
When the request is sent
Then the response status is 200 OK

@generated @skip
Scenario: Get all downtimes for a monitor returns "Bad Request" response
Given new "ListMonitorDowntimes" request
And request contains "monitor_id" parameter from "<PATH>"
When the request is sent
Then the response status is 400 Bad Request

@generated @skip
Scenario: Get all downtimes for a monitor returns "Monitor Not Found error" response
Given new "ListMonitorDowntimes" request
And request contains "monitor_id" parameter from "<PATH>"
When the request is sent
Then the response status is 404 Monitor Not Found error

@generated @skip
Scenario: Get all downtimes for a monitor returns "OK" response
Given new "ListMonitorDowntimes" request
And request contains "monitor_id" parameter from "<PATH>"
When the request is sent
Then the response status is 200 OK

@generated @skip
Scenario: Get all downtimes returns "OK" response
Given new "ListDowntimes" request
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/com/datadog/api/v1/client/api/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,12 @@
"type": "idempotent"
}
},
"ListMonitorDowntimes": {
"tag": "Downtimes",
"undo": {
"type": "safe"
}
},
"GetMonthlyCustomReports": {
"tag": "Usage Metering",
"undo": {
Expand Down