diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 67ea97d1d67..3ac7ae5f2b7 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1388,6 +1388,20 @@ components: required: true schema: type: string + SecurityMonitoringTerraformResourceId: + description: The ID of the security monitoring resource to export. + in: path + name: resource_id + required: true + schema: + type: string + SecurityMonitoringTerraformResourceType: + description: The type of security monitoring resource to export. + in: path + name: resource_type + required: true + schema: + $ref: "#/components/schemas/SecurityMonitoringTerraformResourceType" SensitiveDataScannerGroupID: description: The ID of a group of rules. in: path @@ -64963,6 +64977,134 @@ components: $ref: "#/components/schemas/SecurityMonitoringSuppression" type: array type: object + SecurityMonitoringTerraformBulkExportAttributes: + description: Attributes for the bulk export request. + properties: + resource_ids: + description: The list of resource IDs to export. Maximum 1000 items. + example: + - "" + items: + description: The ID of the resource to export. + type: string + maxItems: 1000 + type: array + required: + - resource_ids + type: object + SecurityMonitoringTerraformBulkExportData: + description: The bulk export request data object. + properties: + attributes: + $ref: "#/components/schemas/SecurityMonitoringTerraformBulkExportAttributes" + type: + description: The JSON:API type. Always `bulk_export_resources`. + example: bulk_export_resources + type: string + required: + - type + - attributes + type: object + SecurityMonitoringTerraformBulkExportRequest: + description: Request body for bulk exporting security monitoring resources to Terraform. + properties: + data: + $ref: "#/components/schemas/SecurityMonitoringTerraformBulkExportData" + required: + - data + type: object + SecurityMonitoringTerraformConvertAttributes: + description: Attributes for the convert request. + properties: + resource_json: + additionalProperties: {} + description: The resource attributes as a JSON object, matching the structure returned by the corresponding Datadog API (for example, the attributes of a suppression rule). + example: + enabled: true + name: Custom suppression + rule_query: type:log_detection source:cloudtrail + suppression_query: env:staging status:low + type: object + required: + - resource_json + type: object + SecurityMonitoringTerraformConvertData: + description: The convert request data object. + properties: + attributes: + $ref: "#/components/schemas/SecurityMonitoringTerraformConvertAttributes" + id: + description: The ID of the resource being converted. + example: abc-123 + type: string + type: + description: The JSON:API type. Always `convert_resource`. + example: convert_resource + type: string + required: + - type + - id + - attributes + type: object + SecurityMonitoringTerraformConvertRequest: + description: Request body for converting a security monitoring resource JSON to Terraform. + properties: + data: + $ref: "#/components/schemas/SecurityMonitoringTerraformConvertData" + required: + - data + type: object + SecurityMonitoringTerraformExportAttributes: + description: Attributes of the Terraform export response. + properties: + output: + description: The Terraform configuration for the resource. + type: string + resource_id: + description: The ID of the exported resource. + example: abc-123 + type: string + type_name: + description: The Terraform resource type name. + example: datadog_security_monitoring_suppression + type: string + required: + - type_name + - resource_id + type: object + SecurityMonitoringTerraformExportData: + description: The Terraform export data object. + properties: + attributes: + $ref: "#/components/schemas/SecurityMonitoringTerraformExportAttributes" + id: + description: The resource identifier composed of the Terraform type name and the resource ID separated by `|`. + example: datadog_security_monitoring_suppression|abc-123 + type: string + type: + description: The JSON:API type. Always `format_resource`. + example: format_resource + type: string + required: + - type + - id + - attributes + type: object + SecurityMonitoringTerraformExportResponse: + description: Response containing the Terraform configuration for a security monitoring resource. + properties: + data: + $ref: "#/components/schemas/SecurityMonitoringTerraformExportData" + type: object + SecurityMonitoringTerraformResourceType: + description: The type of security monitoring resource to export to Terraform. + enum: + - suppressions + - critical_assets + type: string + x-enum-varnames: + - SUPPRESSIONS + - CRITICAL_ASSETS SecurityMonitoringThirdPartyRootQuery: description: A query to be combined with the third party case query. properties: @@ -114337,6 +114479,141 @@ paths: permissions: - security_monitoring_rules_read - security_monitoring_signals_read + /api/v2/security_monitoring/terraform/{resource_type}/bulk: + post: + description: |- + Export multiple security monitoring resources to Terraform, packaged as a zip archive. + The `resource_type` path parameter specifies the type of resources to export + and must be one of `suppressions` or `critical_assets`. + A maximum of 1000 resources can be exported in a single request. + operationId: BulkExportSecurityMonitoringTerraformResources + parameters: + - $ref: "#/components/parameters/SecurityMonitoringTerraformResourceType" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/SecurityMonitoringTerraformBulkExportRequest" + description: The resource IDs to export. + required: true + responses: + "200": + content: + application/zip: + schema: + format: binary + type: string + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + - AuthZ: + - security_monitoring_rules_read + summary: Export security monitoring resources to Terraform + tags: + - Security Monitoring + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - security_monitoring_suppressions_read + - security_monitoring_rules_read + x-unstable: "**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)." + /api/v2/security_monitoring/terraform/{resource_type}/convert: + post: + description: |- + Convert a security monitoring resource that doesn't (yet) exist from JSON to Terraform. + The `resource_type` path parameter specifies the type of resource to convert + and must be one of `suppressions` or `critical_assets`. + operationId: ConvertSecurityMonitoringTerraformResource + parameters: + - $ref: "#/components/parameters/SecurityMonitoringTerraformResourceType" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/SecurityMonitoringTerraformConvertRequest" + description: The resource JSON to convert. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/SecurityMonitoringTerraformExportResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + - AuthZ: + - security_monitoring_rules_read + summary: Convert security monitoring resource to Terraform + tags: + - Security Monitoring + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - security_monitoring_suppressions_read + - security_monitoring_rules_read + x-unstable: "**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)." + /api/v2/security_monitoring/terraform/{resource_type}/{resource_id}: + get: + description: |- + Export a security monitoring resource to a Terraform configuration. + The `resource_type` path parameter specifies the type of resource to export + and must be one of `suppressions` or `critical_assets`. + operationId: ExportSecurityMonitoringTerraformResource + parameters: + - $ref: "#/components/parameters/SecurityMonitoringTerraformResourceType" + - $ref: "#/components/parameters/SecurityMonitoringTerraformResourceId" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/SecurityMonitoringTerraformExportResponse" + description: OK + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - security_monitoring_suppressions_read + - AuthZ: + - security_monitoring_rules_read + summary: Export security monitoring resource to Terraform + tags: + - Security Monitoring + "x-permission": + operator: OR + permissions: + - security_monitoring_suppressions_read + - security_monitoring_rules_read + x-unstable: "**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/)." /api/v2/sensitive-data-scanner/config: get: description: List all the Scanning groups in your organization. diff --git a/examples/v2/security-monitoring/BulkExportSecurityMonitoringTerraformResources.java b/examples/v2/security-monitoring/BulkExportSecurityMonitoringTerraformResources.java new file mode 100644 index 00000000000..9465e3902b3 --- /dev/null +++ b/examples/v2/security-monitoring/BulkExportSecurityMonitoringTerraformResources.java @@ -0,0 +1,47 @@ +// Export security monitoring resources to Terraform returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformBulkExportAttributes; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformBulkExportData; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformBulkExportRequest; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformResourceType; +import java.io.File; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled( + "v2.bulkExportSecurityMonitoringTerraformResources", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "suppression" in the system + String SUPPRESSION_DATA_ID = System.getenv("SUPPRESSION_DATA_ID"); + + SecurityMonitoringTerraformBulkExportRequest body = + new SecurityMonitoringTerraformBulkExportRequest() + .data( + new SecurityMonitoringTerraformBulkExportData() + .attributes( + new SecurityMonitoringTerraformBulkExportAttributes() + .resourceIds(Collections.singletonList(SUPPRESSION_DATA_ID))) + .type("bulk_export_resources")); + + try { + File result = + apiInstance.bulkExportSecurityMonitoringTerraformResources( + SecurityMonitoringTerraformResourceType.SUPPRESSIONS, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling" + + " SecurityMonitoringApi#bulkExportSecurityMonitoringTerraformResources"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/security-monitoring/ConvertSecurityMonitoringTerraformResource.java b/examples/v2/security-monitoring/ConvertSecurityMonitoringTerraformResource.java new file mode 100644 index 00000000000..f3ccc3ed137 --- /dev/null +++ b/examples/v2/security-monitoring/ConvertSecurityMonitoringTerraformResource.java @@ -0,0 +1,50 @@ +// Convert security monitoring resource to Terraform returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformConvertAttributes; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformConvertData; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformConvertRequest; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformExportResponse; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformResourceType; +import java.util.Map; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled( + "v2.convertSecurityMonitoringTerraformResource", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + SecurityMonitoringTerraformConvertRequest body = + new SecurityMonitoringTerraformConvertRequest() + .data( + new SecurityMonitoringTerraformConvertData() + .type("convert_resource") + .id("abc-123") + .attributes( + new SecurityMonitoringTerraformConvertAttributes() + .resourceJson( + Map.ofEntries( + Map.entry("enabled", "True"), + Map.entry("name", "Example-Security-Monitoring"), + Map.entry("rule_query", "source:cloudtrail"), + Map.entry("suppression_query", "env:test"))))); + + try { + SecurityMonitoringTerraformExportResponse result = + apiInstance.convertSecurityMonitoringTerraformResource( + SecurityMonitoringTerraformResourceType.SUPPRESSIONS, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling" + + " SecurityMonitoringApi#convertSecurityMonitoringTerraformResource"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/security-monitoring/ExportSecurityMonitoringTerraformResource.java b/examples/v2/security-monitoring/ExportSecurityMonitoringTerraformResource.java new file mode 100644 index 00000000000..b2b126b34d2 --- /dev/null +++ b/examples/v2/security-monitoring/ExportSecurityMonitoringTerraformResource.java @@ -0,0 +1,32 @@ +// Export security monitoring resource to Terraform returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformExportResponse; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformResourceType; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.exportSecurityMonitoringTerraformResource", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + // there is a valid "suppression" in the system + String SUPPRESSION_DATA_ID = System.getenv("SUPPRESSION_DATA_ID"); + + try { + SecurityMonitoringTerraformExportResponse result = + apiInstance.exportSecurityMonitoringTerraformResource( + SecurityMonitoringTerraformResourceType.SUPPRESSIONS, SUPPRESSION_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println( + "Exception when calling SecurityMonitoringApi#exportSecurityMonitoringTerraformResource"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + 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 9c01c7b086e..26cedc5c5d1 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -801,10 +801,13 @@ public class ApiClient { put("v2.getAWSCloudAuthPersonaMapping", false); put("v2.listAWSCloudAuthPersonaMappings", false); put("v2.activateContentPack", false); + put("v2.bulkExportSecurityMonitoringTerraformResources", false); put("v2.cancelThreatHuntingJob", false); put("v2.convertJobResultToSignal", false); + put("v2.convertSecurityMonitoringTerraformResource", false); put("v2.deactivateContentPack", false); put("v2.deleteThreatHuntingJob", false); + put("v2.exportSecurityMonitoringTerraformResource", false); put("v2.getContentPacksStates", false); put("v2.getFinding", false); put("v2.getIndicatorOfCompromise", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java index eb545900a81..ff95fa787d0 100644 --- a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java @@ -95,6 +95,10 @@ import com.datadog.api.client.v2.model.SecurityMonitoringSuppressionSort; import com.datadog.api.client.v2.model.SecurityMonitoringSuppressionUpdateRequest; import com.datadog.api.client.v2.model.SecurityMonitoringSuppressionsResponse; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformBulkExportRequest; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformConvertRequest; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformExportResponse; +import com.datadog.api.client.v2.model.SecurityMonitoringTerraformResourceType; import com.datadog.api.client.v2.model.ThreatHuntingJobResponse; import com.datadog.api.client.v2.model.UpdateCustomFrameworkRequest; import com.datadog.api.client.v2.model.UpdateCustomFrameworkResponse; @@ -1024,6 +1028,200 @@ public CompletableFuture> bulkExportSecurityMonitoringRulesWit new GenericType() {}); } + /** + * Export security monitoring resources to Terraform. + * + *

See {@link #bulkExportSecurityMonitoringTerraformResourcesWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource IDs to export. (required) + * @return File + * @throws ApiException if fails to make API call + */ + public File bulkExportSecurityMonitoringTerraformResources( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformBulkExportRequest body) + throws ApiException { + return bulkExportSecurityMonitoringTerraformResourcesWithHttpInfo(resourceType, body).getData(); + } + + /** + * Export security monitoring resources to Terraform. + * + *

See {@link #bulkExportSecurityMonitoringTerraformResourcesWithHttpInfoAsync}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource IDs to export. (required) + * @return CompletableFuture<File> + */ + public CompletableFuture bulkExportSecurityMonitoringTerraformResourcesAsync( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformBulkExportRequest body) { + return bulkExportSecurityMonitoringTerraformResourcesWithHttpInfoAsync(resourceType, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Export multiple security monitoring resources to Terraform, packaged as a zip archive. The + * resource_type path parameter specifies the type of resources to export and must be + * one of suppressions or critical_assets. A maximum of 1000 resources + * can be exported in a single request. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource IDs to export. (required) + * @return ApiResponse<File> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Not Authorized -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse bulkExportSecurityMonitoringTerraformResourcesWithHttpInfo( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformBulkExportRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "bulkExportSecurityMonitoringTerraformResources"; + 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 = body; + + // verify the required parameter 'resourceType' is set + if (resourceType == null) { + throw new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " bulkExportSecurityMonitoringTerraformResources"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " bulkExportSecurityMonitoringTerraformResources"); + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/bulk" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.bulkExportSecurityMonitoringTerraformResources", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/zip", "application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Export security monitoring resources to Terraform. + * + *

See {@link #bulkExportSecurityMonitoringTerraformResourcesWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource IDs to export. (required) + * @return CompletableFuture<ApiResponse<File>> + */ + public CompletableFuture> + bulkExportSecurityMonitoringTerraformResourcesWithHttpInfoAsync( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformBulkExportRequest body) { + // Check if unstable operation is enabled + String operationId = "bulkExportSecurityMonitoringTerraformResources"; + 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 = body; + + // verify the required parameter 'resourceType' is set + if (resourceType == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " bulkExportSecurityMonitoringTerraformResources")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " bulkExportSecurityMonitoringTerraformResources")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/bulk" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.bulkExportSecurityMonitoringTerraformResources", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/zip", "application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Cancel a threat hunting job. * @@ -1628,6 +1826,204 @@ public SecurityMonitoringRuleConvertResponse convertSecurityMonitoringRuleFromJS new GenericType() {}); } + /** + * Convert security monitoring resource to Terraform. + * + *

See {@link #convertSecurityMonitoringTerraformResourceWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource JSON to convert. (required) + * @return SecurityMonitoringTerraformExportResponse + * @throws ApiException if fails to make API call + */ + public SecurityMonitoringTerraformExportResponse convertSecurityMonitoringTerraformResource( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformConvertRequest body) + throws ApiException { + return convertSecurityMonitoringTerraformResourceWithHttpInfo(resourceType, body).getData(); + } + + /** + * Convert security monitoring resource to Terraform. + * + *

See {@link #convertSecurityMonitoringTerraformResourceWithHttpInfoAsync}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource JSON to convert. (required) + * @return CompletableFuture<SecurityMonitoringTerraformExportResponse> + */ + public CompletableFuture + convertSecurityMonitoringTerraformResourceAsync( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformConvertRequest body) { + return convertSecurityMonitoringTerraformResourceWithHttpInfoAsync(resourceType, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Convert a security monitoring resource that doesn't (yet) exist from JSON to Terraform. The + * resource_type path parameter specifies the type of resource to convert and must be + * one of suppressions or critical_assets. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource JSON to convert. (required) + * @return ApiResponse<SecurityMonitoringTerraformExportResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Not Authorized -
429 Too many requests -
+ */ + public ApiResponse + convertSecurityMonitoringTerraformResourceWithHttpInfo( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformConvertRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "convertSecurityMonitoringTerraformResource"; + 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 = body; + + // verify the required parameter 'resourceType' is set + if (resourceType == null) { + throw new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " convertSecurityMonitoringTerraformResource"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " convertSecurityMonitoringTerraformResource"); + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/convert" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.convertSecurityMonitoringTerraformResource", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Convert security monitoring resource to Terraform. + * + *

See {@link #convertSecurityMonitoringTerraformResourceWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param body The resource JSON to convert. (required) + * @return CompletableFuture<ApiResponse<SecurityMonitoringTerraformExportResponse>> + */ + public CompletableFuture> + convertSecurityMonitoringTerraformResourceWithHttpInfoAsync( + SecurityMonitoringTerraformResourceType resourceType, + SecurityMonitoringTerraformConvertRequest body) { + // Check if unstable operation is enabled + String operationId = "convertSecurityMonitoringTerraformResource"; + 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 = body; + + // verify the required parameter 'resourceType' is set + if (resourceType == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " convertSecurityMonitoringTerraformResource")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'body' when calling" + + " convertSecurityMonitoringTerraformResource")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/convert" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.convertSecurityMonitoringTerraformResource", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Create cases for security findings. * @@ -4826,6 +5222,204 @@ public SecurityMonitoringSignalTriageUpdateResponse editSecurityMonitoringSignal new GenericType() {}); } + /** + * Export security monitoring resource to Terraform. + * + *

See {@link #exportSecurityMonitoringTerraformResourceWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param resourceId The ID of the security monitoring resource to export. (required) + * @return SecurityMonitoringTerraformExportResponse + * @throws ApiException if fails to make API call + */ + public SecurityMonitoringTerraformExportResponse exportSecurityMonitoringTerraformResource( + SecurityMonitoringTerraformResourceType resourceType, String resourceId) throws ApiException { + return exportSecurityMonitoringTerraformResourceWithHttpInfo(resourceType, resourceId) + .getData(); + } + + /** + * Export security monitoring resource to Terraform. + * + *

See {@link #exportSecurityMonitoringTerraformResourceWithHttpInfoAsync}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param resourceId The ID of the security monitoring resource to export. (required) + * @return CompletableFuture<SecurityMonitoringTerraformExportResponse> + */ + public CompletableFuture + exportSecurityMonitoringTerraformResourceAsync( + SecurityMonitoringTerraformResourceType resourceType, String resourceId) { + return exportSecurityMonitoringTerraformResourceWithHttpInfoAsync(resourceType, resourceId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Export a security monitoring resource to a Terraform configuration. The resource_type + * path parameter specifies the type of resource to export and must be one of + * suppressions or critical_assets. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param resourceId The ID of the security monitoring resource to export. (required) + * @return ApiResponse<SecurityMonitoringTerraformExportResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
403 Not Authorized -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse + exportSecurityMonitoringTerraformResourceWithHttpInfo( + SecurityMonitoringTerraformResourceType resourceType, String resourceId) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "exportSecurityMonitoringTerraformResource"; + 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 'resourceType' is set + if (resourceType == null) { + throw new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " exportSecurityMonitoringTerraformResource"); + } + + // verify the required parameter 'resourceId' is set + if (resourceId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'resourceId' when calling" + + " exportSecurityMonitoringTerraformResource"); + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/{resource_id}" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())) + .replaceAll( + "\\{" + "resource_id" + "\\}", apiClient.escapeString(resourceId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.exportSecurityMonitoringTerraformResource", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Export security monitoring resource to Terraform. + * + *

See {@link #exportSecurityMonitoringTerraformResourceWithHttpInfo}. + * + * @param resourceType The type of security monitoring resource to export. (required) + * @param resourceId The ID of the security monitoring resource to export. (required) + * @return CompletableFuture<ApiResponse<SecurityMonitoringTerraformExportResponse>> + */ + public CompletableFuture> + exportSecurityMonitoringTerraformResourceWithHttpInfoAsync( + SecurityMonitoringTerraformResourceType resourceType, String resourceId) { + // Check if unstable operation is enabled + String operationId = "exportSecurityMonitoringTerraformResource"; + 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 'resourceType' is set + if (resourceType == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'resourceType' when calling" + + " exportSecurityMonitoringTerraformResource")); + return result; + } + + // verify the required parameter 'resourceId' is set + if (resourceId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'resourceId' when calling" + + " exportSecurityMonitoringTerraformResource")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/security_monitoring/terraform/{resource_type}/{resource_id}" + .replaceAll( + "\\{" + "resource_type" + "\\}", apiClient.escapeString(resourceType.toString())) + .replaceAll( + "\\{" + "resource_id" + "\\}", apiClient.escapeString(resourceId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.SecurityMonitoringApi.exportSecurityMonitoringTerraformResource", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Get content pack states. * diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportAttributes.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportAttributes.java new file mode 100644 index 00000000000..b986591acc0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportAttributes.java @@ -0,0 +1,157 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes for the bulk export request. */ +@JsonPropertyOrder({SecurityMonitoringTerraformBulkExportAttributes.JSON_PROPERTY_RESOURCE_IDS}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformBulkExportAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RESOURCE_IDS = "resource_ids"; + private List resourceIds = new ArrayList<>(); + + public SecurityMonitoringTerraformBulkExportAttributes() {} + + @JsonCreator + public SecurityMonitoringTerraformBulkExportAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_IDS) List resourceIds) { + this.resourceIds = resourceIds; + } + + public SecurityMonitoringTerraformBulkExportAttributes resourceIds(List resourceIds) { + this.resourceIds = resourceIds; + return this; + } + + public SecurityMonitoringTerraformBulkExportAttributes addResourceIdsItem( + String resourceIdsItem) { + this.resourceIds.add(resourceIdsItem); + return this; + } + + /** + * The list of resource IDs to export. Maximum 1000 items. + * + * @return resourceIds + */ + @JsonProperty(JSON_PROPERTY_RESOURCE_IDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getResourceIds() { + return resourceIds; + } + + public void setResourceIds(List resourceIds) { + this.resourceIds = resourceIds; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformBulkExportAttributes + */ + @JsonAnySetter + public SecurityMonitoringTerraformBulkExportAttributes putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformBulkExportAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformBulkExportAttributes + securityMonitoringTerraformBulkExportAttributes = + (SecurityMonitoringTerraformBulkExportAttributes) o; + return Objects.equals( + this.resourceIds, securityMonitoringTerraformBulkExportAttributes.resourceIds) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformBulkExportAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourceIds, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformBulkExportAttributes {\n"); + sb.append(" resourceIds: ").append(toIndentedString(resourceIds)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportData.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportData.java new file mode 100644 index 00000000000..58eecc3b36c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportData.java @@ -0,0 +1,180 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The bulk export request data object. */ +@JsonPropertyOrder({ + SecurityMonitoringTerraformBulkExportData.JSON_PROPERTY_ATTRIBUTES, + SecurityMonitoringTerraformBulkExportData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformBulkExportData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private SecurityMonitoringTerraformBulkExportAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public SecurityMonitoringTerraformBulkExportData() {} + + @JsonCreator + public SecurityMonitoringTerraformBulkExportData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + SecurityMonitoringTerraformBulkExportAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + } + + public SecurityMonitoringTerraformBulkExportData attributes( + SecurityMonitoringTerraformBulkExportAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for the bulk export request. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SecurityMonitoringTerraformBulkExportAttributes getAttributes() { + return attributes; + } + + public void setAttributes(SecurityMonitoringTerraformBulkExportAttributes attributes) { + this.attributes = attributes; + } + + public SecurityMonitoringTerraformBulkExportData type(String type) { + this.type = type; + return this; + } + + /** + * The JSON:API type. Always bulk_export_resources. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformBulkExportData + */ + @JsonAnySetter + public SecurityMonitoringTerraformBulkExportData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformBulkExportData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformBulkExportData securityMonitoringTerraformBulkExportData = + (SecurityMonitoringTerraformBulkExportData) o; + return Objects.equals(this.attributes, securityMonitoringTerraformBulkExportData.attributes) + && Objects.equals(this.type, securityMonitoringTerraformBulkExportData.type) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformBulkExportData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformBulkExportData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportRequest.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportRequest.java new file mode 100644 index 00000000000..57284212964 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformBulkExportRequest.java @@ -0,0 +1,151 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request body for bulk exporting security monitoring resources to Terraform. */ +@JsonPropertyOrder({SecurityMonitoringTerraformBulkExportRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformBulkExportRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private SecurityMonitoringTerraformBulkExportData data; + + public SecurityMonitoringTerraformBulkExportRequest() {} + + @JsonCreator + public SecurityMonitoringTerraformBulkExportRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + SecurityMonitoringTerraformBulkExportData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public SecurityMonitoringTerraformBulkExportRequest data( + SecurityMonitoringTerraformBulkExportData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The bulk export request data object. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SecurityMonitoringTerraformBulkExportData getData() { + return data; + } + + public void setData(SecurityMonitoringTerraformBulkExportData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformBulkExportRequest + */ + @JsonAnySetter + public SecurityMonitoringTerraformBulkExportRequest putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformBulkExportRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformBulkExportRequest securityMonitoringTerraformBulkExportRequest = + (SecurityMonitoringTerraformBulkExportRequest) o; + return Objects.equals(this.data, securityMonitoringTerraformBulkExportRequest.data) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformBulkExportRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformBulkExportRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertAttributes.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertAttributes.java new file mode 100644 index 00000000000..9f9b7790968 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertAttributes.java @@ -0,0 +1,157 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes for the convert request. */ +@JsonPropertyOrder({SecurityMonitoringTerraformConvertAttributes.JSON_PROPERTY_RESOURCE_JSON}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformConvertAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RESOURCE_JSON = "resource_json"; + private Map resourceJson = new HashMap(); + + public SecurityMonitoringTerraformConvertAttributes() {} + + @JsonCreator + public SecurityMonitoringTerraformConvertAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_JSON) + Map resourceJson) { + this.resourceJson = resourceJson; + } + + public SecurityMonitoringTerraformConvertAttributes resourceJson( + Map resourceJson) { + this.resourceJson = resourceJson; + return this; + } + + public SecurityMonitoringTerraformConvertAttributes putResourceJsonItem( + String key, Object resourceJsonItem) { + this.resourceJson.put(key, resourceJsonItem); + return this; + } + + /** + * The resource attributes as a JSON object, matching the structure returned by the corresponding + * Datadog API (for example, the attributes of a suppression rule). + * + * @return resourceJson + */ + @JsonProperty(JSON_PROPERTY_RESOURCE_JSON) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Map getResourceJson() { + return resourceJson; + } + + public void setResourceJson(Map resourceJson) { + this.resourceJson = resourceJson; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformConvertAttributes + */ + @JsonAnySetter + public SecurityMonitoringTerraformConvertAttributes putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformConvertAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformConvertAttributes securityMonitoringTerraformConvertAttributes = + (SecurityMonitoringTerraformConvertAttributes) o; + return Objects.equals( + this.resourceJson, securityMonitoringTerraformConvertAttributes.resourceJson) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformConvertAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourceJson, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformConvertAttributes {\n"); + sb.append(" resourceJson: ").append(toIndentedString(resourceJson)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertData.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertData.java new file mode 100644 index 00000000000..19894ff0816 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertData.java @@ -0,0 +1,207 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The convert request data object. */ +@JsonPropertyOrder({ + SecurityMonitoringTerraformConvertData.JSON_PROPERTY_ATTRIBUTES, + SecurityMonitoringTerraformConvertData.JSON_PROPERTY_ID, + SecurityMonitoringTerraformConvertData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformConvertData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private SecurityMonitoringTerraformConvertAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public SecurityMonitoringTerraformConvertData() {} + + @JsonCreator + public SecurityMonitoringTerraformConvertData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + SecurityMonitoringTerraformConvertAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + } + + public SecurityMonitoringTerraformConvertData attributes( + SecurityMonitoringTerraformConvertAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes for the convert request. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SecurityMonitoringTerraformConvertAttributes getAttributes() { + return attributes; + } + + public void setAttributes(SecurityMonitoringTerraformConvertAttributes attributes) { + this.attributes = attributes; + } + + public SecurityMonitoringTerraformConvertData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the resource being converted. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public SecurityMonitoringTerraformConvertData type(String type) { + this.type = type; + return this; + } + + /** + * The JSON:API type. Always convert_resource. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformConvertData + */ + @JsonAnySetter + public SecurityMonitoringTerraformConvertData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformConvertData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformConvertData securityMonitoringTerraformConvertData = + (SecurityMonitoringTerraformConvertData) o; + return Objects.equals(this.attributes, securityMonitoringTerraformConvertData.attributes) + && Objects.equals(this.id, securityMonitoringTerraformConvertData.id) + && Objects.equals(this.type, securityMonitoringTerraformConvertData.type) + && Objects.equals( + this.additionalProperties, securityMonitoringTerraformConvertData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformConvertData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertRequest.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertRequest.java new file mode 100644 index 00000000000..f6726a4cb4c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformConvertRequest.java @@ -0,0 +1,150 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request body for converting a security monitoring resource JSON to Terraform. */ +@JsonPropertyOrder({SecurityMonitoringTerraformConvertRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformConvertRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private SecurityMonitoringTerraformConvertData data; + + public SecurityMonitoringTerraformConvertRequest() {} + + @JsonCreator + public SecurityMonitoringTerraformConvertRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + SecurityMonitoringTerraformConvertData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public SecurityMonitoringTerraformConvertRequest data( + SecurityMonitoringTerraformConvertData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The convert request data object. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SecurityMonitoringTerraformConvertData getData() { + return data; + } + + public void setData(SecurityMonitoringTerraformConvertData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformConvertRequest + */ + @JsonAnySetter + public SecurityMonitoringTerraformConvertRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformConvertRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformConvertRequest securityMonitoringTerraformConvertRequest = + (SecurityMonitoringTerraformConvertRequest) o; + return Objects.equals(this.data, securityMonitoringTerraformConvertRequest.data) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformConvertRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformConvertRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportAttributes.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportAttributes.java new file mode 100644 index 00000000000..a40faed914b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportAttributes.java @@ -0,0 +1,204 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Attributes of the Terraform export response. */ +@JsonPropertyOrder({ + SecurityMonitoringTerraformExportAttributes.JSON_PROPERTY_OUTPUT, + SecurityMonitoringTerraformExportAttributes.JSON_PROPERTY_RESOURCE_ID, + SecurityMonitoringTerraformExportAttributes.JSON_PROPERTY_TYPE_NAME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformExportAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OUTPUT = "output"; + private String output; + + public static final String JSON_PROPERTY_RESOURCE_ID = "resource_id"; + private String resourceId; + + public static final String JSON_PROPERTY_TYPE_NAME = "type_name"; + private String typeName; + + public SecurityMonitoringTerraformExportAttributes() {} + + @JsonCreator + public SecurityMonitoringTerraformExportAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_RESOURCE_ID) String resourceId, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE_NAME) String typeName) { + this.resourceId = resourceId; + this.typeName = typeName; + } + + public SecurityMonitoringTerraformExportAttributes output(String output) { + this.output = output; + return this; + } + + /** + * The Terraform configuration for the resource. + * + * @return output + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OUTPUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOutput() { + return output; + } + + public void setOutput(String output) { + this.output = output; + } + + public SecurityMonitoringTerraformExportAttributes resourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * The ID of the exported resource. + * + * @return resourceId + */ + @JsonProperty(JSON_PROPERTY_RESOURCE_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public SecurityMonitoringTerraformExportAttributes typeName(String typeName) { + this.typeName = typeName; + return this; + } + + /** + * The Terraform resource type name. + * + * @return typeName + */ + @JsonProperty(JSON_PROPERTY_TYPE_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTypeName() { + return typeName; + } + + public void setTypeName(String typeName) { + this.typeName = typeName; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformExportAttributes + */ + @JsonAnySetter + public SecurityMonitoringTerraformExportAttributes putAdditionalProperty( + String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformExportAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformExportAttributes securityMonitoringTerraformExportAttributes = + (SecurityMonitoringTerraformExportAttributes) o; + return Objects.equals(this.output, securityMonitoringTerraformExportAttributes.output) + && Objects.equals(this.resourceId, securityMonitoringTerraformExportAttributes.resourceId) + && Objects.equals(this.typeName, securityMonitoringTerraformExportAttributes.typeName) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformExportAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(output, resourceId, typeName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformExportAttributes {\n"); + sb.append(" output: ").append(toIndentedString(output)).append("\n"); + sb.append(" resourceId: ").append(toIndentedString(resourceId)).append("\n"); + sb.append(" typeName: ").append(toIndentedString(typeName)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportData.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportData.java new file mode 100644 index 00000000000..797e7371dcf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportData.java @@ -0,0 +1,208 @@ +/* + * 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.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; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The Terraform export data object. */ +@JsonPropertyOrder({ + SecurityMonitoringTerraformExportData.JSON_PROPERTY_ATTRIBUTES, + SecurityMonitoringTerraformExportData.JSON_PROPERTY_ID, + SecurityMonitoringTerraformExportData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformExportData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private SecurityMonitoringTerraformExportAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public SecurityMonitoringTerraformExportData() {} + + @JsonCreator + public SecurityMonitoringTerraformExportData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + SecurityMonitoringTerraformExportAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) String type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + } + + public SecurityMonitoringTerraformExportData attributes( + SecurityMonitoringTerraformExportAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of the Terraform export response. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public SecurityMonitoringTerraformExportAttributes getAttributes() { + return attributes; + } + + public void setAttributes(SecurityMonitoringTerraformExportAttributes attributes) { + this.attributes = attributes; + } + + public SecurityMonitoringTerraformExportData id(String id) { + this.id = id; + return this; + } + + /** + * The resource identifier composed of the Terraform type name and the resource ID separated by + * |. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public SecurityMonitoringTerraformExportData type(String type) { + this.type = type; + return this; + } + + /** + * The JSON:API type. Always format_resource. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformExportData + */ + @JsonAnySetter + public SecurityMonitoringTerraformExportData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformExportData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformExportData securityMonitoringTerraformExportData = + (SecurityMonitoringTerraformExportData) o; + return Objects.equals(this.attributes, securityMonitoringTerraformExportData.attributes) + && Objects.equals(this.id, securityMonitoringTerraformExportData.id) + && Objects.equals(this.type, securityMonitoringTerraformExportData.type) + && Objects.equals( + this.additionalProperties, securityMonitoringTerraformExportData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformExportData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportResponse.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportResponse.java new file mode 100644 index 00000000000..1e956c0b640 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformExportResponse.java @@ -0,0 +1,140 @@ +/* + * 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.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +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.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response containing the Terraform configuration for a security monitoring resource. */ +@JsonPropertyOrder({SecurityMonitoringTerraformExportResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class SecurityMonitoringTerraformExportResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private SecurityMonitoringTerraformExportData data; + + public SecurityMonitoringTerraformExportResponse data( + SecurityMonitoringTerraformExportData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The Terraform export data object. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SecurityMonitoringTerraformExportData getData() { + return data; + } + + public void setData(SecurityMonitoringTerraformExportData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return SecurityMonitoringTerraformExportResponse + */ + @JsonAnySetter + public SecurityMonitoringTerraformExportResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this SecurityMonitoringTerraformExportResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityMonitoringTerraformExportResponse securityMonitoringTerraformExportResponse = + (SecurityMonitoringTerraformExportResponse) o; + return Objects.equals(this.data, securityMonitoringTerraformExportResponse.data) + && Objects.equals( + this.additionalProperties, + securityMonitoringTerraformExportResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityMonitoringTerraformExportResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformResourceType.java b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformResourceType.java new file mode 100644 index 00000000000..24bbb202351 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SecurityMonitoringTerraformResourceType.java @@ -0,0 +1,65 @@ +/* + * 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 type of security monitoring resource to export to Terraform. */ +@JsonSerialize( + using = + SecurityMonitoringTerraformResourceType.SecurityMonitoringTerraformResourceTypeSerializer + .class) +public class SecurityMonitoringTerraformResourceType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("suppressions", "critical_assets")); + + public static final SecurityMonitoringTerraformResourceType SUPPRESSIONS = + new SecurityMonitoringTerraformResourceType("suppressions"); + public static final SecurityMonitoringTerraformResourceType CRITICAL_ASSETS = + new SecurityMonitoringTerraformResourceType("critical_assets"); + + SecurityMonitoringTerraformResourceType(String value) { + super(value, allowedValues); + } + + public static class SecurityMonitoringTerraformResourceTypeSerializer + extends StdSerializer { + public SecurityMonitoringTerraformResourceTypeSerializer( + Class t) { + super(t); + } + + public SecurityMonitoringTerraformResourceTypeSerializer() { + this(null); + } + + @Override + public void serialize( + SecurityMonitoringTerraformResourceType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static SecurityMonitoringTerraformResourceType fromValue(String value) { + return new SecurityMonitoringTerraformResourceType(value); + } +} diff --git a/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.freeze new file mode 100644 index 00000000000..58f519964f9 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-10T08:55:44.730Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.json new file mode 100644 index 00000000000..4e3e99eb03a --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Convert_security_monitoring_resource_to_Terraform_returns_OK_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"resource_json\":{\"enabled\":true,\"name\":\"Example-Security-Monitoring\",\"rule_query\":\"source:cloudtrail\",\"suppression_query\":\"env:test\"}},\"id\":\"abc-123\",\"type\":\"convert_resource\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security_monitoring/terraform/suppressions/convert", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"datadog_security_monitoring_suppression|abc-123\",\"type\":\"format_resource\",\"attributes\":{\"output\":\"resource \\\"datadog_security_monitoring_suppression\\\" \\\"abc-123\\\" {\\n enabled = true\\n name = \\\"Example-Security-Monitoring\\\"\\n rule_query = \\\"source:cloudtrail\\\"\\n suppression_query = \\\"env:test\\\"\\n}\\n\",\"resource_id\":\"abc-123\",\"type_name\":\"datadog_security_monitoring_suppression\"}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "1da6a19e-5e58-46c3-b012-a46c18a26ff5" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.freeze new file mode 100644 index 00000000000..fb2c8719020 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-10T08:56:17.310Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.json new file mode 100644 index 00000000000..25dafe22491 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resource_to_Terraform_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"description\":\"Test-Export_security_monitoring_resource_to_Terraform_returns_OK_response-1775811377\",\"enabled\":true,\"name\":\"suppression 934620bff161fb60\",\"rule_query\":\"source:cloudtrail\",\"suppression_query\":\"env:test\",\"tags\":[\"technique:T1110-brute-force\",\"source:cloudtrail\"]},\"type\":\"suppressions\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security_monitoring/configuration/suppressions", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"urh-ldl-f7e\",\"type\":\"suppressions\",\"attributes\":{\"creation_date\":1775811377666,\"creator\":{\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"},\"data_exclusion_query\":\"\",\"description\":\"Test-Export_security_monitoring_resource_to_Terraform_returns_OK_response-1775811377\",\"editable\":true,\"enabled\":true,\"name\":\"suppression 934620bff161fb60\",\"rule_query\":\"source:cloudtrail\",\"suppression_query\":\"env:test\",\"tags\":[\"source:cloudtrail\",\"technique:T1110-brute-force\"],\"update_date\":1775811377666,\"updater\":{\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"},\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "afb9ebe6-9d90-60b2-b572-be58bb226291" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/security_monitoring/terraform/suppressions/urh-ldl-f7e", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"datadog_security_monitoring_suppression|urh-ldl-f7e\",\"type\":\"format_resource\",\"attributes\":{\"output\":\"resource \\\"datadog_security_monitoring_suppression\\\" \\\"urh-ldl-f7e\\\" {\\n description = \\\"Test-Export_security_monitoring_resource_to_Terraform_returns_OK_response-1775811377\\\"\\n enabled = true\\n name = \\\"suppression 934620bff161fb60\\\"\\n rule_query = \\\"source:cloudtrail\\\"\\n suppression_query = \\\"env:test\\\"\\n tags = [\\\"source:cloudtrail\\\", \\\"technique:T1110-brute-force\\\"]\\n}\\n\",\"resource_id\":\"urh-ldl-f7e\",\"type_name\":\"datadog_security_monitoring_suppression\"}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "d55f9e63-6b34-1e2a-de7c-66f9cda3755d" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security_monitoring/configuration/suppressions/urh-ldl-f7e", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "713adace-c7bb-1657-8bf3-4deadef79683" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.freeze new file mode 100644 index 00000000000..2515d910118 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-10T08:56:18.628Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.json new file mode 100644 index 00000000000..1d108d7d430 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Export_security_monitoring_resources_to_Terraform_returns_OK_response.json @@ -0,0 +1,83 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"description\":\"Test-Export_security_monitoring_resources_to_Terraform_returns_OK_response-1775811378\",\"enabled\":true,\"name\":\"suppression 281e64d265076a2a\",\"rule_query\":\"source:cloudtrail\",\"suppression_query\":\"env:test\",\"tags\":[\"technique:T1110-brute-force\",\"source:cloudtrail\"]},\"type\":\"suppressions\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security_monitoring/configuration/suppressions", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"vgr-gcw-s7m\",\"type\":\"suppressions\",\"attributes\":{\"creation_date\":1775811378970,\"creator\":{\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"},\"data_exclusion_query\":\"\",\"description\":\"Test-Export_security_monitoring_resources_to_Terraform_returns_OK_response-1775811378\",\"editable\":true,\"enabled\":true,\"name\":\"suppression 281e64d265076a2a\",\"rule_query\":\"source:cloudtrail\",\"suppression_query\":\"env:test\",\"tags\":[\"source:cloudtrail\",\"technique:T1110-brute-force\"],\"update_date\":1775811378970,\"updater\":{\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"},\"version\":1}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "52ead0b0-c657-bb6e-d5af-bbb6ce033bb3" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"resource_ids\":[\"vgr-gcw-s7m\"]},\"type\":\"bulk_export_resources\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/security_monitoring/terraform/suppressions/bulk", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "UEsDBBQACAAIAAAAAAAAAAAAAAAAAAAAAAAaAAAAc3VwcHJlc3Npb25fdmdyLWdjdy1zN20udGZsjj1PMzEQhPv7FSvXr6U4L8lFka6koqBJh5Dl2JvD0p33srsORIj/jo4PEVCmfuaZYRSqHBFMChoS9V4wVs569iOVrMS59F7qNDGKZCoGzKln28dnK+1o4LUBSCiR86SZCnymA7NDUXv7MhHrVef3snglv0PmcCAePaNWLuLv72ZioiJoXduuNs79bzemAcAS9gMm+EkHyhUbgBJGhF/pwFych+XG4fomLderRbsOyzD7uA7ojxX5fFn6+LaNA9WkHPIwkxemr0IHBstpqyg6Axp6+bv/cMX1D4xifCr5WHG7c84t7J6roj0QRzSPzVvzHgAA//9QSwcIw6lzsPYAAACZAQAAUEsBAhQAFAAIAAgAAAAAAMOpc7D2AAAAmQEAABoAAAAAAAAAAAAAAAAAAAAAAHN1cHByZXNzaW9uX3Znci1nY3ctczdtLnRmUEsFBgAAAAABAAEASAAAAD4BAAAAAA==", + "headers": { + "Content-Type": [ + "application/zip" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "e642d8ed-ee74-4d63-cc32-573efc5a411c" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/security_monitoring/configuration/suppressions/vgr-gcw-s7m", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "3fe882e7-9fa6-5b79-f91b-3d5136db9572" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature index d2cfdeaea0b..1da592aca20 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature @@ -326,6 +326,26 @@ Feature: Security Monitoring Then the response status is 200 OK And the response "terraformContent" is equal to "resource \"datadog_security_monitoring_rule\" \"_{{ unique_hash }}\" {\n\tname = \"_{{ unique_hash }}\"\n\tenabled = true\n\tquery {\n\t\tquery = \"@test:true\"\n\t\tgroup_by_fields = []\n\t\thas_optional_group_by_fields = false\n\t\tdistinct_fields = []\n\t\taggregation = \"count\"\n\t\tname = \"\"\n\t\tdata_source = \"logs\"\n\t}\n\toptions {\n\t\tkeep_alive = 3600\n\t\tmax_signal_duration = 86400\n\t\tdetection_method = \"threshold\"\n\t\tevaluation_window = 900\n\t}\n\tcase {\n\t\tname = \"\"\n\t\tstatus = \"info\"\n\t\tnotifications = []\n\t\tcondition = \"a > 0\"\n\t}\n\tmessage = \"Test rule\"\n\ttags = []\n\thas_extended_title = false\n\ttype = \"log_detection\"\n}\n" + @generated @skip @team:DataDog/k9-cloud-siem + Scenario: Convert security monitoring resource to Terraform returns "Bad Request" response + Given operation "ConvertSecurityMonitoringTerraformResource" enabled + And new "ConvertSecurityMonitoringTerraformResource" request + And request contains "resource_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"resource_json": {"enabled": true, "name": "Custom suppression", "rule_query": "type:log_detection source:cloudtrail", "suppression_query": "env:staging status:low"}}, "id": "abc-123", "type": "convert_resource"}} + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/k9-cloud-siem + Scenario: Convert security monitoring resource to Terraform returns "OK" response + Given operation "ConvertSecurityMonitoringTerraformResource" enabled + And new "ConvertSecurityMonitoringTerraformResource" request + And request contains "resource_type" parameter with value "suppressions" + And body with value {"data": {"type": "convert_resource", "id": "abc-123", "attributes": {"resource_json": {"enabled": true, "name": "Example-Security-Monitoring", "rule_query": "source:cloudtrail", "suppression_query": "env:test"}}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.type_name" is equal to "datadog_security_monitoring_suppression" + And the response "data.attributes.resource_id" is equal to "abc-123" + @team:DataDog/k9-investigation Scenario: Create Jira issue for security finding returns "Created" response Given new "CreateJiraIssues" request @@ -935,6 +955,55 @@ Feature: Security Monitoring When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/k9-cloud-siem + Scenario: Export security monitoring resource to Terraform returns "Not Found" response + Given operation "ExportSecurityMonitoringTerraformResource" enabled + And new "ExportSecurityMonitoringTerraformResource" request + And request contains "resource_type" parameter from "REPLACE.ME" + And request contains "resource_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/k9-cloud-siem + Scenario: Export security monitoring resource to Terraform returns "OK" response + Given operation "ExportSecurityMonitoringTerraformResource" enabled + And there is a valid "suppression" in the system + And new "ExportSecurityMonitoringTerraformResource" request + And request contains "resource_type" parameter with value "suppressions" + And request contains "resource_id" parameter from "suppression.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.type_name" is equal to "datadog_security_monitoring_suppression" + And the response "data.attributes.resource_id" has the same value as "suppression.data.id" + + @generated @skip @team:DataDog/k9-cloud-siem + Scenario: Export security monitoring resources to Terraform returns "Bad Request" response + Given operation "BulkExportSecurityMonitoringTerraformResources" enabled + And new "BulkExportSecurityMonitoringTerraformResources" request + And request contains "resource_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"resource_ids": [""]}, "type": "bulk_export_resources"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/k9-cloud-siem + Scenario: Export security monitoring resources to Terraform returns "Not Found" response + Given operation "BulkExportSecurityMonitoringTerraformResources" enabled + And new "BulkExportSecurityMonitoringTerraformResources" request + And request contains "resource_type" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"resource_ids": [""]}, "type": "bulk_export_resources"}} + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/k9-cloud-siem + Scenario: Export security monitoring resources to Terraform returns "OK" response + Given operation "BulkExportSecurityMonitoringTerraformResources" enabled + And there is a valid "suppression" in the system + And new "BulkExportSecurityMonitoringTerraformResources" request + And request contains "resource_type" parameter with value "suppressions" + And body with value {"data": {"attributes": {"resource_ids": ["{{ suppression.data.id }}"]}, "type": "bulk_export_resources"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-vm Scenario: Get SBOM returns "Bad request: The server cannot process the request due to invalid syntax in the request." response Given new "GetSBOM" request diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index c7ef9624df9..f78cd823b2c 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -5716,6 +5716,24 @@ "type": "safe" } }, + "BulkExportSecurityMonitoringTerraformResources": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "ConvertSecurityMonitoringTerraformResource": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, + "ExportSecurityMonitoringTerraformResource": { + "tag": "Security Monitoring", + "undo": { + "type": "safe" + } + }, "ListScanningGroups": { "tag": "Sensitive Data Scanner", "undo": {