diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 01b5b8a8b32..e4979439c87 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -6550,20 +6550,15 @@ components: example: my-hostname type: string resource_kind: - description: >- - The kind of affected resource. Known values are `host`, `deployment`, `cluster`, `cluster_agent`, and `otel`. - example: host - type: string + $ref: "#/components/schemas/AgentHealthIssueResourceKind" resource_type: description: The type of the affected resource. Omitted when empty. example: host type: string severity: - description: The severity of the issue. Known values are `low`, `medium`, `high`, and `unknown`. - example: high - type: string + $ref: "#/components/schemas/AgentHealthIssueSeverity" state: - description: The state of the issue. Only issues with state `open` are returned. + description: The state of the issue, such as `open`. example: open type: string tags: @@ -6633,6 +6628,23 @@ components: - type - attributes type: object + AgentHealthIssueResourceKind: + description: >- + The kind of affected resource. The meaning of `resource_id` depends on this: hostname for `host`, DaemonSet UID for `deployment` (node Agent), cluster UUID for `cluster`, hostname of the host running the Cluster Agent for `cluster_agent`, or OpenTelemetry collector ID for `otel`. + enum: + - host + - deployment + - cluster + - cluster_agent + - otel + example: host + type: string + x-enum-varnames: + - HOST + - DEPLOYMENT + - CLUSTER + - CLUSTER_AGENT + - OTEL AgentHealthIssueResourceType: description: The Agent Health issue resource type. enum: @@ -6649,6 +6661,20 @@ components: required: - data type: object + AgentHealthIssueSeverity: + description: The severity of the issue. + enum: + - low + - medium + - high + - unknown + example: high + type: string + x-enum-varnames: + - LOW + - MEDIUM + - HIGH + - UNKNOWN AgentHealthIssueTags: description: Tags associated with the issue. Omitted when empty. example: @@ -6709,15 +6735,18 @@ components: $ref: "#/components/schemas/AgentHealthIssuesResponseMeta" required: - data + - meta type: object AgentHealthIssuesResponseMeta: description: >- - Aggregate counts for the matching Agent Health issues. Present only when `count_by=issue_type` is requested. + Pagination metadata for the matching Agent Health issues. Always present. Includes per-issue-type counts only when `count_by=issue_type` is requested. example: page: counts_by_issue_type: invalid_config: 8382 read-only_filesystem_error: 82 + limit: 100 + offset: 0 total_count: 25526 properties: page: @@ -6726,11 +6755,13 @@ components: - page type: object AgentHealthIssuesResponsePage: - description: Counts for the matching Agent Health issues. + description: Pagination details and counts for the matching Agent Health issues. example: counts_by_issue_type: invalid_config: 8382 read-only_filesystem_error: 82 + limit: 100 + offset: 0 total_count: 25526 properties: counts_by_issue_type: @@ -6742,14 +6773,25 @@ components: invalid_config: 8382 read-only_filesystem_error: 82 type: object + limit: + description: The maximum number of issues returned, echoing the requested `page[limit]`. + example: 100 + format: int64 + type: integer + offset: + description: The number of issues skipped, echoing the requested `page[offset]`. + example: 0 + format: int64 + type: integer total_count: description: The total number of open issues matching the filters. example: 25526 format: int64 type: integer required: + - limit + - offset - total_count - - counts_by_issue_type type: object AgentHealthRemediation: description: Remediation for the issue. Omitted when no remediation is available. @@ -6802,6 +6844,8 @@ components: description: Whether the script requires root privileges. example: true type: boolean + required: + - requires_root type: object AgentHealthRemediationStep: description: A step to remediate the issue. @@ -6809,12 +6853,16 @@ components: order: description: The order in which to perform the step. example: 1 - format: int64 + format: int32 + maximum: 2147483647 type: integer text: description: The instructions for the step. example: Open datadog.yaml type: string + required: + - order + - text type: object AgentHealthRemediationSteps: description: Steps to remediate the issue. @@ -165742,9 +165790,9 @@ paths: (`high`, `medium`, `low`, then other values), then `first_seen_at` descending with missing timestamps last, then issue ID ascending. - Set `count_by=issue_type` to include `meta.page`, where `total_count` is the number of - open issues matching the filters and `counts_by_issue_type` holds the per-type counts. - `meta` is omitted when `count_by` is not requested. + The response always includes `meta.page` with the applied `limit`, `offset`, and + `total_count` (the number of open issues matching the filters). Set `count_by=issue_type` + to also include `counts_by_issue_type` with per-issue-type counts. Each filter accepts up to 50 comma-separated exact values of at most 256 characters each, combined with OR within a filter and AND across filters. Blank entries are ignored; an all-blank filter @@ -165752,13 +165800,35 @@ paths: operationId: ListAgentHealthIssues parameters: - description: >- - Set to `issue_type` to include `meta.page` with `total_count` and per-issue-type counts. If you don't set this parameter, the response omits `meta`. Only `issue_type` is supported. + Set to `issue_type` to also include `counts_by_issue_type` in `meta.page` with per-issue-type counts. Pagination metadata is always included. Only `issue_type` is supported. example: issue_type in: query name: count_by required: false schema: $ref: "#/components/schemas/AgentHealthIssuesCountBy" + - description: >- + The maximum number of issues to return. Defaults to 100, with a minimum of 1 and a maximum of 1000. + example: 100 + in: query + name: page[limit] + required: false + schema: + default: 100 + format: int64 + maximum: 1000 + minimum: 1 + type: integer + - description: The number of issues to skip before returning results. Defaults to 0, with a minimum of 0. + example: 0 + in: query + name: page[offset] + required: false + schema: + default: 0 + format: int64 + minimum: 0 + type: integer - description: |- Filter by a comma-separated list of exact `severity` values, up to 50 values of at most 256 characters each. Values are combined with OR within this filter and AND across filters. @@ -165851,6 +165921,8 @@ paths: page: counts_by_issue_type: invalid_config: 8382 + limit: 100 + offset: 0 total_count: 25526 schema: $ref: "#/components/schemas/AgentHealthIssuesResponse" @@ -165883,23 +165955,23 @@ paths: summary: List Agent Health issues tags: - Agent Health + x-pagination: + limitParam: page[limit] + pageOffsetParam: page[offset] + resultsPath: data x-permission: operator: OR permissions: - hosts_read - x-unstable: |- - **Note**: This endpoint is in preview and is subject to change. - If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/agenthealth/issues/{issue_id}: get: description: |- Get an Agent Health issue and its available remediation in your organization. - Only open issues are returned. The `remediation` attribute is omitted when - the issue has no remediation. + The `remediation` attribute is omitted when the issue has no remediation. - Returns `404` if the issue does not exist, is not open, belongs to another - organization, or you do not have access to its data. This response does not - reveal whether the issue exists. Returns `403` if you lack the `hosts_read` permission. + Returns `404` if the issue does not exist, belongs to another organization, or + you do not have access to its data. This response does not reveal whether the + issue exists. Returns `403` if you lack the `hosts_read` permission. operationId: GetAgentHealthIssue parameters: - description: |- @@ -165951,6 +166023,12 @@ paths: schema: $ref: "#/components/schemas/AgentHealthIssueResponse" description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request "401": content: application/json: @@ -165983,9 +166061,6 @@ paths: operator: OR permissions: - hosts_read - x-unstable: |- - **Note**: This endpoint is in preview and is subject to change. - If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/agentless_scanning/accounts/aws: get: description: Fetches the scan options configured for AWS accounts. diff --git a/examples/v2/agent-health/GetAgentHealthIssue.java b/examples/v2/agent-health/GetAgentHealthIssue.java index 1fbe2b2266e..75d7516339f 100644 --- a/examples/v2/agent-health/GetAgentHealthIssue.java +++ b/examples/v2/agent-health/GetAgentHealthIssue.java @@ -9,7 +9,6 @@ public class Example { public static void main(String[] args) { ApiClient defaultClient = ApiClient.getDefaultApiClient(); defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); - defaultClient.setUnstableOperationEnabled("v2.getAgentHealthIssue", true); AgentHealthApi apiInstance = new AgentHealthApi(defaultClient); try { diff --git a/examples/v2/agent-health/ListAgentHealthIssues.java b/examples/v2/agent-health/ListAgentHealthIssues.java index e0296d86dcc..2cedabd0fa3 100644 --- a/examples/v2/agent-health/ListAgentHealthIssues.java +++ b/examples/v2/agent-health/ListAgentHealthIssues.java @@ -9,7 +9,6 @@ public class Example { public static void main(String[] args) { ApiClient defaultClient = ApiClient.getDefaultApiClient(); defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); - defaultClient.setUnstableOperationEnabled("v2.listAgentHealthIssues", true); AgentHealthApi apiInstance = new AgentHealthApi(defaultClient); try { diff --git a/examples/v2/agent-health/ListAgentHealthIssues_3218609860.java b/examples/v2/agent-health/ListAgentHealthIssues_3218609860.java new file mode 100644 index 00000000000..79650aaa26a --- /dev/null +++ b/examples/v2/agent-health/ListAgentHealthIssues_3218609860.java @@ -0,0 +1,28 @@ +// List Agent Health issues returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.AgentHealthApi; +import com.datadog.api.client.v2.model.AgentHealthIssueData; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + AgentHealthApi apiInstance = new AgentHealthApi(defaultClient); + + try { + PaginationIterable iterable = + apiInstance.listAgentHealthIssuesWithPagination(); + + for (AgentHealthIssueData item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println( + "Exception when calling AgentHealthApi#listAgentHealthIssuesWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 45c71bf1c98..3563c18ab25 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1145,8 +1145,6 @@ public class ApiClient { put("v2.getExecutionPolicy", false); put("v2.listExecutionPolicies", false); put("v2.updateExecutionPolicy", false); - put("v2.getAgentHealthIssue", false); - put("v2.listAgentHealthIssues", false); put("v2.evaluateAIGuardRequest", false); put("v2.createAnnotation", false); put("v2.deleteAnnotation", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/AgentHealthApi.java b/src/main/java/com/datadog/api/client/v2/api/AgentHealthApi.java index 731c72b9a3f..2d32d700ab8 100644 --- a/src/main/java/com/datadog/api/client/v2/api/AgentHealthApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/AgentHealthApi.java @@ -3,9 +3,11 @@ 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.AgentHealthAgentType; import com.datadog.api.client.v2.model.AgentHealthHostIssuesResponse; +import com.datadog.api.client.v2.model.AgentHealthIssueData; import com.datadog.api.client.v2.model.AgentHealthIssueResponse; import com.datadog.api.client.v2.model.AgentHealthIssuesCountBy; import com.datadog.api.client.v2.model.AgentHealthIssuesResponse; @@ -13,6 +15,7 @@ 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; @@ -80,13 +83,12 @@ public CompletableFuture getAgentHealthIssueAsync(Stri } /** - * Get an Agent Health issue and its available remediation in your organization. Only open issues - * are returned. The remediation attribute is omitted when the issue has no - * remediation. + * Get an Agent Health issue and its available remediation in your organization. The + * remediation attribute is omitted when the issue has no remediation. * - *

Returns 404 if the issue does not exist, is not open, belongs to another - * organization, or you do not have access to its data. This response does not reveal whether the - * issue exists. Returns 403 if you lack the hosts_read permission. + *

Returns 404 if the issue does not exist, belongs to another organization, or + * you do not have access to its data. This response does not reveal whether the issue exists. + * Returns 403 if you lack the hosts_read permission. * * @param issueId The unique identifier of the issue. It can contain : and must be * percent-encoded by clients when included in the path. (required) @@ -97,6 +99,7 @@ public CompletableFuture getAgentHealthIssueAsync(Stri * Response details * Status Code Description Response Headers * 200 OK - + * 400 Bad Request - * 401 Unauthorized - * 403 Forbidden - * 404 Not Found - @@ -105,13 +108,6 @@ public CompletableFuture getAgentHealthIssueAsync(Stri */ public ApiResponse getAgentHealthIssueWithHttpInfo(String issueId) throws ApiException { - // Check if unstable operation is enabled - String operationId = "getAgentHealthIssue"; - if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { - apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); - } else { - throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); - } Object localVarPostBody = null; // verify the required parameter 'issueId' is set @@ -157,16 +153,6 @@ public ApiResponse getAgentHealthIssueWithHttpInfo(Str */ public CompletableFuture> getAgentHealthIssueWithHttpInfoAsync(String issueId) { - // Check if unstable operation is enabled - String operationId = "getAgentHealthIssue"; - if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { - apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); - } else { - CompletableFuture> result = new CompletableFuture<>(); - result.completeExceptionally( - new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); - return result; - } Object localVarPostBody = null; // verify the required parameter 'issueId' is set @@ -430,6 +416,8 @@ public ApiResponse listAgentHealthHostIssuesWithH /** Manage optional parameters to listAgentHealthIssues. */ public static class ListAgentHealthIssuesOptionalParameters { private AgentHealthIssuesCountBy countBy; + private Long pageLimit; + private Long pageOffset; private String filterSeverity; private String filterCategory; private String filterIssueType; @@ -439,9 +427,9 @@ public static class ListAgentHealthIssuesOptionalParameters { /** * Set countBy. * - * @param countBy Set to issue_type to include meta.page with - * total_count and per-issue-type counts. If you don't set this parameter, the - * response omits meta. Only issue_type is supported. (optional) + * @param countBy Set to issue_type to also include counts_by_issue_type + * in meta.page with per-issue-type counts. Pagination metadata is + * always included. Only issue_type is supported. (optional) * @return ListAgentHealthIssuesOptionalParameters */ public ListAgentHealthIssuesOptionalParameters countBy(AgentHealthIssuesCountBy countBy) { @@ -449,6 +437,30 @@ public ListAgentHealthIssuesOptionalParameters countBy(AgentHealthIssuesCountBy return this; } + /** + * Set pageLimit. + * + * @param pageLimit The maximum number of issues to return. Defaults to 100, with a minimum of 1 + * and a maximum of 1000. (optional, default to 100) + * @return ListAgentHealthIssuesOptionalParameters + */ + public ListAgentHealthIssuesOptionalParameters pageLimit(Long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set pageOffset. + * + * @param pageOffset The number of issues to skip before returning results. Defaults to 0, with + * a minimum of 0. (optional, default to 0) + * @return ListAgentHealthIssuesOptionalParameters + */ + public ListAgentHealthIssuesOptionalParameters pageOffset(Long pageOffset) { + this.pageOffset = pageOffset; + return this; + } + /** * Set filterSeverity. * @@ -579,6 +591,61 @@ public CompletableFuture listAgentHealthIssuesAsync( }); } + /** + * List Agent Health issues. + * + *

See {@link #listAgentHealthIssuesWithHttpInfo}. + * + * @return PaginationIterable<AgentHealthIssueData> + */ + public PaginationIterable listAgentHealthIssuesWithPagination() { + ListAgentHealthIssuesOptionalParameters parameters = + new ListAgentHealthIssuesOptionalParameters(); + return listAgentHealthIssuesWithPagination(parameters); + } + + /** + * List Agent Health issues. + * + *

See {@link #listAgentHealthIssuesWithHttpInfo}. + * + * @return AgentHealthIssuesResponse + */ + public PaginationIterable listAgentHealthIssuesWithPagination( + ListAgentHealthIssuesOptionalParameters parameters) { + String resultsPath = "getData"; + String valueGetterPath = ""; + String valueSetterPath = "pageOffset"; + Boolean valueSetterParamOptional = true; + Long limit; + + if (parameters.pageLimit == null) { + limit = 100l; + parameters.pageLimit(limit); + } else { + limit = parameters.pageLimit; + } + + LinkedHashMap args = new LinkedHashMap(); + args.put("optionalParams", parameters); + + PaginationIterable iterator = + new PaginationIterable( + this, + "listAgentHealthIssues", + resultsPath, + valueGetterPath, + valueSetterPath, + valueSetterParamOptional, + true, + false, + limit, + args, + 0); + + return iterator; + } + /** * List open Agent Health issues across your organization. Returns 403 if you lack * the hosts_read permission. @@ -589,10 +656,10 @@ public CompletableFuture listAgentHealthIssuesAsync( * then first_seen_at descending with missing timestamps last, then issue ID * ascending. * - *

Set count_by=issue_type to include meta.page, where - * total_count is the number of open issues matching the filters and - * counts_by_issue_type holds the per-type counts. meta is omitted when - * count_by is not requested. + *

The response always includes meta.page with the applied limit, + * offset, and total_count (the number of open issues matching the + * filters). Set count_by=issue_type to also include counts_by_issue_type + * with per-issue-type counts. * *

Each filter accepts up to 50 comma-separated exact values of at most 256 characters each, * combined with OR within a filter and AND across filters. Blank entries are ignored; an @@ -614,15 +681,10 @@ public CompletableFuture listAgentHealthIssuesAsync( */ public ApiResponse listAgentHealthIssuesWithHttpInfo( ListAgentHealthIssuesOptionalParameters parameters) throws ApiException { - // Check if unstable operation is enabled - String operationId = "listAgentHealthIssues"; - if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { - apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); - } else { - throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); - } Object localVarPostBody = null; AgentHealthIssuesCountBy countBy = parameters.countBy; + Long pageLimit = parameters.pageLimit; + Long pageOffset = parameters.pageOffset; String filterSeverity = parameters.filterSeverity; String filterCategory = parameters.filterCategory; String filterIssueType = parameters.filterIssueType; @@ -635,6 +697,8 @@ public ApiResponse listAgentHealthIssuesWithHttpInfo( Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "count_by", countBy)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[offset]", pageOffset)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[severity]", filterSeverity)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[category]", filterCategory)); localVarQueryParams.addAll( @@ -674,18 +738,10 @@ public ApiResponse listAgentHealthIssuesWithHttpInfo( */ public CompletableFuture> listAgentHealthIssuesWithHttpInfoAsync(ListAgentHealthIssuesOptionalParameters parameters) { - // Check if unstable operation is enabled - String operationId = "listAgentHealthIssues"; - if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { - apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); - } else { - CompletableFuture> result = new CompletableFuture<>(); - result.completeExceptionally( - new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); - return result; - } Object localVarPostBody = null; AgentHealthIssuesCountBy countBy = parameters.countBy; + Long pageLimit = parameters.pageLimit; + Long pageOffset = parameters.pageOffset; String filterSeverity = parameters.filterSeverity; String filterCategory = parameters.filterCategory; String filterIssueType = parameters.filterIssueType; @@ -698,6 +754,8 @@ public ApiResponse listAgentHealthIssuesWithHttpInfo( Map localVarHeaderParams = new HashMap(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "count_by", countBy)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[offset]", pageOffset)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[severity]", filterSeverity)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[category]", filterCategory)); localVarQueryParams.addAll( diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueAttributes.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueAttributes.java index 31b8ed5e843..e28153704f5 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueAttributes.java @@ -67,13 +67,13 @@ public class AgentHealthIssueAttributes { private String resourceId; public static final String JSON_PROPERTY_RESOURCE_KIND = "resource_kind"; - private String resourceKind; + private AgentHealthIssueResourceKind resourceKind; public static final String JSON_PROPERTY_RESOURCE_TYPE = "resource_type"; private String resourceType; public static final String JSON_PROPERTY_SEVERITY = "severity"; - private String severity; + private AgentHealthIssueSeverity severity; public static final String JSON_PROPERTY_STATE = "state"; private String state; @@ -94,14 +94,18 @@ public AgentHealthIssueAttributes( @JsonProperty(required = true, value = JSON_PROPERTY_ISSUE_NAME) String issueName, @JsonProperty(required = true, value = JSON_PROPERTY_ISSUE_TYPE) String issueType, @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_ID) String resourceId, - @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_KIND) String resourceKind, - @JsonProperty(required = true, value = JSON_PROPERTY_SEVERITY) String severity, + @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_KIND) + AgentHealthIssueResourceKind resourceKind, + @JsonProperty(required = true, value = JSON_PROPERTY_SEVERITY) + AgentHealthIssueSeverity severity, @JsonProperty(required = true, value = JSON_PROPERTY_STATE) String state) { this.issueName = issueName; this.issueType = issueType; this.resourceId = resourceId; this.resourceKind = resourceKind; + this.unparsed |= !resourceKind.isValid(); this.severity = severity; + this.unparsed |= !severity.isValid(); this.state = state; } @@ -286,24 +290,30 @@ public void setResourceId(String resourceId) { this.resourceId = resourceId; } - public AgentHealthIssueAttributes resourceKind(String resourceKind) { + public AgentHealthIssueAttributes resourceKind(AgentHealthIssueResourceKind resourceKind) { this.resourceKind = resourceKind; + this.unparsed |= !resourceKind.isValid(); return this; } /** - * The kind of affected resource. Known values are host, deployment, - * cluster, cluster_agent, and otel. + * The kind of affected resource. The meaning of resource_id depends on this: + * hostname for host, DaemonSet UID for deployment (node Agent), cluster + * UUID for cluster, hostname of the host running the Cluster Agent for + * cluster_agent, or OpenTelemetry collector ID for otel. * * @return resourceKind */ @JsonProperty(JSON_PROPERTY_RESOURCE_KIND) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getResourceKind() { + public AgentHealthIssueResourceKind getResourceKind() { return resourceKind; } - public void setResourceKind(String resourceKind) { + public void setResourceKind(AgentHealthIssueResourceKind resourceKind) { + if (!resourceKind.isValid()) { + this.unparsed = true; + } this.resourceKind = resourceKind; } @@ -328,24 +338,27 @@ public void setResourceType(String resourceType) { this.resourceType = resourceType; } - public AgentHealthIssueAttributes severity(String severity) { + public AgentHealthIssueAttributes severity(AgentHealthIssueSeverity severity) { this.severity = severity; + this.unparsed |= !severity.isValid(); return this; } /** - * The severity of the issue. Known values are low, medium, high - * , and unknown. + * The severity of the issue. * * @return severity */ @JsonProperty(JSON_PROPERTY_SEVERITY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getSeverity() { + public AgentHealthIssueSeverity getSeverity() { return severity; } - public void setSeverity(String severity) { + public void setSeverity(AgentHealthIssueSeverity severity) { + if (!severity.isValid()) { + this.unparsed = true; + } this.severity = severity; } @@ -355,7 +368,7 @@ public AgentHealthIssueAttributes state(String state) { } /** - * The state of the issue. Only issues with state open are returned. + * The state of the issue, such as open. * * @return state */ diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueResourceKind.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueResourceKind.java new file mode 100644 index 00000000000..642ea5314b2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueResourceKind.java @@ -0,0 +1,68 @@ +/* + * 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.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * The kind of affected resource. The meaning of resource_id depends on this: hostname + * for host, DaemonSet UID for deployment (node Agent), cluster UUID for + * cluster, hostname of the host running the Cluster Agent for cluster_agent + * , or OpenTelemetry collector ID for otel. + */ +@JsonSerialize(using = AgentHealthIssueResourceKind.AgentHealthIssueResourceKindSerializer.class) +public class AgentHealthIssueResourceKind extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("host", "deployment", "cluster", "cluster_agent", "otel")); + + public static final AgentHealthIssueResourceKind HOST = new AgentHealthIssueResourceKind("host"); + public static final AgentHealthIssueResourceKind DEPLOYMENT = + new AgentHealthIssueResourceKind("deployment"); + public static final AgentHealthIssueResourceKind CLUSTER = + new AgentHealthIssueResourceKind("cluster"); + public static final AgentHealthIssueResourceKind CLUSTER_AGENT = + new AgentHealthIssueResourceKind("cluster_agent"); + public static final AgentHealthIssueResourceKind OTEL = new AgentHealthIssueResourceKind("otel"); + + AgentHealthIssueResourceKind(String value) { + super(value, allowedValues); + } + + public static class AgentHealthIssueResourceKindSerializer + extends StdSerializer { + public AgentHealthIssueResourceKindSerializer(Class t) { + super(t); + } + + public AgentHealthIssueResourceKindSerializer() { + this(null); + } + + @Override + public void serialize( + AgentHealthIssueResourceKind value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AgentHealthIssueResourceKind fromValue(String value) { + return new AgentHealthIssueResourceKind(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueSeverity.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueSeverity.java new file mode 100644 index 00000000000..6c5819a547e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssueSeverity.java @@ -0,0 +1,59 @@ +/* + * 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.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The severity of the issue. */ +@JsonSerialize(using = AgentHealthIssueSeverity.AgentHealthIssueSeveritySerializer.class) +public class AgentHealthIssueSeverity extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("low", "medium", "high", "unknown")); + + public static final AgentHealthIssueSeverity LOW = new AgentHealthIssueSeverity("low"); + public static final AgentHealthIssueSeverity MEDIUM = new AgentHealthIssueSeverity("medium"); + public static final AgentHealthIssueSeverity HIGH = new AgentHealthIssueSeverity("high"); + public static final AgentHealthIssueSeverity UNKNOWN = new AgentHealthIssueSeverity("unknown"); + + AgentHealthIssueSeverity(String value) { + super(value, allowedValues); + } + + public static class AgentHealthIssueSeveritySerializer + extends StdSerializer { + public AgentHealthIssueSeveritySerializer(Class t) { + super(t); + } + + public AgentHealthIssueSeveritySerializer() { + this(null); + } + + @Override + public void serialize( + AgentHealthIssueSeverity value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AgentHealthIssueSeverity fromValue(String value) { + return new AgentHealthIssueSeverity(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponse.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponse.java index ff58a74908e..69ca9f9de2c 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponse.java @@ -38,11 +38,15 @@ public AgentHealthIssuesResponse() {} @JsonCreator public AgentHealthIssuesResponse( - @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data) { + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data, + @JsonProperty(required = true, value = JSON_PROPERTY_META) + AgentHealthIssuesResponseMeta meta) { this.data = data; for (AgentHealthIssueData item : data) { this.unparsed |= item.unparsed; } + this.meta = meta; + this.unparsed |= meta.unparsed; } public AgentHealthIssuesResponse data(List data) { @@ -86,14 +90,13 @@ public AgentHealthIssuesResponse meta(AgentHealthIssuesResponseMeta meta) { } /** - * Aggregate counts for the matching Agent Health issues. Present only when - * count_by=issue_type is requested. + * Pagination metadata for the matching Agent Health issues. Always present. Includes + * per-issue-type counts only when count_by=issue_type is requested. * * @return meta */ - @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_META) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public AgentHealthIssuesResponseMeta getMeta() { return meta; } diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponseMeta.java index c6a958d7e44..8b5595e585f 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponseMeta.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponseMeta.java @@ -18,8 +18,8 @@ import java.util.Objects; /** - * Aggregate counts for the matching Agent Health issues. Present only when - * count_by=issue_type is requested. + * Pagination metadata for the matching Agent Health issues. Always present. Includes per-issue-type + * counts only when count_by=issue_type is requested. */ @JsonPropertyOrder({AgentHealthIssuesResponseMeta.JSON_PROPERTY_PAGE}) @jakarta.annotation.Generated( @@ -46,7 +46,7 @@ public AgentHealthIssuesResponseMeta page(AgentHealthIssuesResponsePage page) { } /** - * Counts for the matching Agent Health issues. + * Pagination details and counts for the matching Agent Health issues. * * @return page */ diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponsePage.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponsePage.java index 62d18122f39..95f1cf2be00 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponsePage.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthIssuesResponsePage.java @@ -17,9 +17,11 @@ import java.util.Map; import java.util.Objects; -/** Counts for the matching Agent Health issues. */ +/** Pagination details and counts for the matching Agent Health issues. */ @JsonPropertyOrder({ AgentHealthIssuesResponsePage.JSON_PROPERTY_COUNTS_BY_ISSUE_TYPE, + AgentHealthIssuesResponsePage.JSON_PROPERTY_LIMIT, + AgentHealthIssuesResponsePage.JSON_PROPERTY_OFFSET, AgentHealthIssuesResponsePage.JSON_PROPERTY_TOTAL_COUNT }) @jakarta.annotation.Generated( @@ -27,7 +29,13 @@ public class AgentHealthIssuesResponsePage { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_COUNTS_BY_ISSUE_TYPE = "counts_by_issue_type"; - private Map countsByIssueType = new HashMap(); + private Map countsByIssueType = null; + + public static final String JSON_PROPERTY_LIMIT = "limit"; + private Long limit; + + public static final String JSON_PROPERTY_OFFSET = "offset"; + private Long offset; public static final String JSON_PROPERTY_TOTAL_COUNT = "total_count"; private Long totalCount; @@ -36,10 +44,11 @@ public AgentHealthIssuesResponsePage() {} @JsonCreator public AgentHealthIssuesResponsePage( - @JsonProperty(required = true, value = JSON_PROPERTY_COUNTS_BY_ISSUE_TYPE) - Map countsByIssueType, + @JsonProperty(required = true, value = JSON_PROPERTY_LIMIT) Long limit, + @JsonProperty(required = true, value = JSON_PROPERTY_OFFSET) Long offset, @JsonProperty(required = true, value = JSON_PROPERTY_TOTAL_COUNT) Long totalCount) { - this.countsByIssueType = countsByIssueType; + this.limit = limit; + this.offset = offset; this.totalCount = totalCount; } @@ -50,6 +59,9 @@ public AgentHealthIssuesResponsePage countsByIssueType(Map countsB public AgentHealthIssuesResponsePage putCountsByIssueTypeItem( String key, Long countsByIssueTypeItem) { + if (this.countsByIssueType == null) { + this.countsByIssueType = new HashMap<>(); + } this.countsByIssueType.put(key, countsByIssueTypeItem); return this; } @@ -59,8 +71,9 @@ public AgentHealthIssuesResponsePage putCountsByIssueTypeItem( * * @return countsByIssueType */ + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_COUNTS_BY_ISSUE_TYPE) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public Map getCountsByIssueType() { return countsByIssueType; } @@ -69,6 +82,46 @@ public void setCountsByIssueType(Map countsByIssueType) { this.countsByIssueType = countsByIssueType; } + public AgentHealthIssuesResponsePage limit(Long limit) { + this.limit = limit; + return this; + } + + /** + * The maximum number of issues returned, echoing the requested page[limit]. + * + * @return limit + */ + @JsonProperty(JSON_PROPERTY_LIMIT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getLimit() { + return limit; + } + + public void setLimit(Long limit) { + this.limit = limit; + } + + public AgentHealthIssuesResponsePage offset(Long offset) { + this.offset = offset; + return this; + } + + /** + * The number of issues skipped, echoing the requested page[offset]. + * + * @return offset + */ + @JsonProperty(JSON_PROPERTY_OFFSET) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getOffset() { + return offset; + } + + public void setOffset(Long offset) { + this.offset = offset; + } + public AgentHealthIssuesResponsePage totalCount(Long totalCount) { this.totalCount = totalCount; return this; @@ -146,6 +199,8 @@ public boolean equals(Object o) { } AgentHealthIssuesResponsePage agentHealthIssuesResponsePage = (AgentHealthIssuesResponsePage) o; return Objects.equals(this.countsByIssueType, agentHealthIssuesResponsePage.countsByIssueType) + && Objects.equals(this.limit, agentHealthIssuesResponsePage.limit) + && Objects.equals(this.offset, agentHealthIssuesResponsePage.offset) && Objects.equals(this.totalCount, agentHealthIssuesResponsePage.totalCount) && Objects.equals( this.additionalProperties, agentHealthIssuesResponsePage.additionalProperties); @@ -153,7 +208,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(countsByIssueType, totalCount, additionalProperties); + return Objects.hash(countsByIssueType, limit, offset, totalCount, additionalProperties); } @Override @@ -161,6 +216,8 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AgentHealthIssuesResponsePage {\n"); sb.append(" countsByIssueType: ").append(toIndentedString(countsByIssueType)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationScript.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationScript.java index ef2a02d2eb3..6f34525f20b 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationScript.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationScript.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -43,6 +44,14 @@ public class AgentHealthRemediationScript { public static final String JSON_PROPERTY_REQUIRES_ROOT = "requires_root"; private Boolean requiresRoot; + public AgentHealthRemediationScript() {} + + @JsonCreator + public AgentHealthRemediationScript( + @JsonProperty(required = true, value = JSON_PROPERTY_REQUIRES_ROOT) Boolean requiresRoot) { + this.requiresRoot = requiresRoot; + } + public AgentHealthRemediationScript content(String content) { this.content = content; return this; @@ -137,9 +146,8 @@ public AgentHealthRemediationScript requiresRoot(Boolean requiresRoot) { * * @return requiresRoot */ - @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_REQUIRES_ROOT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public Boolean getRequiresRoot() { return requiresRoot; } diff --git a/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationStep.java b/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationStep.java index 7441c61af28..c89c68fac45 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationStep.java +++ b/src/main/java/com/datadog/api/client/v2/model/AgentHealthRemediationStep.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -26,29 +27,38 @@ public class AgentHealthRemediationStep { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_ORDER = "order"; - private Long order; + private Integer order; public static final String JSON_PROPERTY_TEXT = "text"; private String text; - public AgentHealthRemediationStep order(Long order) { + public AgentHealthRemediationStep() {} + + @JsonCreator + public AgentHealthRemediationStep( + @JsonProperty(required = true, value = JSON_PROPERTY_ORDER) Integer order, + @JsonProperty(required = true, value = JSON_PROPERTY_TEXT) String text) { + this.order = order; + this.text = text; + } + + public AgentHealthRemediationStep order(Integer order) { this.order = order; return this; } /** - * The order in which to perform the step. + * The order in which to perform the step. maximum: 2147483647 * * @return order */ - @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ORDER) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Long getOrder() { + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getOrder() { return order; } - public void setOrder(Long order) { + public void setOrder(Integer order) { this.order = order; } @@ -62,9 +72,8 @@ public AgentHealthRemediationStep text(String text) { * * @return text */ - @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TEXT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getText() { return text; } diff --git a/src/test/resources/com/datadog/api/client/v2/api/agent_health.feature b/src/test/resources/com/datadog/api/client/v2/api/agent_health.feature index 64eae1a5d3d..c20925601a6 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/agent_health.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/agent_health.feature @@ -12,10 +12,17 @@ Feature: Agent Health Given a valid "apiKeyAuth" key in the system And an instance of "AgentHealth" API + @generated @skip @team:ddoghq/fleet-remediation + Scenario: Get an Agent Health issue returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And new "GetAgentHealthIssue" request + And request contains "issue_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + @skip @team:ddoghq/fleet-remediation Scenario: Get an Agent Health issue returns "Not Found" response Given a valid "appKeyAuth" key in the system - And operation "GetAgentHealthIssue" enabled And new "GetAgentHealthIssue" request And request contains "issue_id" parameter with value "does-not-exist" When the request is sent @@ -24,7 +31,6 @@ Feature: Agent Health @generated @skip @team:ddoghq/fleet-remediation Scenario: Get an Agent Health issue returns "OK" response Given a valid "appKeyAuth" key in the system - And operation "GetAgentHealthIssue" enabled And new "GetAgentHealthIssue" request And request contains "issue_id" parameter from "REPLACE.ME" When the request is sent @@ -33,7 +39,6 @@ Feature: Agent Health @skip @team:ddoghq/fleet-remediation Scenario: List Agent Health issues returns "Bad Request" response Given a valid "appKeyAuth" key in the system - And operation "ListAgentHealthIssues" enabled And new "ListAgentHealthIssues" request And request contains "count_by" parameter with value "invalid" When the request is sent @@ -42,11 +47,17 @@ Feature: Agent Health @skip @team:ddoghq/fleet-remediation Scenario: List Agent Health issues returns "OK" response Given a valid "appKeyAuth" key in the system - And operation "ListAgentHealthIssues" enabled And new "ListAgentHealthIssues" request When the request is sent Then the response status is 200 OK + @generated @skip @team:ddoghq/fleet-remediation @with-pagination + Scenario: List Agent Health issues returns "OK" response with pagination + Given a valid "appKeyAuth" key in the system + And new "ListAgentHealthIssues" request + When the request with pagination is sent + Then the response status is 200 OK + @skip @team:ddoghq/fleet-remediation Scenario: List active Agent Health issues returns "Bad Request" response Given new "ListAgentHealthHostIssues" request