diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 364018c47d5..f35df77478f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -20093,6 +20093,179 @@ components: - PIPELINES_FAILED_DESCENDING - PIPELINES_DURATION_LOST_ASCENDING - PIPELINES_DURATION_LOST_DESCENDING + FleetDeployment: + description: A deployment that defines automated configuration changes for a + fleet of hosts. + properties: + attributes: + $ref: '#/components/schemas/FleetDeploymentAttributes' + id: + description: Unique identifier for the deployment. + example: aeadc05e-98a8-11ec-ac2c-da7ad0900001 + type: string + type: + $ref: '#/components/schemas/FleetDeploymentResourceType' + required: + - id + - type + - attributes + type: object + FleetDeploymentAttributes: + description: Attributes of a deployment in the response. + properties: + config_operations: + description: Ordered list of configuration file operations to perform on + the target hosts. + items: + $ref: '#/components/schemas/FleetDeploymentOperation' + type: array + estimated_end_time_unix: + description: Estimated completion time of the deployment as a Unix timestamp + (seconds since epoch). + example: 1699999999 + format: int64 + type: integer + filter_query: + description: Query used to filter and select target hosts for the deployment. + Uses the Datadog query syntax. + example: env:prod AND service:web + type: string + high_level_status: + description: Current high-level status of the deployment (for example, "pending", + "running", "completed", "failed"). + example: pending + type: string + total_hosts: + description: Total number of hosts targeted by this deployment. + example: 42 + format: int64 + type: integer + type: object + FleetDeploymentConfigureAttributes: + description: Attributes for creating a new configuration deployment. + properties: + config_operations: + description: Ordered list of configuration file operations to perform on + the target hosts. + items: + $ref: '#/components/schemas/FleetDeploymentOperation' + type: array + filter_query: + description: Query used to filter and select target hosts for the deployment. + Uses the Datadog query syntax. + example: env:prod AND service:web + type: string + required: + - config_operations + type: object + FleetDeploymentConfigureCreate: + description: Data for creating a new deployment. + properties: + attributes: + $ref: '#/components/schemas/FleetDeploymentConfigureAttributes' + type: + $ref: '#/components/schemas/FleetDeploymentResourceType' + required: + - type + - attributes + type: object + FleetDeploymentConfigureCreateRequest: + description: Request payload for creating a new deployment. + properties: + data: + $ref: '#/components/schemas/FleetDeploymentConfigureCreate' + required: + - data + type: object + FleetDeploymentFileOp: + description: "Type of file operation to perform on the target configuration + file.\n- `merge-patch`: Merges the provided patch data with the existing configuration + file.\n Creates the file if it doesn't exist.\n- `delete`: Removes the specified + configuration file from the target hosts." + enum: + - merge-patch + - delete + example: merge-patch + type: string + x-enum-varnames: + - MERGE_PATCH + - DELETE + FleetDeploymentOperation: + description: A single configuration file operation to perform on the target + hosts. + properties: + file_op: + $ref: '#/components/schemas/FleetDeploymentFileOp' + file_path: + description: Absolute path to the target configuration file on the host. + example: /datadog.yaml + type: string + patch: + additionalProperties: {} + description: 'Patch data in JSON format to apply to the configuration file. + + When using `merge-patch`, this object is merged with the existing configuration, + + allowing you to add, update, or override specific fields without replacing + the entire file. + + The structure must match the target configuration file format (for example, + YAML structure for Datadog Agent config). + + Not applicable when using the `delete` operation.' + example: + apm_config: + enabled: true + log_level: debug + logs_enabled: true + type: object + required: + - file_op + - file_path + type: object + FleetDeploymentResourceType: + default: deployment + description: The type of deployment resource. + enum: + - deployment + example: deployment + type: string + x-enum-varnames: + - DEPLOYMENT + FleetDeploymentResponse: + description: Response containing a single deployment. + properties: + data: + $ref: '#/components/schemas/FleetDeployment' + type: object + FleetDeploymentsPage: + description: Pagination details for the list of deployments. + properties: + total_count: + description: Total number of deployments available across all pages. + example: 25 + format: int64 + type: integer + type: object + FleetDeploymentsResponse: + description: Response containing a paginated list of deployments. + properties: + data: + description: Array of deployments matching the query criteria. + items: + $ref: '#/components/schemas/FleetDeployment' + type: array + meta: + $ref: '#/components/schemas/FleetDeploymentsResponseMeta' + required: + - data + type: object + FleetDeploymentsResponseMeta: + description: Metadata for the list of deployments, including pagination information. + properties: + page: + $ref: '#/components/schemas/FleetDeploymentsPage' + type: object FormulaLimit: description: 'Message for specifying limits to the number of values returned by a query. @@ -53094,6 +53267,249 @@ info: version: '1.0' openapi: 3.0.0 paths: + /api/unstable/fleet/deployments: + get: + description: 'Retrieve a list of all deployments for fleet automation. + + Use the `page_size` and `page_offset` parameters to paginate results.' + operationId: ListFleetDeployments + parameters: + - description: Number of deployments to return per page. Maximum value is 100. + in: query + name: page_size + required: false + schema: + default: 10 + format: int64 + maximum: 100 + type: integer + - description: Index of the first deployment to return. Use this with `page_size` + to paginate through results. + in: query + name: page_offset + required: false + schema: + default: 0 + format: int64 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FleetDeploymentsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List all deployments + tags: + - Fleet Automation + x-permission: + operator: AND + permissions: + - hosts_read + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/unstable/fleet/deployments/configure: + post: + description: 'Create a new deployment to apply configuration changes + + to a fleet of hosts matching the specified filter query.' + operationId: CreateFleetDeploymentConfigure + requestBody: + content: + application/json: + examples: + add_log_integration: + summary: Add log integrations for multiple services + value: + data: + attributes: + config_operations: + - file_op: merge-patch + file_path: /conf.d/postgres.d/logs.yaml + patch: + logs: + - path: /var/log/postgres.log + service: postgres1 + source: postgres + type: file + - file_op: merge-patch + file_path: /conf.d/kafka.d/logs.yaml + patch: + logs: + - path: /var/log/kafka.log + service: kafka1 + source: kafka + type: file + filter_query: env:prod + type: deployment + delete_config_file: + summary: Delete a configuration file + value: + data: + attributes: + config_operations: + - file_op: delete + file_path: /conf.d/old-integration.yaml + filter_query: env:dev + type: deployment + enable_apm_and_logs: + summary: Enable APM and Logs products + value: + data: + attributes: + config_operations: + - file_op: merge-patch + file_path: /datadog.yaml + patch: + apm_config: + enabled: true + log_level: debug + logs_enabled: true + filter_query: env:prod AND service:web + type: deployment + simple_log_level: + summary: Set log level to info + value: + data: + attributes: + config_operations: + - file_op: merge-patch + file_path: /datadog.yaml + patch: + log_level: info + filter_query: env:staging + type: deployment + schema: + $ref: '#/components/schemas/FleetDeploymentConfigureCreateRequest' + description: Request payload containing the deployment details. + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/FleetDeploymentResponse' + description: CREATED + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create a deployment + tags: + - Fleet Automation + x-permission: + operator: AND + permissions: + - agent_upgrade_write + - fleet_policies_write + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/unstable/fleet/deployments/{deployment_id}: + get: + description: Retrieve the details of a specific deployment using its unique + identifier. + operationId: GetFleetDeployment + parameters: + - description: The unique identifier of the deployment to retrieve. + example: abc-def-ghi + in: path + name: deployment_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FleetDeploymentResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get a deployment by ID + tags: + - Fleet Automation + x-permission: + operator: AND + permissions: + - hosts_read + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/unstable/fleet/deployments/{deployment_id}/cancel: + post: + description: 'Cancel this deployment and stop all associated operations. + + If a workflow is currently running for this deployment, it is canceled immediately. + + Changes already applied to hosts are not rolled back.' + operationId: CancelFleetDeployment + parameters: + - description: The unique identifier of the deployment to cancel. + example: abc-def-ghi + in: path + name: deployment_id + required: true + schema: + type: string + responses: + '204': + description: Deployment successfully canceled. + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Cancel a deployment + tags: + - Fleet Automation + x-permission: + operator: AND + permissions: + - agent_upgrade_write + - fleet_policies_write + x-unstable: 'This endpoint is in Preview and may introduce breaking changes. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/actions-datastores: get: description: Lists all datastores for the organization. @@ -79828,6 +80244,12 @@ tags: through the Datadog API. See the [Fastly integration page](https://docs.datadoghq.com/integrations/fastly/) for more information. name: Fastly Integration +- description: 'Manage automated deployments across your fleet of hosts. + + Use these endpoints to create, retrieve, and cancel deployments + + that apply configuration changes to multiple hosts at once.' + name: Fleet Automation - description: 'Configure your Datadog-Google Cloud Platform (GCP) integration directly through the Datadog API. Read more about the [Datadog-Google Cloud Platform integration](https://docs.datadoghq.com/integrations/google_cloud_platform).' diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index fd8afb26c3c..15a1d708405 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -600,6 +600,10 @@ func NewConfiguration() *Configuration { }, }, unstableOperations: map[string]bool{ + "v2.CancelFleetDeployment": false, + "v2.CreateFleetDeploymentConfigure": false, + "v2.GetFleetDeployment": false, + "v2.ListFleetDeployments": false, "v2.CreateOpenAPI": false, "v2.DeleteOpenAPI": false, "v2.GetOpenAPI": false, diff --git a/api/datadogV2/api_fleet_automation.go b/api/datadogV2/api_fleet_automation.go new file mode 100644 index 00000000000..dfc373b011b --- /dev/null +++ b/api/datadogV2/api_fleet_automation.go @@ -0,0 +1,406 @@ +// 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 datadogV2 + +import ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetAutomationApi service type +type FleetAutomationApi datadog.Service + +// CancelFleetDeployment Cancel a deployment. +// Cancel this deployment and stop all associated operations. +// If a workflow is currently running for this deployment, it is canceled immediately. +// Changes already applied to hosts are not rolled back. +func (a *FleetAutomationApi) CancelFleetDeployment(ctx _context.Context, deploymentId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.CancelFleetDeployment" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FleetAutomationApi.CancelFleetDeployment") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/unstable/fleet/deployments/{deployment_id}/cancel" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{deployment_id}", _neturl.PathEscape(datadog.ParameterToString(deploymentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// CreateFleetDeploymentConfigure Create a deployment. +// Create a new deployment to apply configuration changes +// to a fleet of hosts matching the specified filter query. +func (a *FleetAutomationApi) CreateFleetDeploymentConfigure(ctx _context.Context, body FleetDeploymentConfigureCreateRequest) (FleetDeploymentResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue FleetDeploymentResponse + ) + + operationId := "v2.CreateFleetDeploymentConfigure" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FleetAutomationApi.CreateFleetDeploymentConfigure") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/unstable/fleet/deployments/configure" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetFleetDeployment Get a deployment by ID. +// Retrieve the details of a specific deployment using its unique identifier. +func (a *FleetAutomationApi) GetFleetDeployment(ctx _context.Context, deploymentId string) (FleetDeploymentResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FleetDeploymentResponse + ) + + operationId := "v2.GetFleetDeployment" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FleetAutomationApi.GetFleetDeployment") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/unstable/fleet/deployments/{deployment_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{deployment_id}", _neturl.PathEscape(datadog.ParameterToString(deploymentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListFleetDeploymentsOptionalParameters holds optional parameters for ListFleetDeployments. +type ListFleetDeploymentsOptionalParameters struct { + PageSize *int64 + PageOffset *int64 +} + +// NewListFleetDeploymentsOptionalParameters creates an empty struct for parameters. +func NewListFleetDeploymentsOptionalParameters() *ListFleetDeploymentsOptionalParameters { + this := ListFleetDeploymentsOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListFleetDeploymentsOptionalParameters) WithPageSize(pageSize int64) *ListFleetDeploymentsOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageOffset sets the corresponding parameter name and returns the struct. +func (r *ListFleetDeploymentsOptionalParameters) WithPageOffset(pageOffset int64) *ListFleetDeploymentsOptionalParameters { + r.PageOffset = &pageOffset + return r +} + +// ListFleetDeployments List all deployments. +// Retrieve a list of all deployments for fleet automation. +// Use the `page_size` and `page_offset` parameters to paginate results. +func (a *FleetAutomationApi) ListFleetDeployments(ctx _context.Context, o ...ListFleetDeploymentsOptionalParameters) (FleetDeploymentsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FleetDeploymentsResponse + optionalParams ListFleetDeploymentsOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListFleetDeploymentsOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListFleetDeployments" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FleetAutomationApi.ListFleetDeployments") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/unstable/fleet/deployments" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page_size", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageOffset != nil { + localVarQueryParams.Add("page_offset", datadog.ParameterToString(*optionalParams.PageOffset, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewFleetAutomationApi Returns NewFleetAutomationApi. +func NewFleetAutomationApi(client *datadog.APIClient) *FleetAutomationApi { + return &FleetAutomationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 2cdb4f3a2be..9f6d924f5c1 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -245,6 +245,10 @@ // - [FastlyIntegrationApi.ListFastlyServices] // - [FastlyIntegrationApi.UpdateFastlyAccount] // - [FastlyIntegrationApi.UpdateFastlyService] +// - [FleetAutomationApi.CancelFleetDeployment] +// - [FleetAutomationApi.CreateFleetDeploymentConfigure] +// - [FleetAutomationApi.GetFleetDeployment] +// - [FleetAutomationApi.ListFleetDeployments] // - [GCPIntegrationApi.CreateGCPSTSAccount] // - [GCPIntegrationApi.DeleteGCPSTSAccount] // - [GCPIntegrationApi.GetGCPSTSDelegate] diff --git a/api/datadogV2/model_fleet_deployment.go b/api/datadogV2/model_fleet_deployment.go new file mode 100644 index 00000000000..5847ecf997a --- /dev/null +++ b/api/datadogV2/model_fleet_deployment.go @@ -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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeployment A deployment that defines automated configuration changes for a fleet of hosts. +type FleetDeployment struct { + // Attributes of a deployment in the response. + Attributes FleetDeploymentAttributes `json:"attributes"` + // Unique identifier for the deployment. + Id string `json:"id"` + // The type of deployment resource. + Type FleetDeploymentResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeployment instantiates a new FleetDeployment object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeployment(attributes FleetDeploymentAttributes, id string, typeVar FleetDeploymentResourceType) *FleetDeployment { + this := FleetDeployment{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewFleetDeploymentWithDefaults instantiates a new FleetDeployment object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentWithDefaults() *FleetDeployment { + this := FleetDeployment{} + var typeVar FleetDeploymentResourceType = FLEETDEPLOYMENTRESOURCETYPE_DEPLOYMENT + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *FleetDeployment) GetAttributes() FleetDeploymentAttributes { + if o == nil { + var ret FleetDeploymentAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *FleetDeployment) GetAttributesOk() (*FleetDeploymentAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *FleetDeployment) SetAttributes(v FleetDeploymentAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *FleetDeployment) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *FleetDeployment) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *FleetDeployment) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *FleetDeployment) GetType() FleetDeploymentResourceType { + if o == nil { + var ret FleetDeploymentResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FleetDeployment) GetTypeOk() (*FleetDeploymentResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FleetDeployment) SetType(v FleetDeploymentResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeployment) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeployment) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *FleetDeploymentAttributes `json:"attributes"` + Id *string `json:"id"` + Type *FleetDeploymentResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_attributes.go b/api/datadogV2/model_fleet_deployment_attributes.go new file mode 100644 index 00000000000..7a18d7f62dd --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_attributes.go @@ -0,0 +1,242 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentAttributes Attributes of a deployment in the response. +type FleetDeploymentAttributes struct { + // Ordered list of configuration file operations to perform on the target hosts. + ConfigOperations []FleetDeploymentOperation `json:"config_operations,omitempty"` + // Estimated completion time of the deployment as a Unix timestamp (seconds since epoch). + EstimatedEndTimeUnix *int64 `json:"estimated_end_time_unix,omitempty"` + // Query used to filter and select target hosts for the deployment. Uses the Datadog query syntax. + FilterQuery *string `json:"filter_query,omitempty"` + // Current high-level status of the deployment (for example, "pending", "running", "completed", "failed"). + HighLevelStatus *string `json:"high_level_status,omitempty"` + // Total number of hosts targeted by this deployment. + TotalHosts *int64 `json:"total_hosts,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentAttributes instantiates a new FleetDeploymentAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentAttributes() *FleetDeploymentAttributes { + this := FleetDeploymentAttributes{} + return &this +} + +// NewFleetDeploymentAttributesWithDefaults instantiates a new FleetDeploymentAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentAttributesWithDefaults() *FleetDeploymentAttributes { + this := FleetDeploymentAttributes{} + return &this +} + +// GetConfigOperations returns the ConfigOperations field value if set, zero value otherwise. +func (o *FleetDeploymentAttributes) GetConfigOperations() []FleetDeploymentOperation { + if o == nil || o.ConfigOperations == nil { + var ret []FleetDeploymentOperation + return ret + } + return o.ConfigOperations +} + +// GetConfigOperationsOk returns a tuple with the ConfigOperations field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentAttributes) GetConfigOperationsOk() (*[]FleetDeploymentOperation, bool) { + if o == nil || o.ConfigOperations == nil { + return nil, false + } + return &o.ConfigOperations, true +} + +// HasConfigOperations returns a boolean if a field has been set. +func (o *FleetDeploymentAttributes) HasConfigOperations() bool { + return o != nil && o.ConfigOperations != nil +} + +// SetConfigOperations gets a reference to the given []FleetDeploymentOperation and assigns it to the ConfigOperations field. +func (o *FleetDeploymentAttributes) SetConfigOperations(v []FleetDeploymentOperation) { + o.ConfigOperations = v +} + +// GetEstimatedEndTimeUnix returns the EstimatedEndTimeUnix field value if set, zero value otherwise. +func (o *FleetDeploymentAttributes) GetEstimatedEndTimeUnix() int64 { + if o == nil || o.EstimatedEndTimeUnix == nil { + var ret int64 + return ret + } + return *o.EstimatedEndTimeUnix +} + +// GetEstimatedEndTimeUnixOk returns a tuple with the EstimatedEndTimeUnix field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentAttributes) GetEstimatedEndTimeUnixOk() (*int64, bool) { + if o == nil || o.EstimatedEndTimeUnix == nil { + return nil, false + } + return o.EstimatedEndTimeUnix, true +} + +// HasEstimatedEndTimeUnix returns a boolean if a field has been set. +func (o *FleetDeploymentAttributes) HasEstimatedEndTimeUnix() bool { + return o != nil && o.EstimatedEndTimeUnix != nil +} + +// SetEstimatedEndTimeUnix gets a reference to the given int64 and assigns it to the EstimatedEndTimeUnix field. +func (o *FleetDeploymentAttributes) SetEstimatedEndTimeUnix(v int64) { + o.EstimatedEndTimeUnix = &v +} + +// GetFilterQuery returns the FilterQuery field value if set, zero value otherwise. +func (o *FleetDeploymentAttributes) GetFilterQuery() string { + if o == nil || o.FilterQuery == nil { + var ret string + return ret + } + return *o.FilterQuery +} + +// GetFilterQueryOk returns a tuple with the FilterQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentAttributes) GetFilterQueryOk() (*string, bool) { + if o == nil || o.FilterQuery == nil { + return nil, false + } + return o.FilterQuery, true +} + +// HasFilterQuery returns a boolean if a field has been set. +func (o *FleetDeploymentAttributes) HasFilterQuery() bool { + return o != nil && o.FilterQuery != nil +} + +// SetFilterQuery gets a reference to the given string and assigns it to the FilterQuery field. +func (o *FleetDeploymentAttributes) SetFilterQuery(v string) { + o.FilterQuery = &v +} + +// GetHighLevelStatus returns the HighLevelStatus field value if set, zero value otherwise. +func (o *FleetDeploymentAttributes) GetHighLevelStatus() string { + if o == nil || o.HighLevelStatus == nil { + var ret string + return ret + } + return *o.HighLevelStatus +} + +// GetHighLevelStatusOk returns a tuple with the HighLevelStatus field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentAttributes) GetHighLevelStatusOk() (*string, bool) { + if o == nil || o.HighLevelStatus == nil { + return nil, false + } + return o.HighLevelStatus, true +} + +// HasHighLevelStatus returns a boolean if a field has been set. +func (o *FleetDeploymentAttributes) HasHighLevelStatus() bool { + return o != nil && o.HighLevelStatus != nil +} + +// SetHighLevelStatus gets a reference to the given string and assigns it to the HighLevelStatus field. +func (o *FleetDeploymentAttributes) SetHighLevelStatus(v string) { + o.HighLevelStatus = &v +} + +// GetTotalHosts returns the TotalHosts field value if set, zero value otherwise. +func (o *FleetDeploymentAttributes) GetTotalHosts() int64 { + if o == nil || o.TotalHosts == nil { + var ret int64 + return ret + } + return *o.TotalHosts +} + +// GetTotalHostsOk returns a tuple with the TotalHosts field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentAttributes) GetTotalHostsOk() (*int64, bool) { + if o == nil || o.TotalHosts == nil { + return nil, false + } + return o.TotalHosts, true +} + +// HasTotalHosts returns a boolean if a field has been set. +func (o *FleetDeploymentAttributes) HasTotalHosts() bool { + return o != nil && o.TotalHosts != nil +} + +// SetTotalHosts gets a reference to the given int64 and assigns it to the TotalHosts field. +func (o *FleetDeploymentAttributes) SetTotalHosts(v int64) { + o.TotalHosts = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ConfigOperations != nil { + toSerialize["config_operations"] = o.ConfigOperations + } + if o.EstimatedEndTimeUnix != nil { + toSerialize["estimated_end_time_unix"] = o.EstimatedEndTimeUnix + } + if o.FilterQuery != nil { + toSerialize["filter_query"] = o.FilterQuery + } + if o.HighLevelStatus != nil { + toSerialize["high_level_status"] = o.HighLevelStatus + } + if o.TotalHosts != nil { + toSerialize["total_hosts"] = o.TotalHosts + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ConfigOperations []FleetDeploymentOperation `json:"config_operations,omitempty"` + EstimatedEndTimeUnix *int64 `json:"estimated_end_time_unix,omitempty"` + FilterQuery *string `json:"filter_query,omitempty"` + HighLevelStatus *string `json:"high_level_status,omitempty"` + TotalHosts *int64 `json:"total_hosts,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"config_operations", "estimated_end_time_unix", "filter_query", "high_level_status", "total_hosts"}) + } else { + return err + } + o.ConfigOperations = all.ConfigOperations + o.EstimatedEndTimeUnix = all.EstimatedEndTimeUnix + o.FilterQuery = all.FilterQuery + o.HighLevelStatus = all.HighLevelStatus + o.TotalHosts = all.TotalHosts + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_configure_attributes.go b/api/datadogV2/model_fleet_deployment_configure_attributes.go new file mode 100644 index 00000000000..60a88bec763 --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_configure_attributes.go @@ -0,0 +1,136 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentConfigureAttributes Attributes for creating a new configuration deployment. +type FleetDeploymentConfigureAttributes struct { + // Ordered list of configuration file operations to perform on the target hosts. + ConfigOperations []FleetDeploymentOperation `json:"config_operations"` + // Query used to filter and select target hosts for the deployment. Uses the Datadog query syntax. + FilterQuery *string `json:"filter_query,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentConfigureAttributes instantiates a new FleetDeploymentConfigureAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentConfigureAttributes(configOperations []FleetDeploymentOperation) *FleetDeploymentConfigureAttributes { + this := FleetDeploymentConfigureAttributes{} + this.ConfigOperations = configOperations + return &this +} + +// NewFleetDeploymentConfigureAttributesWithDefaults instantiates a new FleetDeploymentConfigureAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentConfigureAttributesWithDefaults() *FleetDeploymentConfigureAttributes { + this := FleetDeploymentConfigureAttributes{} + return &this +} + +// GetConfigOperations returns the ConfigOperations field value. +func (o *FleetDeploymentConfigureAttributes) GetConfigOperations() []FleetDeploymentOperation { + if o == nil { + var ret []FleetDeploymentOperation + return ret + } + return o.ConfigOperations +} + +// GetConfigOperationsOk returns a tuple with the ConfigOperations field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentConfigureAttributes) GetConfigOperationsOk() (*[]FleetDeploymentOperation, bool) { + if o == nil { + return nil, false + } + return &o.ConfigOperations, true +} + +// SetConfigOperations sets field value. +func (o *FleetDeploymentConfigureAttributes) SetConfigOperations(v []FleetDeploymentOperation) { + o.ConfigOperations = v +} + +// GetFilterQuery returns the FilterQuery field value if set, zero value otherwise. +func (o *FleetDeploymentConfigureAttributes) GetFilterQuery() string { + if o == nil || o.FilterQuery == nil { + var ret string + return ret + } + return *o.FilterQuery +} + +// GetFilterQueryOk returns a tuple with the FilterQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentConfigureAttributes) GetFilterQueryOk() (*string, bool) { + if o == nil || o.FilterQuery == nil { + return nil, false + } + return o.FilterQuery, true +} + +// HasFilterQuery returns a boolean if a field has been set. +func (o *FleetDeploymentConfigureAttributes) HasFilterQuery() bool { + return o != nil && o.FilterQuery != nil +} + +// SetFilterQuery gets a reference to the given string and assigns it to the FilterQuery field. +func (o *FleetDeploymentConfigureAttributes) SetFilterQuery(v string) { + o.FilterQuery = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentConfigureAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["config_operations"] = o.ConfigOperations + if o.FilterQuery != nil { + toSerialize["filter_query"] = o.FilterQuery + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentConfigureAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ConfigOperations *[]FleetDeploymentOperation `json:"config_operations"` + FilterQuery *string `json:"filter_query,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ConfigOperations == nil { + return fmt.Errorf("required field config_operations missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"config_operations", "filter_query"}) + } else { + return err + } + o.ConfigOperations = *all.ConfigOperations + o.FilterQuery = all.FilterQuery + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_configure_create.go b/api/datadogV2/model_fleet_deployment_configure_create.go new file mode 100644 index 00000000000..db9d86b1d6e --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_configure_create.go @@ -0,0 +1,148 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentConfigureCreate Data for creating a new deployment. +type FleetDeploymentConfigureCreate struct { + // Attributes for creating a new configuration deployment. + Attributes FleetDeploymentConfigureAttributes `json:"attributes"` + // The type of deployment resource. + Type FleetDeploymentResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentConfigureCreate instantiates a new FleetDeploymentConfigureCreate object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentConfigureCreate(attributes FleetDeploymentConfigureAttributes, typeVar FleetDeploymentResourceType) *FleetDeploymentConfigureCreate { + this := FleetDeploymentConfigureCreate{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewFleetDeploymentConfigureCreateWithDefaults instantiates a new FleetDeploymentConfigureCreate object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentConfigureCreateWithDefaults() *FleetDeploymentConfigureCreate { + this := FleetDeploymentConfigureCreate{} + var typeVar FleetDeploymentResourceType = FLEETDEPLOYMENTRESOURCETYPE_DEPLOYMENT + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *FleetDeploymentConfigureCreate) GetAttributes() FleetDeploymentConfigureAttributes { + if o == nil { + var ret FleetDeploymentConfigureAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentConfigureCreate) GetAttributesOk() (*FleetDeploymentConfigureAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *FleetDeploymentConfigureCreate) SetAttributes(v FleetDeploymentConfigureAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *FleetDeploymentConfigureCreate) GetType() FleetDeploymentResourceType { + if o == nil { + var ret FleetDeploymentResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentConfigureCreate) GetTypeOk() (*FleetDeploymentResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FleetDeploymentConfigureCreate) SetType(v FleetDeploymentResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentConfigureCreate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentConfigureCreate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *FleetDeploymentConfigureAttributes `json:"attributes"` + Type *FleetDeploymentResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_configure_create_request.go b/api/datadogV2/model_fleet_deployment_configure_create_request.go new file mode 100644 index 00000000000..ce7171a8f35 --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_configure_create_request.go @@ -0,0 +1,110 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentConfigureCreateRequest Request payload for creating a new deployment. +type FleetDeploymentConfigureCreateRequest struct { + // Data for creating a new deployment. + Data FleetDeploymentConfigureCreate `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentConfigureCreateRequest instantiates a new FleetDeploymentConfigureCreateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentConfigureCreateRequest(data FleetDeploymentConfigureCreate) *FleetDeploymentConfigureCreateRequest { + this := FleetDeploymentConfigureCreateRequest{} + this.Data = data + return &this +} + +// NewFleetDeploymentConfigureCreateRequestWithDefaults instantiates a new FleetDeploymentConfigureCreateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentConfigureCreateRequestWithDefaults() *FleetDeploymentConfigureCreateRequest { + this := FleetDeploymentConfigureCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *FleetDeploymentConfigureCreateRequest) GetData() FleetDeploymentConfigureCreate { + if o == nil { + var ret FleetDeploymentConfigureCreate + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentConfigureCreateRequest) GetDataOk() (*FleetDeploymentConfigureCreate, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FleetDeploymentConfigureCreateRequest) SetData(v FleetDeploymentConfigureCreate) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentConfigureCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentConfigureCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *FleetDeploymentConfigureCreate `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_file_op.go b/api/datadogV2/model_fleet_deployment_file_op.go new file mode 100644 index 00000000000..03a563e061d --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_file_op.go @@ -0,0 +1,69 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentFileOp Type of file operation to perform on the target configuration file. +// - `merge-patch`: Merges the provided patch data with the existing configuration file. +// Creates the file if it doesn't exist. +// - `delete`: Removes the specified configuration file from the target hosts. +type FleetDeploymentFileOp string + +// List of FleetDeploymentFileOp. +const ( + FLEETDEPLOYMENTFILEOP_MERGE_PATCH FleetDeploymentFileOp = "merge-patch" + FLEETDEPLOYMENTFILEOP_DELETE FleetDeploymentFileOp = "delete" +) + +var allowedFleetDeploymentFileOpEnumValues = []FleetDeploymentFileOp{ + FLEETDEPLOYMENTFILEOP_MERGE_PATCH, + FLEETDEPLOYMENTFILEOP_DELETE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FleetDeploymentFileOp) GetAllowedValues() []FleetDeploymentFileOp { + return allowedFleetDeploymentFileOpEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FleetDeploymentFileOp) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FleetDeploymentFileOp(value) + return nil +} + +// NewFleetDeploymentFileOpFromValue returns a pointer to a valid FleetDeploymentFileOp +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFleetDeploymentFileOpFromValue(v string) (*FleetDeploymentFileOp, error) { + ev := FleetDeploymentFileOp(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FleetDeploymentFileOp: valid values are %v", v, allowedFleetDeploymentFileOpEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FleetDeploymentFileOp) IsValid() bool { + for _, existing := range allowedFleetDeploymentFileOpEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FleetDeploymentFileOp value. +func (v FleetDeploymentFileOp) Ptr() *FleetDeploymentFileOp { + return &v +} diff --git a/api/datadogV2/model_fleet_deployment_operation.go b/api/datadogV2/model_fleet_deployment_operation.go new file mode 100644 index 00000000000..27fb7c54776 --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_operation.go @@ -0,0 +1,185 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentOperation A single configuration file operation to perform on the target hosts. +type FleetDeploymentOperation struct { + // Type of file operation to perform on the target configuration file. + // - `merge-patch`: Merges the provided patch data with the existing configuration file. + // Creates the file if it doesn't exist. + // - `delete`: Removes the specified configuration file from the target hosts. + FileOp FleetDeploymentFileOp `json:"file_op"` + // Absolute path to the target configuration file on the host. + FilePath string `json:"file_path"` + // Patch data in JSON format to apply to the configuration file. + // When using `merge-patch`, this object is merged with the existing configuration, + // allowing you to add, update, or override specific fields without replacing the entire file. + // The structure must match the target configuration file format (for example, YAML structure for Datadog Agent config). + // Not applicable when using the `delete` operation. + Patch map[string]interface{} `json:"patch,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentOperation instantiates a new FleetDeploymentOperation object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentOperation(fileOp FleetDeploymentFileOp, filePath string) *FleetDeploymentOperation { + this := FleetDeploymentOperation{} + this.FileOp = fileOp + this.FilePath = filePath + return &this +} + +// NewFleetDeploymentOperationWithDefaults instantiates a new FleetDeploymentOperation object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentOperationWithDefaults() *FleetDeploymentOperation { + this := FleetDeploymentOperation{} + return &this +} + +// GetFileOp returns the FileOp field value. +func (o *FleetDeploymentOperation) GetFileOp() FleetDeploymentFileOp { + if o == nil { + var ret FleetDeploymentFileOp + return ret + } + return o.FileOp +} + +// GetFileOpOk returns a tuple with the FileOp field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentOperation) GetFileOpOk() (*FleetDeploymentFileOp, bool) { + if o == nil { + return nil, false + } + return &o.FileOp, true +} + +// SetFileOp sets field value. +func (o *FleetDeploymentOperation) SetFileOp(v FleetDeploymentFileOp) { + o.FileOp = v +} + +// GetFilePath returns the FilePath field value. +func (o *FleetDeploymentOperation) GetFilePath() string { + if o == nil { + var ret string + return ret + } + return o.FilePath +} + +// GetFilePathOk returns a tuple with the FilePath field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentOperation) GetFilePathOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.FilePath, true +} + +// SetFilePath sets field value. +func (o *FleetDeploymentOperation) SetFilePath(v string) { + o.FilePath = v +} + +// GetPatch returns the Patch field value if set, zero value otherwise. +func (o *FleetDeploymentOperation) GetPatch() map[string]interface{} { + if o == nil || o.Patch == nil { + var ret map[string]interface{} + return ret + } + return o.Patch +} + +// GetPatchOk returns a tuple with the Patch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentOperation) GetPatchOk() (*map[string]interface{}, bool) { + if o == nil || o.Patch == nil { + return nil, false + } + return &o.Patch, true +} + +// HasPatch returns a boolean if a field has been set. +func (o *FleetDeploymentOperation) HasPatch() bool { + return o != nil && o.Patch != nil +} + +// SetPatch gets a reference to the given map[string]interface{} and assigns it to the Patch field. +func (o *FleetDeploymentOperation) SetPatch(v map[string]interface{}) { + o.Patch = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentOperation) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["file_op"] = o.FileOp + toSerialize["file_path"] = o.FilePath + if o.Patch != nil { + toSerialize["patch"] = o.Patch + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentOperation) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + FileOp *FleetDeploymentFileOp `json:"file_op"` + FilePath *string `json:"file_path"` + Patch map[string]interface{} `json:"patch,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.FileOp == nil { + return fmt.Errorf("required field file_op missing") + } + if all.FilePath == nil { + return fmt.Errorf("required field file_path missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"file_op", "file_path", "patch"}) + } else { + return err + } + + hasInvalidField := false + if !all.FileOp.IsValid() { + hasInvalidField = true + } else { + o.FileOp = *all.FileOp + } + o.FilePath = *all.FilePath + o.Patch = all.Patch + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployment_resource_type.go b/api/datadogV2/model_fleet_deployment_resource_type.go new file mode 100644 index 00000000000..c36e7b37d04 --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_resource_type.go @@ -0,0 +1,64 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentResourceType The type of deployment resource. +type FleetDeploymentResourceType string + +// List of FleetDeploymentResourceType. +const ( + FLEETDEPLOYMENTRESOURCETYPE_DEPLOYMENT FleetDeploymentResourceType = "deployment" +) + +var allowedFleetDeploymentResourceTypeEnumValues = []FleetDeploymentResourceType{ + FLEETDEPLOYMENTRESOURCETYPE_DEPLOYMENT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FleetDeploymentResourceType) GetAllowedValues() []FleetDeploymentResourceType { + return allowedFleetDeploymentResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FleetDeploymentResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FleetDeploymentResourceType(value) + return nil +} + +// NewFleetDeploymentResourceTypeFromValue returns a pointer to a valid FleetDeploymentResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFleetDeploymentResourceTypeFromValue(v string) (*FleetDeploymentResourceType, error) { + ev := FleetDeploymentResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FleetDeploymentResourceType: valid values are %v", v, allowedFleetDeploymentResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FleetDeploymentResourceType) IsValid() bool { + for _, existing := range allowedFleetDeploymentResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FleetDeploymentResourceType value. +func (v FleetDeploymentResourceType) Ptr() *FleetDeploymentResourceType { + return &v +} diff --git a/api/datadogV2/model_fleet_deployment_response.go b/api/datadogV2/model_fleet_deployment_response.go new file mode 100644 index 00000000000..156f6661684 --- /dev/null +++ b/api/datadogV2/model_fleet_deployment_response.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentResponse Response containing a single deployment. +type FleetDeploymentResponse struct { + // A deployment that defines automated configuration changes for a fleet of hosts. + Data *FleetDeployment `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentResponse instantiates a new FleetDeploymentResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentResponse() *FleetDeploymentResponse { + this := FleetDeploymentResponse{} + return &this +} + +// NewFleetDeploymentResponseWithDefaults instantiates a new FleetDeploymentResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentResponseWithDefaults() *FleetDeploymentResponse { + this := FleetDeploymentResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *FleetDeploymentResponse) GetData() FleetDeployment { + if o == nil || o.Data == nil { + var ret FleetDeployment + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentResponse) GetDataOk() (*FleetDeployment, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *FleetDeploymentResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given FleetDeployment and assigns it to the Data field. +func (o *FleetDeploymentResponse) SetData(v FleetDeployment) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *FleetDeployment `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployments_page.go b/api/datadogV2/model_fleet_deployments_page.go new file mode 100644 index 00000000000..c92bce9ec51 --- /dev/null +++ b/api/datadogV2/model_fleet_deployments_page.go @@ -0,0 +1,102 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentsPage Pagination details for the list of deployments. +type FleetDeploymentsPage struct { + // Total number of deployments available across all pages. + TotalCount *int64 `json:"total_count,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentsPage instantiates a new FleetDeploymentsPage object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentsPage() *FleetDeploymentsPage { + this := FleetDeploymentsPage{} + return &this +} + +// NewFleetDeploymentsPageWithDefaults instantiates a new FleetDeploymentsPage object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentsPageWithDefaults() *FleetDeploymentsPage { + this := FleetDeploymentsPage{} + return &this +} + +// GetTotalCount returns the TotalCount field value if set, zero value otherwise. +func (o *FleetDeploymentsPage) GetTotalCount() int64 { + if o == nil || o.TotalCount == nil { + var ret int64 + return ret + } + return *o.TotalCount +} + +// GetTotalCountOk returns a tuple with the TotalCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentsPage) GetTotalCountOk() (*int64, bool) { + if o == nil || o.TotalCount == nil { + return nil, false + } + return o.TotalCount, true +} + +// HasTotalCount returns a boolean if a field has been set. +func (o *FleetDeploymentsPage) HasTotalCount() bool { + return o != nil && o.TotalCount != nil +} + +// SetTotalCount gets a reference to the given int64 and assigns it to the TotalCount field. +func (o *FleetDeploymentsPage) SetTotalCount(v int64) { + o.TotalCount = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentsPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.TotalCount != nil { + toSerialize["total_count"] = o.TotalCount + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentsPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + TotalCount *int64 `json:"total_count,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"total_count"}) + } else { + return err + } + o.TotalCount = all.TotalCount + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployments_response.go b/api/datadogV2/model_fleet_deployments_response.go new file mode 100644 index 00000000000..d7c97898b44 --- /dev/null +++ b/api/datadogV2/model_fleet_deployments_response.go @@ -0,0 +1,145 @@ +// 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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentsResponse Response containing a paginated list of deployments. +type FleetDeploymentsResponse struct { + // Array of deployments matching the query criteria. + Data []FleetDeployment `json:"data"` + // Metadata for the list of deployments, including pagination information. + Meta *FleetDeploymentsResponseMeta `json:"meta,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentsResponse instantiates a new FleetDeploymentsResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentsResponse(data []FleetDeployment) *FleetDeploymentsResponse { + this := FleetDeploymentsResponse{} + this.Data = data + return &this +} + +// NewFleetDeploymentsResponseWithDefaults instantiates a new FleetDeploymentsResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentsResponseWithDefaults() *FleetDeploymentsResponse { + this := FleetDeploymentsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *FleetDeploymentsResponse) GetData() []FleetDeployment { + if o == nil { + var ret []FleetDeployment + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *FleetDeploymentsResponse) GetDataOk() (*[]FleetDeployment, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FleetDeploymentsResponse) SetData(v []FleetDeployment) { + o.Data = v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *FleetDeploymentsResponse) GetMeta() FleetDeploymentsResponseMeta { + if o == nil || o.Meta == nil { + var ret FleetDeploymentsResponseMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentsResponse) GetMetaOk() (*FleetDeploymentsResponseMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *FleetDeploymentsResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given FleetDeploymentsResponseMeta and assigns it to the Meta field. +func (o *FleetDeploymentsResponse) SetMeta(v FleetDeploymentsResponseMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]FleetDeployment `json:"data"` + Meta *FleetDeploymentsResponseMeta `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = *all.Data + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_fleet_deployments_response_meta.go b/api/datadogV2/model_fleet_deployments_response_meta.go new file mode 100644 index 00000000000..0ba782df56b --- /dev/null +++ b/api/datadogV2/model_fleet_deployments_response_meta.go @@ -0,0 +1,111 @@ +// 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 datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FleetDeploymentsResponseMeta Metadata for the list of deployments, including pagination information. +type FleetDeploymentsResponseMeta struct { + // Pagination details for the list of deployments. + Page *FleetDeploymentsPage `json:"page,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFleetDeploymentsResponseMeta instantiates a new FleetDeploymentsResponseMeta object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFleetDeploymentsResponseMeta() *FleetDeploymentsResponseMeta { + this := FleetDeploymentsResponseMeta{} + return &this +} + +// NewFleetDeploymentsResponseMetaWithDefaults instantiates a new FleetDeploymentsResponseMeta object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFleetDeploymentsResponseMetaWithDefaults() *FleetDeploymentsResponseMeta { + this := FleetDeploymentsResponseMeta{} + return &this +} + +// GetPage returns the Page field value if set, zero value otherwise. +func (o *FleetDeploymentsResponseMeta) GetPage() FleetDeploymentsPage { + if o == nil || o.Page == nil { + var ret FleetDeploymentsPage + return ret + } + return *o.Page +} + +// GetPageOk returns a tuple with the Page field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FleetDeploymentsResponseMeta) GetPageOk() (*FleetDeploymentsPage, bool) { + if o == nil || o.Page == nil { + return nil, false + } + return o.Page, true +} + +// HasPage returns a boolean if a field has been set. +func (o *FleetDeploymentsResponseMeta) HasPage() bool { + return o != nil && o.Page != nil +} + +// SetPage gets a reference to the given FleetDeploymentsPage and assigns it to the Page field. +func (o *FleetDeploymentsResponseMeta) SetPage(v FleetDeploymentsPage) { + o.Page = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FleetDeploymentsResponseMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Page != nil { + toSerialize["page"] = o.Page + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FleetDeploymentsResponseMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Page *FleetDeploymentsPage `json:"page,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"page"}) + } else { + return err + } + + hasInvalidField := false + if all.Page != nil && all.Page.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Page = all.Page + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/fleet-automation/CancelFleetDeployment.go b/examples/v2/fleet-automation/CancelFleetDeployment.go new file mode 100644 index 00000000000..7463b3cbdf8 --- /dev/null +++ b/examples/v2/fleet-automation/CancelFleetDeployment.go @@ -0,0 +1,26 @@ +// Cancel a deployment returns "Deployment successfully canceled." response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CancelFleetDeployment", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFleetAutomationApi(apiClient) + r, err := api.CancelFleetDeployment(ctx, "deployment_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FleetAutomationApi.CancelFleetDeployment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/fleet-automation/CreateFleetDeploymentConfigure.go b/examples/v2/fleet-automation/CreateFleetDeploymentConfigure.go new file mode 100644 index 00000000000..bf8cc46146d --- /dev/null +++ b/examples/v2/fleet-automation/CreateFleetDeploymentConfigure.go @@ -0,0 +1,49 @@ +// Create a deployment returns "CREATED" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.FleetDeploymentConfigureCreateRequest{ + Data: datadogV2.FleetDeploymentConfigureCreate{ + Attributes: datadogV2.FleetDeploymentConfigureAttributes{ + ConfigOperations: []datadogV2.FleetDeploymentOperation{ + { + FileOp: datadogV2.FLEETDEPLOYMENTFILEOP_MERGE_PATCH, + FilePath: "/datadog.yaml", + Patch: map[string]interface{}{ + "apm_config": "{'enabled': True}", + "log_level": "debug", + "logs_enabled": "True", + }, + }, + }, + FilterQuery: datadog.PtrString("env:prod AND service:web"), + }, + Type: datadogV2.FLEETDEPLOYMENTRESOURCETYPE_DEPLOYMENT, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateFleetDeploymentConfigure", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFleetAutomationApi(apiClient) + resp, r, err := api.CreateFleetDeploymentConfigure(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FleetAutomationApi.CreateFleetDeploymentConfigure`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.CreateFleetDeploymentConfigure`:\n%s\n", responseContent) +} diff --git a/examples/v2/fleet-automation/GetFleetDeployment.go b/examples/v2/fleet-automation/GetFleetDeployment.go new file mode 100644 index 00000000000..a9a8364ed6d --- /dev/null +++ b/examples/v2/fleet-automation/GetFleetDeployment.go @@ -0,0 +1,33 @@ +// Get a deployment by ID returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "deployment" in the system + DeploymentID := os.Getenv("DEPLOYMENT_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetFleetDeployment", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFleetAutomationApi(apiClient) + resp, r, err := api.GetFleetDeployment(ctx, DeploymentID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FleetAutomationApi.GetFleetDeployment`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.GetFleetDeployment`:\n%s\n", responseContent) +} diff --git a/examples/v2/fleet-automation/ListFleetDeployments.go b/examples/v2/fleet-automation/ListFleetDeployments.go new file mode 100644 index 00000000000..d49d82b99b4 --- /dev/null +++ b/examples/v2/fleet-automation/ListFleetDeployments.go @@ -0,0 +1,30 @@ +// List all deployments returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListFleetDeployments", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFleetAutomationApi(apiClient) + resp, r, err := api.ListFleetDeployments(ctx, *datadogV2.NewListFleetDeploymentsOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FleetAutomationApi.ListFleetDeployments`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.ListFleetDeployments`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 835cacf25bf..774bb42f021 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -44,6 +44,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "AuthenticationApi": reflect.ValueOf(datadogV1.NewAuthenticationApi), }, "v2": { + "FleetAutomationApi": reflect.ValueOf(datadogV2.NewFleetAutomationApi), "ActionsDatastoresApi": reflect.ValueOf(datadogV2.NewActionsDatastoresApi), "ActionConnectionApi": reflect.ValueOf(datadogV2.NewActionConnectionApi), "AgentlessScanningApi": reflect.ValueOf(datadogV2.NewAgentlessScanningApi), diff --git a/tests/scenarios/features/v2/fleet_automation.feature b/tests/scenarios/features/v2/fleet_automation.feature new file mode 100644 index 00000000000..2e91b6e0a85 --- /dev/null +++ b/tests/scenarios/features/v2/fleet_automation.feature @@ -0,0 +1,89 @@ +@endpoint(fleet-automation) @endpoint(fleet-automation-v2) +Feature: Fleet Automation + Manage automated deployments across your fleet of hosts. Use these + endpoints to create, retrieve, and cancel deployments that apply + configuration changes to multiple hosts at once. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "FleetAutomation" API + + @generated @skip @team:DataDog/fleet-automation + Scenario: Cancel a deployment returns "Bad Request" response + Given operation "CancelFleetDeployment" enabled + And new "CancelFleetDeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/fleet-automation + Scenario: Cancel a deployment returns "Deployment successfully canceled." response + Given operation "CancelFleetDeployment" enabled + And new "CancelFleetDeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 Deployment successfully canceled. + + @generated @skip @team:DataDog/fleet-automation + Scenario: Cancel a deployment returns "Not Found" response + Given operation "CancelFleetDeployment" enabled + And new "CancelFleetDeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/fleet-automation + Scenario: Create a deployment returns "Bad Request" response + Given operation "CreateFleetDeploymentConfigure" enabled + And new "CreateFleetDeploymentConfigure" request + And body with value {"data": {"attributes": {"config_operations": [{"file_op": "merge-patch", "file_path": "/datadog.yaml", "patch": {"apm_config": {"enabled": true}, "log_level": "debug", "logs_enabled": true}}], "filter_query": "env:prod AND service:web"}, "type": "deployment"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/fleet-automation + Scenario: Create a deployment returns "CREATED" response + Given operation "CreateFleetDeploymentConfigure" enabled + And new "CreateFleetDeploymentConfigure" request + And body with value {"data": {"attributes": {"config_operations": [{"file_op": "merge-patch", "file_path": "/datadog.yaml", "patch": {"apm_config": {"enabled": true}, "log_level": "debug", "logs_enabled": true}}], "filter_query": "env:prod AND service:web"}, "type": "deployment"}} + When the request is sent + Then the response status is 201 CREATED + + @generated @skip @team:DataDog/fleet-automation + Scenario: Get a deployment by ID returns "Bad Request" response + Given operation "GetFleetDeployment" enabled + And new "GetFleetDeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/fleet-automation + Scenario: Get a deployment by ID returns "Not Found" response + Given operation "GetFleetDeployment" enabled + And new "GetFleetDeployment" request + And request contains "deployment_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/fleet-automation + Scenario: Get a deployment by ID returns "OK" response + Given operation "GetFleetDeployment" enabled + And there is a valid "deployment" in the system + And new "GetFleetDeployment" request + And request contains "deployment_id" parameter from "deployment.id" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/fleet-automation + Scenario: List all deployments returns "Bad Request" response + Given operation "ListFleetDeployments" enabled + And new "ListFleetDeployments" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/fleet-automation + Scenario: List all deployments returns "OK" response + Given operation "ListFleetDeployments" enabled + And new "ListFleetDeployments" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 23b1000e2cd..a4ab9c24bd1 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -1,4 +1,17 @@ [ + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"deployment\",\n \"attributes\": {\n \"filter_query\": \"env:prod AND service:{{ unique_lower }}\",\n \"config_operations\": [\n {\n \"file_op\": \"merge-patch\",\n \"file_path\": \"/datadog.yaml\",\n \"patch\": {\n \"log_level\": \"info\"\n }\n }\n ]\n }\n }\n}" + } + ], + "source": "data", + "step": "there is a valid \"deployment\" in the system", + "key": "deployment", + "tag": "Fleet Automation", + "operationId": "CreateFleetDeploymentConfigure" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 6c74e264b65..bb35cea36c2 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1,4 +1,35 @@ { + "ListFleetDeployments": { + "tag": "Fleet Automation", + "undo": { + "type": "safe" + } + }, + "CreateFleetDeploymentConfigure": { + "tag": "Fleet Automation", + "undo": { + "operationId": "CancelFleetDeployment", + "parameters": [ + { + "name": "deployment_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "GetFleetDeployment": { + "tag": "Fleet Automation", + "undo": { + "type": "safe" + } + }, + "CancelFleetDeployment": { + "tag": "Fleet Automation", + "undo": { + "type": "idempotent" + } + }, "ListDatastores": { "tag": "Actions Datastores", "undo": {