|
| 1 | +// Create a deployment returns "CREATED" response |
| 2 | + |
| 3 | +import com.datadog.api.client.ApiClient; |
| 4 | +import com.datadog.api.client.ApiException; |
| 5 | +import com.datadog.api.client.v2.api.FleetAutomationApi; |
| 6 | +import com.datadog.api.client.v2.model.FleetDeploymentConfigureAttributes; |
| 7 | +import com.datadog.api.client.v2.model.FleetDeploymentConfigureCreate; |
| 8 | +import com.datadog.api.client.v2.model.FleetDeploymentConfigureCreateRequest; |
| 9 | +import com.datadog.api.client.v2.model.FleetDeploymentFileOp; |
| 10 | +import com.datadog.api.client.v2.model.FleetDeploymentOperation; |
| 11 | +import com.datadog.api.client.v2.model.FleetDeploymentResourceType; |
| 12 | +import com.datadog.api.client.v2.model.FleetDeploymentResponse; |
| 13 | +import java.util.Collections; |
| 14 | +import java.util.Map; |
| 15 | + |
| 16 | +public class Example { |
| 17 | + public static void main(String[] args) { |
| 18 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 19 | + defaultClient.setUnstableOperationEnabled("v2.createFleetDeploymentConfigure", true); |
| 20 | + FleetAutomationApi apiInstance = new FleetAutomationApi(defaultClient); |
| 21 | + |
| 22 | + FleetDeploymentConfigureCreateRequest body = |
| 23 | + new FleetDeploymentConfigureCreateRequest() |
| 24 | + .data( |
| 25 | + new FleetDeploymentConfigureCreate() |
| 26 | + .attributes( |
| 27 | + new FleetDeploymentConfigureAttributes() |
| 28 | + .configOperations( |
| 29 | + Collections.singletonList( |
| 30 | + new FleetDeploymentOperation() |
| 31 | + .fileOp(FleetDeploymentFileOp.MERGE_PATCH) |
| 32 | + .filePath("/datadog.yaml") |
| 33 | + .patch( |
| 34 | + Map.ofEntries( |
| 35 | + Map.entry("apm_config", "{'enabled': True}"), |
| 36 | + Map.entry("log_level", "debug"), |
| 37 | + Map.entry("logs_enabled", "True"))))) |
| 38 | + .filterQuery("env:prod AND service:web")) |
| 39 | + .type(FleetDeploymentResourceType.DEPLOYMENT)); |
| 40 | + |
| 41 | + try { |
| 42 | + FleetDeploymentResponse result = apiInstance.createFleetDeploymentConfigure(body); |
| 43 | + System.out.println(result); |
| 44 | + } catch (ApiException e) { |
| 45 | + System.err.println( |
| 46 | + "Exception when calling FleetAutomationApi#createFleetDeploymentConfigure"); |
| 47 | + System.err.println("Status code: " + e.getCode()); |
| 48 | + System.err.println("Reason: " + e.getResponseBody()); |
| 49 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 50 | + e.printStackTrace(); |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments