From f48bc74b1da12da50c4612733786c67e756339d9 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 25 Mar 2024 21:31:09 +0000 Subject: [PATCH] Regenerate client from commit 44c8462a of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 276 ++++++++++++++++++ api/datadog/configuration.go | 3 + api/datadogV2/api_service_level_objectives.go | 266 +++++++++++++++++ api/datadogV2/doc.go | 3 + api/datadogV2/model_slo_report_interval.go | 66 +++++ .../model_slo_report_post_request.go | 110 +++++++ ...odel_slo_report_post_request_attributes.go | 245 ++++++++++++++++ .../model_slo_report_post_request_data.go | 110 +++++++ .../model_slo_report_post_response.go | 111 +++++++ .../model_slo_report_post_response_data.go | 137 +++++++++ api/datadogV2/model_slo_report_status.go | 72 +++++ .../model_slo_report_status_get_response.go | 111 +++++++ ...o_report_status_get_response_attributes.go | 112 +++++++ ...del_slo_report_status_get_response_data.go | 181 ++++++++++++ .../CreateSLOReportJob.go | 41 +++ .../service-level-objectives/GetSLOReport.go | 26 ++ .../GetSLOReportJobStatus.go | 33 +++ tests/scenarios/api_mappings.go | 1 + ...report_returns_Bad_Request_response.freeze | 1 + ...O_report_returns_Bad_Request_response.yaml | 23 ++ ..._new_SLO_report_returns_OK_response.freeze | 1 + ..._a_new_SLO_report_returns_OK_response.yaml | 22 ++ ...status_returns_Bad_Request_response.freeze | 1 + ...t_status_returns_Bad_Request_response.yaml | 19 ++ ...O_report_status_returns_OK_response.freeze | 1 + ...SLO_report_status_returns_OK_response.yaml | 39 +++ tests/scenarios/features/v2/given.json | 12 + .../v2/service_level_objectives.feature | 73 +++++ tests/scenarios/features/v2/undo.json | 18 ++ 30 files changed, 2118 insertions(+), 4 deletions(-) create mode 100644 api/datadogV2/api_service_level_objectives.go create mode 100644 api/datadogV2/model_slo_report_interval.go create mode 100644 api/datadogV2/model_slo_report_post_request.go create mode 100644 api/datadogV2/model_slo_report_post_request_attributes.go create mode 100644 api/datadogV2/model_slo_report_post_request_data.go create mode 100644 api/datadogV2/model_slo_report_post_response.go create mode 100644 api/datadogV2/model_slo_report_post_response_data.go create mode 100644 api/datadogV2/model_slo_report_status.go create mode 100644 api/datadogV2/model_slo_report_status_get_response.go create mode 100644 api/datadogV2/model_slo_report_status_get_response_attributes.go create mode 100644 api/datadogV2/model_slo_report_status_get_response_data.go create mode 100644 examples/v2/service-level-objectives/CreateSLOReportJob.go create mode 100644 examples/v2/service-level-objectives/GetSLOReport.go create mode 100644 examples/v2/service-level-objectives/GetSLOReportJobStatus.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.yaml create mode 100644 tests/scenarios/features/v2/service_level_objectives.feature diff --git a/.apigentools-info b/.apigentools-info index 079f2671d82..ab4816295df 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-22 19:28:41.487387", - "spec_repo_commit": "b8f385dc" + "regenerated": "2024-03-25 21:29:33.983440", + "spec_repo_commit": "44c8462a" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-03-22 19:28:41.504951", - "spec_repo_commit": "b8f385dc" + "regenerated": "2024-03-25 21:29:34.000334", + "spec_repo_commit": "44c8462a" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 16aa136f9ab..6a4c54f6d61 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -411,6 +411,13 @@ components: required: true schema: type: string + ReportID: + description: The ID of the report job. + in: path + name: report_id + required: true + schema: + type: string ResourceID: description: 'Identifier, formatted as `type:id`. Supported types: `connection`, `dashboard`, `notebook`, `security-rule`, `slo`.' @@ -16487,6 +16494,92 @@ components: type: string x-enum-varnames: - SAML_ASSERTION_ATTRIBUTES + SLOReportInterval: + description: The frequency at which report data is to be generated. + enum: + - weekly + - monthly + example: weekly + type: string + x-enum-varnames: + - WEEKLY + - MONTHLY + SLOReportPostRequest: + description: The SLO report request body. + properties: + data: + $ref: '#/components/schemas/SLOReportPostRequestData' + required: + - data + type: object + SLOReportPostRequestData: + description: The data portion of the SLO report request. + properties: + attributes: + $ref: '#/components/schemas/SloReportPostRequestAttributes' + required: + - attributes + type: object + SLOReportPostResponse: + description: The SLO report response. + properties: + data: + $ref: '#/components/schemas/SLOReportPostResponseData' + type: object + SLOReportPostResponseData: + description: The data portion of the SLO report response. + properties: + id: + description: The ID of the report job. + example: dc8d92aa-e0af-11ee-af21-1feeaccaa3a3 + type: string + type: + description: The type of ID. + example: report_id + type: string + type: object + SLOReportStatus: + description: The status of the SLO report job. + enum: + - IN_PROGRESS + - COMPLETED + - COMPLETED_WITH_ERRORS + - FAILED + - UNKNOWN + example: COMPLETED + type: string + x-enum-varnames: + - IN_PROGRESS + - COMPLETED + - COMPLETED_WITH_ERRORS + - FAILED + - UNKNOWN + SLOReportStatusGetResponse: + description: The SLO report status response. + properties: + data: + $ref: '#/components/schemas/SLOReportStatusGetResponseData' + type: object + SLOReportStatusGetResponseAttributes: + description: The attributes portion of the SLO report status response. + properties: + status: + $ref: '#/components/schemas/SLOReportStatus' + type: object + SLOReportStatusGetResponseData: + description: The data portion of the SLO report status response. + properties: + attributes: + $ref: '#/components/schemas/SLOReportStatusGetResponseAttributes' + id: + description: The ID of the report job. + example: dc8d92aa-e0af-11ee-af21-1feeaccaa3a3 + type: string + type: + description: The type of ID. + example: report_id + type: string + type: object ScalarColumn: description: A single column in a scalar query response. oneOf: @@ -20124,6 +20217,37 @@ components: - channel_name - redirect_url type: object + SloReportPostRequestAttributes: + description: The attributes portion of the SLO report request. + properties: + from_ts: + description: The `from` timestamp for the report in epoch seconds. + example: 1690901870 + format: int64 + type: integer + interval: + $ref: '#/components/schemas/SLOReportInterval' + query: + description: The query string used to filter SLO results. Some examples + of queries include `service:` and `slo-name`. + example: slo_type:metric + type: string + timezone: + description: The timezone used to determine the start and end of each interval. + For example, weekly intervals start at 12am on Sunday in the specified + timezone. + example: America/New_York + type: string + to_ts: + description: The `to` timestamp for the report in epoch seconds. + example: 1706803070 + format: int64 + type: integer + required: + - query + - from_ts + - to_ts + type: object SortDirection: default: desc description: The direction to sort by. @@ -33594,6 +33718,146 @@ paths: - Incident Services x-codegen-request-body-name: body x-unstable: '**Note**: This endpoint is deprecated.' + /api/v2/slo/report: + post: + description: 'Create a job to generate an SLO report. The report job is processed + asynchronously and will eventually result in a CSV report being available + for download. + + + Check the status of the job and download the CSV report using the returned + `report_id`.' + operationId: CreateSLOReportJob + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SLOReportPostRequest' + description: Create SLO report job request body. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SLOReportPostResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - slos_read + summary: Create a new SLO report + tags: + - Service Level Objectives + x-codegen-request-body-name: body + x-unstable: '**Note: This feature is in private beta. If you are interested + in joining, + + request access via [our public docs](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export).**' + /api/v2/slo/report/{report_id}/download: + get: + description: 'Download an SLO report. This can only be performed after the report + job has completed. + + + Reports are not guaranteed to exist indefinitely. It is recommended to download + the report as soon as it is available.' + operationId: GetSLOReport + parameters: + - $ref: '#/components/parameters/ReportID' + responses: + '200': + content: + text/csv: + schema: + type: string + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - slos_read + summary: Get SLO report + tags: + - Service Level Objectives + x-unstable: '**Note: This feature is in private beta. If you are interested + in joining, + + request access via [our public docs](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export).**' + /api/v2/slo/report/{report_id}/status: + get: + description: Get the status of the SLO report job. + operationId: GetSLOReportJobStatus + parameters: + - $ref: '#/components/parameters/ReportID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SLOReportStatusGetResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - slos_read + summary: Get SLO report status + tags: + - Service Level Objectives + x-unstable: '**Note: This feature is in private beta. If you are interested + in joining, + + request access via [our public docs](https://docs.datadoghq.com/service_management/service_level_objectives/#slo-csv-export).**' /api/v2/spans/analytics/aggregate: post: description: 'The API endpoint to aggregate spans into buckets and compute metrics @@ -36005,6 +36269,18 @@ tags: externalDocs: url: https://docs.datadoghq.com/tracing/service_catalog/ name: Service Definition +- description: '[Service Level Objectives](https://docs.datadoghq.com/monitors/service_level_objectives/#configuration) + + (or SLOs) are a key part of the site reliability engineering toolkit. + + SLOs provide a framework for defining clear targets around application performance, + + which ultimately help teams provide a consistent customer experience, + + balance feature development with platform stability, + + and improve communication with internal and external users.' + name: Service Level Objectives - description: 'API to create, update scorecard rules and outcomes. See [Service Scorecards](https://docs.datadoghq.com/service_catalog/scorecards) for more information. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 0dbecbbd2c9..15cf3ace9fd 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -364,6 +364,9 @@ func NewConfiguration() *Configuration { "v2.GetIncidentService": false, "v2.ListIncidentServices": false, "v2.UpdateIncidentService": false, + "v2.CreateSLOReportJob": false, + "v2.GetSLOReport": false, + "v2.GetSLOReportJobStatus": false, "v2.CreateIncidentTeam": false, "v2.DeleteIncidentTeam": false, "v2.GetIncidentTeam": false, diff --git a/api/datadogV2/api_service_level_objectives.go b/api/datadogV2/api_service_level_objectives.go new file mode 100644 index 00000000000..41cde418072 --- /dev/null +++ b/api/datadogV2/api_service_level_objectives.go @@ -0,0 +1,266 @@ +// 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" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceLevelObjectivesApi service type +type ServiceLevelObjectivesApi datadog.Service + +// CreateSLOReportJob Create a new SLO report. +// Create a job to generate an SLO report. The report job is processed asynchronously and will eventually result in a CSV report being available for download. +// +// Check the status of the job and download the CSV report using the returned `report_id`. +func (a *ServiceLevelObjectivesApi) CreateSLOReportJob(ctx _context.Context, body SLOReportPostRequest) (SLOReportPostResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue SLOReportPostResponse + ) + + operationId := "v2.CreateSLOReportJob" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceLevelObjectivesApi.CreateSLOReportJob") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/slo/report" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + 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 == 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 +} + +// GetSLOReport Get SLO report. +// Download an SLO report. This can only be performed after the report job has completed. +// +// Reports are not guaranteed to exist indefinitely. It is recommended to download the report as soon as it is available. +func (a *ServiceLevelObjectivesApi) GetSLOReport(ctx _context.Context, reportId string) (string, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue string + ) + + operationId := "v2.GetSLOReport" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceLevelObjectivesApi.GetSLOReport") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/slo/report/{report_id}/download" + localVarPath = strings.Replace(localVarPath, "{"+"report_id"+"}", _neturl.PathEscape(datadog.ParameterToString(reportId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + 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 == 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 +} + +// GetSLOReportJobStatus Get SLO report status. +// Get the status of the SLO report job. +func (a *ServiceLevelObjectivesApi) GetSLOReportJobStatus(ctx _context.Context, reportId string) (SLOReportStatusGetResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SLOReportStatusGetResponse + ) + + operationId := "v2.GetSLOReportJobStatus" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceLevelObjectivesApi.GetSLOReportJobStatus") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/slo/report/{report_id}/status" + localVarPath = strings.Replace(localVarPath, "{"+"report_id"+"}", _neturl.PathEscape(datadog.ParameterToString(reportId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + 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 == 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 +} + +// NewServiceLevelObjectivesApi Returns NewServiceLevelObjectivesApi. +func NewServiceLevelObjectivesApi(client *datadog.APIClient) *ServiceLevelObjectivesApi { + return &ServiceLevelObjectivesApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 84f0f1d129d..c21fc24df2f 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -281,6 +281,9 @@ // - [ServiceDefinitionApi.DeleteServiceDefinition] // - [ServiceDefinitionApi.GetServiceDefinition] // - [ServiceDefinitionApi.ListServiceDefinitions] +// - [ServiceLevelObjectivesApi.CreateSLOReportJob] +// - [ServiceLevelObjectivesApi.GetSLOReport] +// - [ServiceLevelObjectivesApi.GetSLOReportJobStatus] // - [ServiceScorecardsApi.CreateScorecardOutcomesBatch] // - [ServiceScorecardsApi.CreateScorecardRule] // - [ServiceScorecardsApi.DeleteScorecardRule] diff --git a/api/datadogV2/model_slo_report_interval.go b/api/datadogV2/model_slo_report_interval.go new file mode 100644 index 00000000000..4a163791246 --- /dev/null +++ b/api/datadogV2/model_slo_report_interval.go @@ -0,0 +1,66 @@ +// 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" +) + +// SLOReportInterval The frequency at which report data is to be generated. +type SLOReportInterval string + +// List of SLOReportInterval. +const ( + SLOREPORTINTERVAL_WEEKLY SLOReportInterval = "weekly" + SLOREPORTINTERVAL_MONTHLY SLOReportInterval = "monthly" +) + +var allowedSLOReportIntervalEnumValues = []SLOReportInterval{ + SLOREPORTINTERVAL_WEEKLY, + SLOREPORTINTERVAL_MONTHLY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SLOReportInterval) GetAllowedValues() []SLOReportInterval { + return allowedSLOReportIntervalEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SLOReportInterval) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SLOReportInterval(value) + return nil +} + +// NewSLOReportIntervalFromValue returns a pointer to a valid SLOReportInterval +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSLOReportIntervalFromValue(v string) (*SLOReportInterval, error) { + ev := SLOReportInterval(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SLOReportInterval: valid values are %v", v, allowedSLOReportIntervalEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SLOReportInterval) IsValid() bool { + for _, existing := range allowedSLOReportIntervalEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SLOReportInterval value. +func (v SLOReportInterval) Ptr() *SLOReportInterval { + return &v +} diff --git a/api/datadogV2/model_slo_report_post_request.go b/api/datadogV2/model_slo_report_post_request.go new file mode 100644 index 00000000000..7d3a3015466 --- /dev/null +++ b/api/datadogV2/model_slo_report_post_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" +) + +// SLOReportPostRequest The SLO report request body. +type SLOReportPostRequest struct { + // The data portion of the SLO report request. + Data SLOReportPostRequestData `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{} +} + +// NewSLOReportPostRequest instantiates a new SLOReportPostRequest 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 NewSLOReportPostRequest(data SLOReportPostRequestData) *SLOReportPostRequest { + this := SLOReportPostRequest{} + this.Data = data + return &this +} + +// NewSLOReportPostRequestWithDefaults instantiates a new SLOReportPostRequest 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 NewSLOReportPostRequestWithDefaults() *SLOReportPostRequest { + this := SLOReportPostRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *SLOReportPostRequest) GetData() SLOReportPostRequestData { + if o == nil { + var ret SLOReportPostRequestData + 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 *SLOReportPostRequest) GetDataOk() (*SLOReportPostRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SLOReportPostRequest) SetData(v SLOReportPostRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportPostRequest) 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 *SLOReportPostRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SLOReportPostRequestData `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_slo_report_post_request_attributes.go b/api/datadogV2/model_slo_report_post_request_attributes.go new file mode 100644 index 00000000000..8d2004096dd --- /dev/null +++ b/api/datadogV2/model_slo_report_post_request_attributes.go @@ -0,0 +1,245 @@ +// 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" +) + +// SloReportPostRequestAttributes The attributes portion of the SLO report request. +type SloReportPostRequestAttributes struct { + // The `from` timestamp for the report in epoch seconds. + FromTs int64 `json:"from_ts"` + // The frequency at which report data is to be generated. + Interval *SLOReportInterval `json:"interval,omitempty"` + // The query string used to filter SLO results. Some examples of queries include `service:` and `slo-name`. + Query string `json:"query"` + // The timezone used to determine the start and end of each interval. For example, weekly intervals start at 12am on Sunday in the specified timezone. + Timezone *string `json:"timezone,omitempty"` + // The `to` timestamp for the report in epoch seconds. + ToTs int64 `json:"to_ts"` + // 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{} +} + +// NewSloReportPostRequestAttributes instantiates a new SloReportPostRequestAttributes 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 NewSloReportPostRequestAttributes(fromTs int64, query string, toTs int64) *SloReportPostRequestAttributes { + this := SloReportPostRequestAttributes{} + this.FromTs = fromTs + this.Query = query + this.ToTs = toTs + return &this +} + +// NewSloReportPostRequestAttributesWithDefaults instantiates a new SloReportPostRequestAttributes 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 NewSloReportPostRequestAttributesWithDefaults() *SloReportPostRequestAttributes { + this := SloReportPostRequestAttributes{} + return &this +} + +// GetFromTs returns the FromTs field value. +func (o *SloReportPostRequestAttributes) GetFromTs() int64 { + if o == nil { + var ret int64 + return ret + } + return o.FromTs +} + +// GetFromTsOk returns a tuple with the FromTs field value +// and a boolean to check if the value has been set. +func (o *SloReportPostRequestAttributes) GetFromTsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.FromTs, true +} + +// SetFromTs sets field value. +func (o *SloReportPostRequestAttributes) SetFromTs(v int64) { + o.FromTs = v +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *SloReportPostRequestAttributes) GetInterval() SLOReportInterval { + if o == nil || o.Interval == nil { + var ret SLOReportInterval + return ret + } + return *o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SloReportPostRequestAttributes) GetIntervalOk() (*SLOReportInterval, bool) { + if o == nil || o.Interval == nil { + return nil, false + } + return o.Interval, true +} + +// HasInterval returns a boolean if a field has been set. +func (o *SloReportPostRequestAttributes) HasInterval() bool { + return o != nil && o.Interval != nil +} + +// SetInterval gets a reference to the given SLOReportInterval and assigns it to the Interval field. +func (o *SloReportPostRequestAttributes) SetInterval(v SLOReportInterval) { + o.Interval = &v +} + +// GetQuery returns the Query field value. +func (o *SloReportPostRequestAttributes) GetQuery() string { + if o == nil { + var ret string + return ret + } + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *SloReportPostRequestAttributes) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value. +func (o *SloReportPostRequestAttributes) SetQuery(v string) { + o.Query = v +} + +// GetTimezone returns the Timezone field value if set, zero value otherwise. +func (o *SloReportPostRequestAttributes) GetTimezone() string { + if o == nil || o.Timezone == nil { + var ret string + return ret + } + return *o.Timezone +} + +// GetTimezoneOk returns a tuple with the Timezone field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SloReportPostRequestAttributes) GetTimezoneOk() (*string, bool) { + if o == nil || o.Timezone == nil { + return nil, false + } + return o.Timezone, true +} + +// HasTimezone returns a boolean if a field has been set. +func (o *SloReportPostRequestAttributes) HasTimezone() bool { + return o != nil && o.Timezone != nil +} + +// SetTimezone gets a reference to the given string and assigns it to the Timezone field. +func (o *SloReportPostRequestAttributes) SetTimezone(v string) { + o.Timezone = &v +} + +// GetToTs returns the ToTs field value. +func (o *SloReportPostRequestAttributes) GetToTs() int64 { + if o == nil { + var ret int64 + return ret + } + return o.ToTs +} + +// GetToTsOk returns a tuple with the ToTs field value +// and a boolean to check if the value has been set. +func (o *SloReportPostRequestAttributes) GetToTsOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.ToTs, true +} + +// SetToTs sets field value. +func (o *SloReportPostRequestAttributes) SetToTs(v int64) { + o.ToTs = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SloReportPostRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["from_ts"] = o.FromTs + if o.Interval != nil { + toSerialize["interval"] = o.Interval + } + toSerialize["query"] = o.Query + if o.Timezone != nil { + toSerialize["timezone"] = o.Timezone + } + toSerialize["to_ts"] = o.ToTs + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SloReportPostRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + FromTs *int64 `json:"from_ts"` + Interval *SLOReportInterval `json:"interval,omitempty"` + Query *string `json:"query"` + Timezone *string `json:"timezone,omitempty"` + ToTs *int64 `json:"to_ts"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.FromTs == nil { + return fmt.Errorf("required field from_ts missing") + } + if all.Query == nil { + return fmt.Errorf("required field query missing") + } + if all.ToTs == nil { + return fmt.Errorf("required field to_ts missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"from_ts", "interval", "query", "timezone", "to_ts"}) + } else { + return err + } + + hasInvalidField := false + o.FromTs = *all.FromTs + if all.Interval != nil && !all.Interval.IsValid() { + hasInvalidField = true + } else { + o.Interval = all.Interval + } + o.Query = *all.Query + o.Timezone = all.Timezone + o.ToTs = *all.ToTs + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_slo_report_post_request_data.go b/api/datadogV2/model_slo_report_post_request_data.go new file mode 100644 index 00000000000..22c0bae739b --- /dev/null +++ b/api/datadogV2/model_slo_report_post_request_data.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" +) + +// SLOReportPostRequestData The data portion of the SLO report request. +type SLOReportPostRequestData struct { + // The attributes portion of the SLO report request. + Attributes SloReportPostRequestAttributes `json:"attributes"` + // 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{} +} + +// NewSLOReportPostRequestData instantiates a new SLOReportPostRequestData 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 NewSLOReportPostRequestData(attributes SloReportPostRequestAttributes) *SLOReportPostRequestData { + this := SLOReportPostRequestData{} + this.Attributes = attributes + return &this +} + +// NewSLOReportPostRequestDataWithDefaults instantiates a new SLOReportPostRequestData 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 NewSLOReportPostRequestDataWithDefaults() *SLOReportPostRequestData { + this := SLOReportPostRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SLOReportPostRequestData) GetAttributes() SloReportPostRequestAttributes { + if o == nil { + var ret SloReportPostRequestAttributes + 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 *SLOReportPostRequestData) GetAttributesOk() (*SloReportPostRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SLOReportPostRequestData) SetAttributes(v SloReportPostRequestAttributes) { + o.Attributes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportPostRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SLOReportPostRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SloReportPostRequestAttributes `json:"attributes"` + }{} + 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") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_slo_report_post_response.go b/api/datadogV2/model_slo_report_post_response.go new file mode 100644 index 00000000000..030c0cb4287 --- /dev/null +++ b/api/datadogV2/model_slo_report_post_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" +) + +// SLOReportPostResponse The SLO report response. +type SLOReportPostResponse struct { + // The data portion of the SLO report response. + Data *SLOReportPostResponseData `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{} +} + +// NewSLOReportPostResponse instantiates a new SLOReportPostResponse 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 NewSLOReportPostResponse() *SLOReportPostResponse { + this := SLOReportPostResponse{} + return &this +} + +// NewSLOReportPostResponseWithDefaults instantiates a new SLOReportPostResponse 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 NewSLOReportPostResponseWithDefaults() *SLOReportPostResponse { + this := SLOReportPostResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *SLOReportPostResponse) GetData() SLOReportPostResponseData { + if o == nil || o.Data == nil { + var ret SLOReportPostResponseData + 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 *SLOReportPostResponse) GetDataOk() (*SLOReportPostResponseData, 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 *SLOReportPostResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given SLOReportPostResponseData and assigns it to the Data field. +func (o *SLOReportPostResponse) SetData(v SLOReportPostResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportPostResponse) 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 *SLOReportPostResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SLOReportPostResponseData `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_slo_report_post_response_data.go b/api/datadogV2/model_slo_report_post_response_data.go new file mode 100644 index 00000000000..2fe894733c2 --- /dev/null +++ b/api/datadogV2/model_slo_report_post_response_data.go @@ -0,0 +1,137 @@ +// 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" +) + +// SLOReportPostResponseData The data portion of the SLO report response. +type SLOReportPostResponseData struct { + // The ID of the report job. + Id *string `json:"id,omitempty"` + // The type of ID. + Type *string `json:"type,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{} +} + +// NewSLOReportPostResponseData instantiates a new SLOReportPostResponseData 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 NewSLOReportPostResponseData() *SLOReportPostResponseData { + this := SLOReportPostResponseData{} + return &this +} + +// NewSLOReportPostResponseDataWithDefaults instantiates a new SLOReportPostResponseData 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 NewSLOReportPostResponseDataWithDefaults() *SLOReportPostResponseData { + this := SLOReportPostResponseData{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SLOReportPostResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportPostResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *SLOReportPostResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *SLOReportPostResponseData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *SLOReportPostResponseData) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportPostResponseData) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *SLOReportPostResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *SLOReportPostResponseData) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportPostResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SLOReportPostResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + Type *string `json:"type,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{"id", "type"}) + } else { + return err + } + o.Id = all.Id + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_slo_report_status.go b/api/datadogV2/model_slo_report_status.go new file mode 100644 index 00000000000..543ea8838a7 --- /dev/null +++ b/api/datadogV2/model_slo_report_status.go @@ -0,0 +1,72 @@ +// 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" +) + +// SLOReportStatus The status of the SLO report job. +type SLOReportStatus string + +// List of SLOReportStatus. +const ( + SLOREPORTSTATUS_IN_PROGRESS SLOReportStatus = "IN_PROGRESS" + SLOREPORTSTATUS_COMPLETED SLOReportStatus = "COMPLETED" + SLOREPORTSTATUS_COMPLETED_WITH_ERRORS SLOReportStatus = "COMPLETED_WITH_ERRORS" + SLOREPORTSTATUS_FAILED SLOReportStatus = "FAILED" + SLOREPORTSTATUS_UNKNOWN SLOReportStatus = "UNKNOWN" +) + +var allowedSLOReportStatusEnumValues = []SLOReportStatus{ + SLOREPORTSTATUS_IN_PROGRESS, + SLOREPORTSTATUS_COMPLETED, + SLOREPORTSTATUS_COMPLETED_WITH_ERRORS, + SLOREPORTSTATUS_FAILED, + SLOREPORTSTATUS_UNKNOWN, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SLOReportStatus) GetAllowedValues() []SLOReportStatus { + return allowedSLOReportStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SLOReportStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SLOReportStatus(value) + return nil +} + +// NewSLOReportStatusFromValue returns a pointer to a valid SLOReportStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSLOReportStatusFromValue(v string) (*SLOReportStatus, error) { + ev := SLOReportStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SLOReportStatus: valid values are %v", v, allowedSLOReportStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SLOReportStatus) IsValid() bool { + for _, existing := range allowedSLOReportStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SLOReportStatus value. +func (v SLOReportStatus) Ptr() *SLOReportStatus { + return &v +} diff --git a/api/datadogV2/model_slo_report_status_get_response.go b/api/datadogV2/model_slo_report_status_get_response.go new file mode 100644 index 00000000000..72041cb56a5 --- /dev/null +++ b/api/datadogV2/model_slo_report_status_get_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" +) + +// SLOReportStatusGetResponse The SLO report status response. +type SLOReportStatusGetResponse struct { + // The data portion of the SLO report status response. + Data *SLOReportStatusGetResponseData `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{} +} + +// NewSLOReportStatusGetResponse instantiates a new SLOReportStatusGetResponse 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 NewSLOReportStatusGetResponse() *SLOReportStatusGetResponse { + this := SLOReportStatusGetResponse{} + return &this +} + +// NewSLOReportStatusGetResponseWithDefaults instantiates a new SLOReportStatusGetResponse 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 NewSLOReportStatusGetResponseWithDefaults() *SLOReportStatusGetResponse { + this := SLOReportStatusGetResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *SLOReportStatusGetResponse) GetData() SLOReportStatusGetResponseData { + if o == nil || o.Data == nil { + var ret SLOReportStatusGetResponseData + 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 *SLOReportStatusGetResponse) GetDataOk() (*SLOReportStatusGetResponseData, 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 *SLOReportStatusGetResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given SLOReportStatusGetResponseData and assigns it to the Data field. +func (o *SLOReportStatusGetResponse) SetData(v SLOReportStatusGetResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportStatusGetResponse) 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 *SLOReportStatusGetResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SLOReportStatusGetResponseData `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_slo_report_status_get_response_attributes.go b/api/datadogV2/model_slo_report_status_get_response_attributes.go new file mode 100644 index 00000000000..a458a12500b --- /dev/null +++ b/api/datadogV2/model_slo_report_status_get_response_attributes.go @@ -0,0 +1,112 @@ +// 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" +) + +// SLOReportStatusGetResponseAttributes The attributes portion of the SLO report status response. +type SLOReportStatusGetResponseAttributes struct { + // The status of the SLO report job. + Status *SLOReportStatus `json:"status,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{} +} + +// NewSLOReportStatusGetResponseAttributes instantiates a new SLOReportStatusGetResponseAttributes 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 NewSLOReportStatusGetResponseAttributes() *SLOReportStatusGetResponseAttributes { + this := SLOReportStatusGetResponseAttributes{} + return &this +} + +// NewSLOReportStatusGetResponseAttributesWithDefaults instantiates a new SLOReportStatusGetResponseAttributes 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 NewSLOReportStatusGetResponseAttributesWithDefaults() *SLOReportStatusGetResponseAttributes { + this := SLOReportStatusGetResponseAttributes{} + return &this +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *SLOReportStatusGetResponseAttributes) GetStatus() SLOReportStatus { + if o == nil || o.Status == nil { + var ret SLOReportStatus + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportStatusGetResponseAttributes) GetStatusOk() (*SLOReportStatus, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *SLOReportStatusGetResponseAttributes) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given SLOReportStatus and assigns it to the Status field. +func (o *SLOReportStatusGetResponseAttributes) SetStatus(v SLOReportStatus) { + o.Status = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportStatusGetResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Status != nil { + toSerialize["status"] = o.Status + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SLOReportStatusGetResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Status *SLOReportStatus `json:"status,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{"status"}) + } else { + return err + } + + hasInvalidField := false + if all.Status != nil && !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_slo_report_status_get_response_data.go b/api/datadogV2/model_slo_report_status_get_response_data.go new file mode 100644 index 00000000000..46a498beec5 --- /dev/null +++ b/api/datadogV2/model_slo_report_status_get_response_data.go @@ -0,0 +1,181 @@ +// 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" +) + +// SLOReportStatusGetResponseData The data portion of the SLO report status response. +type SLOReportStatusGetResponseData struct { + // The attributes portion of the SLO report status response. + Attributes *SLOReportStatusGetResponseAttributes `json:"attributes,omitempty"` + // The ID of the report job. + Id *string `json:"id,omitempty"` + // The type of ID. + Type *string `json:"type,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{} +} + +// NewSLOReportStatusGetResponseData instantiates a new SLOReportStatusGetResponseData 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 NewSLOReportStatusGetResponseData() *SLOReportStatusGetResponseData { + this := SLOReportStatusGetResponseData{} + return &this +} + +// NewSLOReportStatusGetResponseDataWithDefaults instantiates a new SLOReportStatusGetResponseData 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 NewSLOReportStatusGetResponseDataWithDefaults() *SLOReportStatusGetResponseData { + this := SLOReportStatusGetResponseData{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *SLOReportStatusGetResponseData) GetAttributes() SLOReportStatusGetResponseAttributes { + if o == nil || o.Attributes == nil { + var ret SLOReportStatusGetResponseAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportStatusGetResponseData) GetAttributesOk() (*SLOReportStatusGetResponseAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *SLOReportStatusGetResponseData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given SLOReportStatusGetResponseAttributes and assigns it to the Attributes field. +func (o *SLOReportStatusGetResponseData) SetAttributes(v SLOReportStatusGetResponseAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SLOReportStatusGetResponseData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportStatusGetResponseData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *SLOReportStatusGetResponseData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *SLOReportStatusGetResponseData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *SLOReportStatusGetResponseData) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SLOReportStatusGetResponseData) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *SLOReportStatusGetResponseData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *SLOReportStatusGetResponseData) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SLOReportStatusGetResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SLOReportStatusGetResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SLOReportStatusGetResponseAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *string `json:"type,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{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/service-level-objectives/CreateSLOReportJob.go b/examples/v2/service-level-objectives/CreateSLOReportJob.go new file mode 100644 index 00000000000..2d349564f56 --- /dev/null +++ b/examples/v2/service-level-objectives/CreateSLOReportJob.go @@ -0,0 +1,41 @@ +// Create a new SLO report 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() { + body := datadogV2.SLOReportPostRequest{ + Data: datadogV2.SLOReportPostRequestData{ + Attributes: datadogV2.SloReportPostRequestAttributes{ + FromTs: 1690901870, + ToTs: 1706803070, + Query: `slo_type:metric "SLO Reporting Test"`, + Interval: datadogV2.SLOREPORTINTERVAL_MONTHLY.Ptr(), + Timezone: datadog.PtrString("America/New_York"), + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateSLOReportJob", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceLevelObjectivesApi(apiClient) + resp, r, err := api.CreateSLOReportJob(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.CreateSLOReportJob`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.CreateSLOReportJob`:\n%s\n", responseContent) +} diff --git a/examples/v2/service-level-objectives/GetSLOReport.go b/examples/v2/service-level-objectives/GetSLOReport.go new file mode 100644 index 00000000000..221877d7ce7 --- /dev/null +++ b/examples/v2/service-level-objectives/GetSLOReport.go @@ -0,0 +1,26 @@ +// Get SLO report returns "OK" 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.GetSLOReport", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceLevelObjectivesApi(apiClient) + resp, r, err := api.GetSLOReport(ctx, "9fb2dc2a-ead0-11ee-a174-9fe3a9d7627f") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLOReport`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/service-level-objectives/GetSLOReportJobStatus.go b/examples/v2/service-level-objectives/GetSLOReportJobStatus.go new file mode 100644 index 00000000000..b4225537fbe --- /dev/null +++ b/examples/v2/service-level-objectives/GetSLOReportJobStatus.go @@ -0,0 +1,33 @@ +// Get SLO report status 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 "report" in the system + ReportDataID := os.Getenv("REPORT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetSLOReportJobStatus", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceLevelObjectivesApi(apiClient) + resp, r, err := api.GetSLOReportJobStatus(ctx, ReportDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceLevelObjectivesApi.GetSLOReportJobStatus`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceLevelObjectivesApi.GetSLOReportJobStatus`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 5bfcfc0a999..7d4227c89ac 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -88,6 +88,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "ServiceAccountsApi": reflect.ValueOf(datadogV2.NewServiceAccountsApi), "IncidentServicesApi": reflect.ValueOf(datadogV2.NewIncidentServicesApi), "ServiceDefinitionApi": reflect.ValueOf(datadogV2.NewServiceDefinitionApi), + "ServiceLevelObjectivesApi": reflect.ValueOf(datadogV2.NewServiceLevelObjectivesApi), "SpansApi": reflect.ValueOf(datadogV2.NewSpansApi), "SyntheticsApi": reflect.ValueOf(datadogV2.NewSyntheticsApi), "TeamsApi": reflect.ValueOf(datadogV2.NewTeamsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..19fee92b9d8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-03-25T21:23:42.888Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..27eed5dd3ff --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"from_ts":"invalid_from_ts","query":"slo_type:metric \"SLO Reporting Test\"","to_ts":1706803070}}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/slo/report + response: + body: '{"errors":[{"status":"400","title":"Bad Request","detail":"json: cannot + unmarshal string into Go struct field ReportConfiguration.from_ts of type int64"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.freeze new file mode 100644 index 00000000000..220b684fd02 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-25T21:23:43.031Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.yaml new file mode 100644 index 00000000000..b861b857cfe --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Create_a_new_SLO_report_returns_OK_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"from_ts":1690901870,"interval":"monthly","query":"slo_type:metric \"SLO Reporting Test\"","timezone":"America/New_York","to_ts":1706803070}}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/slo/report + response: + body: '{"data":{"id":"f4dfac06-eaed-11ee-900d-5fe0c2b4bd38","type":"report_id"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..1349ac7e464 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2024-03-25T21:23:43.248Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..51c08ac7b10 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/slo/report/invalid-report-id/status + response: + body: '{"errors":[{"title":"Request Timeout","detail":"invalid report ID: invalid-report-id"}]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.freeze new file mode 100644 index 00000000000..8a1b40c6306 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.freeze @@ -0,0 +1 @@ +2024-03-25T21:23:43.334Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.yaml new file mode 100644 index 00000000000..ed1d339cc44 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Level_Objectives/Scenario_Get_SLO_report_status_returns_OK_response.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"from_ts":1690901870,"interval":"monthly","query":"slo_type:metric \"SLO Reporting Test\"","to_ts":1706803070}}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/slo/report + response: + body: '{"data":{"id":"f5186604-eaed-11ee-900e-67f23d84a6eb","type":"report_id"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/slo/report/f5186604-eaed-11ee-900e-67f23d84a6eb/status + response: + body: '{"data":{"id":"f5186604-eaed-11ee-900e-67f23d84a6eb","type":"report_id","attributes":{"status":"IN_PROGRESS"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 5201f7e3c2c..58ed345e7a4 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -601,6 +601,18 @@ "tag": "Service Definition", "operationId": "CreateOrUpdateServiceDefinitions" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"query\": \"slo_type:metric \\\"SLO Reporting Test\\\"\",\n \"interval\": \"monthly\",\n \"from_ts\": 1690901870,\n \"to_ts\": 1706803070\n }\n }\n}" + } + ], + "step": "there is a valid \"report\" in the system", + "key": "report", + "tag": "Service Level Objectives", + "operationId": "CreateSLOReportJob" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/service_level_objectives.feature b/tests/scenarios/features/v2/service_level_objectives.feature new file mode 100644 index 00000000000..f80226f45b9 --- /dev/null +++ b/tests/scenarios/features/v2/service_level_objectives.feature @@ -0,0 +1,73 @@ +@endpoint(service-level-objectives) @endpoint(service-level-objectives-v2) +Feature: Service Level Objectives + [Service Level Objectives](https://docs.datadoghq.com/monitors/service_lev + el_objectives/#configuration) (or SLOs) are a key part of the site + reliability engineering toolkit. SLOs provide a framework for defining + clear targets around application performance, which ultimately help teams + provide a consistent customer experience, balance feature development with + platform stability, and improve communication with internal and external + users. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ServiceLevelObjectives" API + + @team:DataDog/slo-app + Scenario: Create a new SLO report returns "Bad Request" response + Given operation "CreateSLOReportJob" enabled + And new "CreateSLOReportJob" request + And body with value {"data": {"attributes": {"from_ts": "invalid_from_ts", "to_ts": 1706803070, "query": "slo_type:metric \"SLO Reporting Test\""}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/slo-app + Scenario: Create a new SLO report returns "OK" response + Given operation "CreateSLOReportJob" enabled + And new "CreateSLOReportJob" request + And body with value {"data": {"attributes": {"from_ts": 1690901870, "to_ts": 1706803070, "query": "slo_type:metric \"SLO Reporting Test\"", "interval": "monthly", "timezone": "America/New_York"}}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "report_id" + + @skip @team:DataDog/slo-app + Scenario: Get SLO report returns "Not Found" response + Given operation "GetSLOReport" enabled + And new "GetSLOReport" request + And request contains "report_id" parameter with value "invalid-report-id" + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/slo-app + Scenario: Get SLO report returns "OK" response + Given operation "GetSLOReport" enabled + And new "GetSLOReport" request + And request contains "report_id" parameter with value "9fb2dc2a-ead0-11ee-a174-9fe3a9d7627f" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/slo-app + Scenario: Get SLO report status returns "Bad Request" response + Given operation "GetSLOReportJobStatus" enabled + And new "GetSLOReportJobStatus" request + And request contains "report_id" parameter with value "invalid-report-id" + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/slo-app + Scenario: Get SLO report status returns "Not Found" response + Given operation "GetSLOReportJobStatus" enabled + And new "GetSLOReportJobStatus" request + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/slo-app + Scenario: Get SLO report status returns "OK" response + Given operation "GetSLOReportJobStatus" enabled + And new "GetSLOReportJobStatus" request + And there is a valid "report" in the system + And request contains "report_id" parameter from "report.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "report_id" + And the response "data.attributes.status" is equal to "IN_PROGRESS" diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index f1ce400479c..ca2154193d7 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2010,6 +2010,24 @@ "type": "idempotent" } }, + "CreateSLOReportJob": { + "tag": "Service Level Objectives", + "undo": { + "type": "safe" + } + }, + "GetSLOReport": { + "tag": "Service Level Objectives", + "undo": { + "type": "safe" + } + }, + "GetSLOReportJobStatus": { + "tag": "Service Level Objectives", + "undo": { + "type": "safe" + } + }, "AggregateSpans": { "tag": "Spans", "undo": {