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-04-06 14:03:53.397002",
"spec_repo_commit": "9572acd2"
"regenerated": "2023-04-06 15:03:59.469640",
"spec_repo_commit": "b180cceb"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-04-06 14:03:53.409829",
"spec_repo_commit": "9572acd2"
"regenerated": "2023-04-06 15:03:59.482002",
"spec_repo_commit": "b180cceb"
}
}
}
7 changes: 7 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21758,6 +21758,9 @@ paths:
description: Get a list of all service definitions from the Datadog Service
Catalog.
operationId: ListServiceDefinitions
parameters:
- $ref: '#/components/parameters/PageSize'
- $ref: '#/components/parameters/PageNumber'
responses:
'200':
content:
Expand All @@ -21772,6 +21775,10 @@ paths:
summary: Get all service definitions
tags:
- Service Definition
x-pagination:
limitParam: page[size]
pageOffsetParam: page[number]
resultsPath: data
post:
description: Create or update service definition in the Datadog Service Catalog.
operationId: CreateOrUpdateServiceDefinitions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Get all service definitions returns "OK" response with pagination

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.PaginationIterable;
import com.datadog.api.client.v2.api.ServiceDefinitionApi;
import com.datadog.api.client.v2.api.ServiceDefinitionApi.ListServiceDefinitionsOptionalParameters;
import com.datadog.api.client.v2.model.ServiceDefinitionData;

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

try {
PaginationIterable<ServiceDefinitionData> iterable =
apiInstance.listServiceDefinitionsWithPagination(
new ListServiceDefinitionsOptionalParameters().pageSize(2L));

for (ServiceDefinitionData item : iterable) {
System.out.println(item);
}
} catch (RuntimeException e) {
System.err.println(
"Exception when calling ServiceDefinitionApi#listServiceDefinitionsWithPagination");
System.err.println("Reason: " + e.getMessage());
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.ApiResponse;
import com.datadog.api.client.PaginationIterable;
import com.datadog.api.client.Pair;
import com.datadog.api.client.v2.model.ServiceDefinitionCreateResponse;
import com.datadog.api.client.v2.model.ServiceDefinitionData;
import com.datadog.api.client.v2.model.ServiceDefinitionGetResponse;
import com.datadog.api.client.v2.model.ServiceDefinitionsCreateRequest;
import com.datadog.api.client.v2.model.ServiceDefinitionsListResponse;
import jakarta.ws.rs.client.Invocation;
import jakarta.ws.rs.core.GenericType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -466,6 +470,35 @@ public ApiResponse<ServiceDefinitionGetResponse> getServiceDefinitionWithHttpInf
new GenericType<ServiceDefinitionGetResponse>() {});
}

/** Manage optional parameters to listServiceDefinitions. */
public static class ListServiceDefinitionsOptionalParameters {
private Long pageSize;
private Long pageNumber;

/**
* Set pageSize.
*
* @param pageSize Size for a given page. The maximum allowed value is 5000. (optional, default
* to 10)
* @return ListServiceDefinitionsOptionalParameters
*/
public ListServiceDefinitionsOptionalParameters pageSize(Long pageSize) {
this.pageSize = pageSize;
return this;
}

/**
* Set pageNumber.
*
* @param pageNumber Specific page number to return. (optional, default to 0)
* @return ListServiceDefinitionsOptionalParameters
*/
public ListServiceDefinitionsOptionalParameters pageNumber(Long pageNumber) {
this.pageNumber = pageNumber;
return this;
}
}

/**
* Get all service definitions.
*
Expand All @@ -475,7 +508,8 @@ public ApiResponse<ServiceDefinitionGetResponse> getServiceDefinitionWithHttpInf
* @throws ApiException if fails to make API call
*/
public ServiceDefinitionsListResponse listServiceDefinitions() throws ApiException {
return listServiceDefinitionsWithHttpInfo().getData();
return listServiceDefinitionsWithHttpInfo(new ListServiceDefinitionsOptionalParameters())
.getData();
}

/**
Expand All @@ -486,16 +520,100 @@ public ServiceDefinitionsListResponse listServiceDefinitions() throws ApiExcepti
* @return CompletableFuture&lt;ServiceDefinitionsListResponse&gt;
*/
public CompletableFuture<ServiceDefinitionsListResponse> listServiceDefinitionsAsync() {
return listServiceDefinitionsWithHttpInfoAsync()
return listServiceDefinitionsWithHttpInfoAsync(new ListServiceDefinitionsOptionalParameters())
.thenApply(
response -> {
return response.getData();
});
}

/**
* Get all service definitions.
*
* <p>See {@link #listServiceDefinitionsWithHttpInfo}.
*
* @param parameters Optional parameters for the request.
* @return ServiceDefinitionsListResponse
* @throws ApiException if fails to make API call
*/
public ServiceDefinitionsListResponse listServiceDefinitions(
ListServiceDefinitionsOptionalParameters parameters) throws ApiException {
return listServiceDefinitionsWithHttpInfo(parameters).getData();
}

/**
* Get all service definitions.
*
* <p>See {@link #listServiceDefinitionsWithHttpInfoAsync}.
*
* @param parameters Optional parameters for the request.
* @return CompletableFuture&lt;ServiceDefinitionsListResponse&gt;
*/
public CompletableFuture<ServiceDefinitionsListResponse> listServiceDefinitionsAsync(
ListServiceDefinitionsOptionalParameters parameters) {
return listServiceDefinitionsWithHttpInfoAsync(parameters)
.thenApply(
response -> {
return response.getData();
});
}

/**
* Get all service definitions.
*
* <p>See {@link #listServiceDefinitionsWithHttpInfo}.
*
* @return PaginationIterable&lt;ServiceDefinitionData&gt;
*/
public PaginationIterable<ServiceDefinitionData> listServiceDefinitionsWithPagination() {
ListServiceDefinitionsOptionalParameters parameters =
new ListServiceDefinitionsOptionalParameters();
return listServiceDefinitionsWithPagination(parameters);
}

/**
* Get all service definitions.
*
* <p>See {@link #listServiceDefinitionsWithHttpInfo}.
*
* @return ServiceDefinitionsListResponse
*/
public PaginationIterable<ServiceDefinitionData> listServiceDefinitionsWithPagination(
ListServiceDefinitionsOptionalParameters parameters) {
String resultsPath = "getData";
String valueGetterPath = "";
String valueSetterPath = "pageNumber";
Boolean valueSetterParamOptional = true;
Long limit;

if (parameters.pageSize == null) {
limit = 10l;
parameters.pageSize(limit);
} else {
limit = parameters.pageSize;
}

LinkedHashMap<String, Object> args = new LinkedHashMap<String, Object>();
args.put("optionalParams", parameters);

PaginationIterable iterator =
new PaginationIterable(
this,
"listServiceDefinitions",
resultsPath,
valueGetterPath,
valueSetterPath,
valueSetterParamOptional,
limit,
args);

return iterator;
}

/**
* Get a list of all service definitions from the Datadog Service Catalog.
*
* @param parameters Optional parameters for the request.
* @return ApiResponse&lt;ServiceDefinitionsListResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
Expand All @@ -507,19 +625,25 @@ public CompletableFuture<ServiceDefinitionsListResponse> listServiceDefinitionsA
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
* </table>
*/
public ApiResponse<ServiceDefinitionsListResponse> listServiceDefinitionsWithHttpInfo()
throws ApiException {
public ApiResponse<ServiceDefinitionsListResponse> listServiceDefinitionsWithHttpInfo(
ListServiceDefinitionsOptionalParameters parameters) throws ApiException {
Object localVarPostBody = null;
Long pageSize = parameters.pageSize;
Long pageNumber = parameters.pageNumber;
// create path and map variables
String localVarPath = "/api/v2/services/definitions";

List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));

Invocation.Builder builder =
apiClient.createBuilder(
"v2.ServiceDefinitionApi.listServiceDefinitions",
localVarPath,
new ArrayList<Pair>(),
localVarQueryParams,
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
Expand All @@ -540,23 +664,30 @@ public ApiResponse<ServiceDefinitionsListResponse> listServiceDefinitionsWithHtt
*
* <p>See {@link #listServiceDefinitionsWithHttpInfo}.
*
* @param parameters Optional parameters for the request.
* @return CompletableFuture&lt;ApiResponse&lt;ServiceDefinitionsListResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<ServiceDefinitionsListResponse>>
listServiceDefinitionsWithHttpInfoAsync() {
listServiceDefinitionsWithHttpInfoAsync(ListServiceDefinitionsOptionalParameters parameters) {
Object localVarPostBody = null;
Long pageSize = parameters.pageSize;
Long pageNumber = parameters.pageNumber;
// create path and map variables
String localVarPath = "/api/v2/services/definitions";

List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize));
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));

Invocation.Builder builder;
try {
builder =
apiClient.createBuilder(
"v2.ServiceDefinitionApi.listServiceDefinitions",
localVarPath,
new ArrayList<Pair>(),
localVarQueryParams,
localVarHeaderParams,
new HashMap<String, String>(),
new String[] {"application/json"},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-04-05T09:45:34.876Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[
{
"httpRequest": {
"headers": {},
"method": "GET",
"path": "/api/v2/services/definitions",
"queryStringParameters": {
"page[size]": [
"2"
]
},
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"data\":[{\"type\":\"service-definition\",\"id\":\"000c4db9ae43787066748b39ad1c3059\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2023-04-03T20:23:00Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"unknown\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2.1\"},\"schema\":{\"schema-version\":\"v2.1\",\"dd-service\":\"service-examplecreateorupdateservicedefinitionusingschemav21returnscreatedresponse1680553380\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Architecture\",\"type\":\"doc\",\"provider\":\"Gigoogle drivetHub\",\"url\":\"https://my-runbook\"},{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"},{\"name\":\"Source Code\",\"type\":\"repo\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":{\"service-url\":\"https://my-org.pagerduty.com/service-directory/PMyService\"},\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}},{\"type\":\"service-definition\",\"id\":\"000c83c634df871f80ecbb47fa6b8bcc\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2022-11-17T02:44:15Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"\",\"origin-detail\":\"\",\"warnings\":[],\"ingested-schema-version\":\"v2\"},\"schema\":{\"schema-version\":\"v2\",\"dd-service\":\"service-test-ruby-create_or_update_service_definition_returns_created_response-1668653055\",\"dd-team\":\"my-team\",\"team\":\"my-team\",\"contacts\":[{\"name\":\"Team Email\",\"type\":\"email\",\"contact\":\"contact@datadoghq.com\"}],\"links\":[{\"name\":\"Runbook\",\"type\":\"runbook\",\"url\":\"https://my-runbook\"}],\"repos\":[{\"name\":\"Source Code\",\"provider\":\"GitHub\",\"url\":\"https://github.com/DataDog/schema\"}],\"docs\":[{\"name\":\"Architecture\",\"provider\":\"google drive\",\"url\":\"https://gdrive/mydoc\"}],\"tags\":[\"my:tag\",\"service:tag\"],\"integrations\":{\"pagerduty\":\"https://my-org.pagerduty.com/service-directory/PMyService\",\"opsgenie\":{\"service-url\":\"https://my-org.opsgenie.com/service/123e4567-e89b-12d3-a456-426614174000\",\"region\":\"US\"}},\"extensions\":{\"myorgextension\":\"extensionvalue\"}}}}]}\n",
"headers": {
"Content-Type": [
"application/json"
]
},
"statusCode": 200,
"reasonPhrase": "OK"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "2e4420ff-858d-e0f4-313c-cbc92eb665f7"
},
{
"httpRequest": {
"headers": {},
"method": "GET",
"path": "/api/v2/services/definitions",
"queryStringParameters": {
"page[size]": [
"2"
],
"page[number]": [
"2"
]
},
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"data\":[{\"type\":\"service-definition\",\"id\":\"0059bcab67b74e99cc832ca503019574\",\"attributes\":{\"meta\":{\"last-modified-time\":\"2023-03-02T12:21:20Z\",\"github-html-url\":\"\",\"ingestion-source\":\"api\",\"origin\":\"dd_terraform\",\"origin-detail\":\"\",\"warnings\":[{\"keyword-location\":\"/properties/contacts/items/$ref/allOf/1/then/properties/contact/pattern\",\"instance-location\":\"/contacts/0/contact\",\"message\":\"does not match pattern 'https://[a-zA-Z0-9_\\\\\\\\-]+.slack\\\\\\\\.com/archives/[a-zA-Z0-9_\\\\\\\\-]+'\"},{\"keyword-location\":\"/properties/contacts/items/$ref/allOf/0/then/properties/contact/format\",\"instance-location\":\"/contacts/1/contact\",\"message\":\"'BBB' is not valid 'email'\"},{\"keyword-location\":\"/properties/contacts/items/$ref/allOf/0/then/properties/contact/format\",\"instance-location\":\"/contacts/2/contact\",\"message\":\"'AAA' is not valid 'email'\"},{\"keyword-location\":\"/properties/contacts/items/$ref/allOf/0/then/properties/contact/format\",\"instance-location\":\"/contacts/3/contact\",\"message\":\"'AAA' is not valid 'email'\"},{\"keyword-location\":\"/properties/contacts/items/$ref/allOf/0/then/properties/contact/format\",\"instance-location\":\"/contacts/4/contact\",\"message\":\"'BBB' is not valid 'email'\"}],\"ingested-schema-version\":\"v2\"},\"schema\":{\"schema-version\":\"v2\",\"dd-service\":\"tf-testaccdatadogservicedefinition_order-local-1677759678\",\"team\":\"\",\"contacts\":[{\"name\":\"AA\",\"type\":\"email\",\"contact\":\"AAA\"},{\"name\":\"AA\",\"type\":\"slack\",\"contact\":\"AAA\"},{\"name\":\"BB\",\"type\":\"email\",\"contact\":\"AAA\"},{\"name\":\"AA\",\"type\":\"email\",\"contact\":\"BBB\"},{\"name\":\"BB\",\"type\":\"email\",\"contact\":\"BBB\"}],\"links\":[],\"repos\":[],\"docs\":[],\"tags\":[\"aaa\",\"bbb\"],\"integrations\":{},\"extensions\":{}}}}]}\n",
"headers": {
"Content-Type": [
"application/json"
]
},
"statusCode": 200,
"reasonPhrase": "OK"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "1c6d4b20-01a9-8d9d-e440-0911acda2436"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,12 @@ Feature: Service Definition
Given new "ListServiceDefinitions" request
When the request is sent
Then the response status is 200 OK
And the response "data[0].attributes.meta.ingested-schema-version" is equal to "v2"
And the response "data[0].attributes.meta.ingestion-source" is equal to "api"

@replay-only @team:DataDog/service-catalog @with-pagination
Scenario: Get all service definitions returns "OK" response with pagination
Given new "ListServiceDefinitions" request
And request contains "page[size]" parameter with value 2
When the request with pagination is sent
Then the response status is 200 OK
And the response has 3 items