From 4099375f46582b88353b070150d5794249cf62a5 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2020 11:03:24 +0200 Subject: [PATCH] [Synthetics] Add create, edit and delete endpoints for global variables (#421) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Synthetics] Add global variable endpoint tests * Update tests/api/v1/datadog/api_synthetics_test.go Co-authored-by: Jiri Kuncar * [Synthetics] Fix missing tags * [Synthetics] Update tests with new endpoints * [Synthetics] Fix global variable creation * Regenerate client from commit 049bffd of spec repo * Fix test Co-authored-by: Romain Berger Co-authored-by: Romain Berger Co-authored-by: Jiri Kuncar Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec Co-authored-by: Thomas Hervé --- .apigentools-info | 8 +- api/v1/datadog/.openapi-generator/FILES | 4 + api/v1/datadog/README.md | 5 + api/v1/datadog/api/openapi.yaml | 164 ++++++ api/v1/datadog/api_synthetics.go | 473 ++++++++++++++++++ api/v1/datadog/docs/SyntheticsApi.md | 248 +++++++++ .../datadog/docs/SyntheticsGlobalVariable.md | 140 ++++++ .../docs/SyntheticsGlobalVariableValue.md | 77 +++ .../model_synthetics_global_variable.go | 231 +++++++++ .../model_synthetics_global_variable_value.go | 142 ++++++ tests/api/v1/datadog/api_synthetics_test.go | 49 +- .../TestSyntheticsDeleteVariable.yaml | 0 .../TestSyntheticsVariableLifecycle.freeze | 1 + .../TestSyntheticsVariableLifecycle.yaml | 186 +++++++ .../v1/datadog/features/synthetics.feature | 22 + 15 files changed, 1744 insertions(+), 6 deletions(-) create mode 100644 api/v1/datadog/docs/SyntheticsGlobalVariable.md create mode 100644 api/v1/datadog/docs/SyntheticsGlobalVariableValue.md create mode 100644 api/v1/datadog/model_synthetics_global_variable.go create mode 100644 api/v1/datadog/model_synthetics_global_variable_value.go create mode 100644 tests/api/v1/datadog/cassettes/TestSyntheticsDeleteVariable.yaml create mode 100644 tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.freeze create mode 100644 tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.yaml diff --git a/.apigentools-info b/.apigentools-info index 9fead048e5e..52f4f960947 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.2.0", - "regenerated": "2020-07-30 15:13:16.740261", - "spec_repo_commit": "a7ab9d2" + "regenerated": "2020-07-31 08:09:16.579146", + "spec_repo_commit": "049bffd" }, "v2": { "apigentools_version": "1.2.0", - "regenerated": "2020-07-30 15:13:22.348328", - "spec_repo_commit": "a7ab9d2" + "regenerated": "2020-07-31 08:09:21.963297", + "spec_repo_commit": "049bffd" } } } \ No newline at end of file diff --git a/api/v1/datadog/.openapi-generator/FILES b/api/v1/datadog/.openapi-generator/FILES index 868c2b5bae6..18ac049a4f4 100644 --- a/api/v1/datadog/.openapi-generator/FILES +++ b/api/v1/datadog/.openapi-generator/FILES @@ -310,6 +310,8 @@ docs/SyntheticsDeviceID.md docs/SyntheticsErrorCode.md docs/SyntheticsGetAPITestLatestResultsResponse.md docs/SyntheticsGetBrowserTestLatestResultsResponse.md +docs/SyntheticsGlobalVariable.md +docs/SyntheticsGlobalVariableValue.md docs/SyntheticsListTestsResponse.md docs/SyntheticsLocation.md docs/SyntheticsLocations.md @@ -712,6 +714,8 @@ model_synthetics_device_id.go model_synthetics_error_code.go model_synthetics_get_api_test_latest_results_response.go model_synthetics_get_browser_test_latest_results_response.go +model_synthetics_global_variable.go +model_synthetics_global_variable_value.go model_synthetics_list_tests_response.go model_synthetics_location.go model_synthetics_locations.go diff --git a/api/v1/datadog/README.md b/api/v1/datadog/README.md index 8f84676f97c..9ac74b90672 100644 --- a/api/v1/datadog/README.md +++ b/api/v1/datadog/README.md @@ -172,8 +172,11 @@ Class | Method | HTTP request | Description *ServiceLevelObjectivesApi* | [**ListSLOs**](docs/ServiceLevelObjectivesApi.md#listslos) | **Get** /api/v1/slo | Search SLOs *ServiceLevelObjectivesApi* | [**UpdateSLO**](docs/ServiceLevelObjectivesApi.md#updateslo) | **Put** /api/v1/slo/{slo_id} | Update a SLO *SnapshotsApi* | [**GetGraphSnapshot**](docs/SnapshotsApi.md#getgraphsnapshot) | **Get** /api/v1/graph/snapshot | Take graph snapshots +*SyntheticsApi* | [**CreateGlobalVariable**](docs/SyntheticsApi.md#createglobalvariable) | **Post** /api/v1/synthetics/variables | Create a global variable *SyntheticsApi* | [**CreateTest**](docs/SyntheticsApi.md#createtest) | **Post** /api/v1/synthetics/tests | Create a test +*SyntheticsApi* | [**DeleteGlobalVariable**](docs/SyntheticsApi.md#deleteglobalvariable) | **Delete** /api/v1/synthetics/variables/{variable_id} | Delete a global variable *SyntheticsApi* | [**DeleteTests**](docs/SyntheticsApi.md#deletetests) | **Post** /api/v1/synthetics/tests/delete | Delete tests +*SyntheticsApi* | [**EditGlobalVariable**](docs/SyntheticsApi.md#editglobalvariable) | **Put** /api/v1/synthetics/variables/{variable_id} | Edit a global variable *SyntheticsApi* | [**GetAPITestLatestResults**](docs/SyntheticsApi.md#getapitestlatestresults) | **Get** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API) *SyntheticsApi* | [**GetAPITestResult**](docs/SyntheticsApi.md#getapitestresult) | **Get** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API) *SyntheticsApi* | [**GetBrowserTest**](docs/SyntheticsApi.md#getbrowsertest) | **Get** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser) @@ -478,6 +481,8 @@ Class | Method | HTTP request | Description - [SyntheticsErrorCode](docs/SyntheticsErrorCode.md) - [SyntheticsGetAPITestLatestResultsResponse](docs/SyntheticsGetAPITestLatestResultsResponse.md) - [SyntheticsGetBrowserTestLatestResultsResponse](docs/SyntheticsGetBrowserTestLatestResultsResponse.md) + - [SyntheticsGlobalVariable](docs/SyntheticsGlobalVariable.md) + - [SyntheticsGlobalVariableValue](docs/SyntheticsGlobalVariableValue.md) - [SyntheticsListTestsResponse](docs/SyntheticsListTestsResponse.md) - [SyntheticsLocation](docs/SyntheticsLocation.md) - [SyntheticsLocations](docs/SyntheticsLocations.md) diff --git a/api/v1/datadog/api/openapi.yaml b/api/v1/datadog/api/openapi.yaml index f81a8ea89a0..a2d4264b1b1 100644 --- a/api/v1/datadog/api/openapi.yaml +++ b/api/v1/datadog/api/openapi.yaml @@ -5038,6 +5038,119 @@ paths: tags: - Synthetics x-codegen-request-body-name: body + /api/v1/synthetics/variables: + post: + description: Create a Synthetics global variable. + operationId: CreateGlobalVariable + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + description: Details of the global variable to create. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Invalid request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + summary: Create a global variable + tags: + - Synthetics + x-codegen-request-body-name: body + /api/v1/synthetics/variables/{variable_id}: + delete: + description: Delete a Synthetics global variable. + operationId: DeleteGlobalVariable + parameters: + - description: The ID of the global variable. + explode: false + in: path + name: variable_id + required: true + schema: + type: string + style: simple + responses: + "200": + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: JSON format is wrong + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + summary: Delete a global variable + tags: + - Synthetics + put: + description: Edit a Synthetics global variable. + operationId: EditGlobalVariable + parameters: + - description: The ID of the global variable. + explode: false + in: path + name: variable_id + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + description: Details of the global variable to update. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsGlobalVariable' + description: OK + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Invalid request + "403": + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + summary: Edit a global variable + tags: + - Synthetics + x-codegen-request-body-name: body /api/v1/tags/hosts: get: description: Return a mapping of tags to hosts for your whole infrastructure. @@ -13323,6 +13436,57 @@ components: $ref: '#/components/schemas/SyntheticsBrowserTestResultShort' type: array type: object + SyntheticsGlobalVariable: + description: Synthetics global variable. + example: + name: name + description: description + id: id + value: + secure: true + value: value + tags: + - tags + - tags + properties: + description: + description: Description of the global variable. + type: string + id: + description: Unique identifier of the global variable. + readOnly: true + type: string + name: + description: Name of the global variable. + type: string + tags: + description: Tags of the global variable. + items: + description: Tag name. + type: string + type: array + value: + $ref: '#/components/schemas/SyntheticsGlobalVariableValue' + required: + - description + - name + - tags + - value + type: object + SyntheticsGlobalVariableValue: + description: Value of the global variable. + example: + secure: true + value: value + properties: + secure: + description: Determines if the variable is secure. + type: boolean + value: + description: Value of the global variable. + type: string + required: + - value SyntheticsListTestsResponse: description: Object containing an array of Synthetic tests configuration. example: diff --git a/api/v1/datadog/api_synthetics.go b/api/v1/datadog/api_synthetics.go index f22e8b1187d..2c88cda5f9e 100644 --- a/api/v1/datadog/api_synthetics.go +++ b/api/v1/datadog/api_synthetics.go @@ -25,6 +25,165 @@ var ( // SyntheticsApiService SyntheticsApi service type SyntheticsApiService service +type apiCreateGlobalVariableRequest struct { + ctx _context.Context + apiService *SyntheticsApiService + body *SyntheticsGlobalVariable +} + +func (r apiCreateGlobalVariableRequest) Body(body SyntheticsGlobalVariable) apiCreateGlobalVariableRequest { + r.body = &body + return r +} + +/* +CreateGlobalVariable Create a global variable +Create a Synthetics global variable. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). +@return apiCreateGlobalVariableRequest +*/ +func (a *SyntheticsApiService) CreateGlobalVariable(ctx _context.Context) apiCreateGlobalVariableRequest { + return apiCreateGlobalVariableRequest{ + apiService: a, + ctx: ctx, + } +} + +/* +Execute executes the request + @return SyntheticsGlobalVariable +*/ +func (r apiCreateGlobalVariableRequest) Execute() (SyntheticsGlobalVariable, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SyntheticsGlobalVariable + ) + + localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "SyntheticsApiService.CreateGlobalVariable") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/synthetics/variables" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + + // Set Operation-ID header for telemetry + localVarHeaderParams["DD-OPERATION-ID"] = "CreateGlobalVariable" + + // body params + localVarPostBody = r.body + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["apiKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-API-KEY"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["appKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-APPLICATION-KEY"] = key + } + } + } + req, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := r.apiService.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = r.apiService.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type apiCreateTestRequest struct { ctx _context.Context apiService *SyntheticsApiService @@ -194,6 +353,157 @@ func (r apiCreateTestRequest) Execute() (SyntheticsTestDetails, *_nethttp.Respon return localVarReturnValue, localVarHTTPResponse, nil } +type apiDeleteGlobalVariableRequest struct { + ctx _context.Context + apiService *SyntheticsApiService + variableId string +} + +/* +DeleteGlobalVariable Delete a global variable +Delete a Synthetics global variable. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param variableId The ID of the global variable. +@return apiDeleteGlobalVariableRequest +*/ +func (a *SyntheticsApiService) DeleteGlobalVariable(ctx _context.Context, variableId string) apiDeleteGlobalVariableRequest { + return apiDeleteGlobalVariableRequest{ + apiService: a, + ctx: ctx, + variableId: variableId, + } +} + +/* +Execute executes the request + +*/ +func (r apiDeleteGlobalVariableRequest) Execute() (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + ) + + localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "SyntheticsApiService.DeleteGlobalVariable") + if err != nil { + return nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/synthetics/variables/{variable_id}" + localVarPath = strings.Replace(localVarPath, "{"+"variable_id"+"}", _neturl.PathEscape(parameterToString(r.variableId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + + // Set Operation-ID header for telemetry + localVarHeaderParams["DD-OPERATION-ID"] = "DeleteGlobalVariable" + + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["apiKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-API-KEY"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["appKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-APPLICATION-KEY"] = key + } + } + } + req, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := r.apiService.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.model = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 404 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.model = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + type apiDeleteTestsRequest struct { ctx _context.Context apiService *SyntheticsApiService @@ -363,6 +673,169 @@ func (r apiDeleteTestsRequest) Execute() (SyntheticsDeleteTestsResponse, *_netht return localVarReturnValue, localVarHTTPResponse, nil } +type apiEditGlobalVariableRequest struct { + ctx _context.Context + apiService *SyntheticsApiService + variableId string + body *SyntheticsGlobalVariable +} + +func (r apiEditGlobalVariableRequest) Body(body SyntheticsGlobalVariable) apiEditGlobalVariableRequest { + r.body = &body + return r +} + +/* +EditGlobalVariable Edit a global variable +Edit a Synthetics global variable. + * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param variableId The ID of the global variable. +@return apiEditGlobalVariableRequest +*/ +func (a *SyntheticsApiService) EditGlobalVariable(ctx _context.Context, variableId string) apiEditGlobalVariableRequest { + return apiEditGlobalVariableRequest{ + apiService: a, + ctx: ctx, + variableId: variableId, + } +} + +/* +Execute executes the request + @return SyntheticsGlobalVariable +*/ +func (r apiEditGlobalVariableRequest) Execute() (SyntheticsGlobalVariable, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue SyntheticsGlobalVariable + ) + + localBasePath, err := r.apiService.client.cfg.ServerURLWithContext(r.ctx, "SyntheticsApiService.EditGlobalVariable") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/synthetics/variables/{variable_id}" + localVarPath = strings.Replace(localVarPath, "{"+"variable_id"+"}", _neturl.PathEscape(parameterToString(r.variableId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + + if r.body == nil { + return localVarReturnValue, nil, reportError("body is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + + // Set Operation-ID header for telemetry + localVarHeaderParams["DD-OPERATION-ID"] = "EditGlobalVariable" + + // body params + localVarPostBody = r.body + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["apiKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-API-KEY"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if auth, ok := auth["appKeyAuth"]; ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["DD-APPLICATION-KEY"] = key + } + } + } + req, err := r.apiService.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := r.apiService.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 403 { + var v APIErrorResponse + err = r.apiService.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = r.apiService.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type apiGetAPITestLatestResultsRequest struct { ctx _context.Context apiService *SyntheticsApiService diff --git a/api/v1/datadog/docs/SyntheticsApi.md b/api/v1/datadog/docs/SyntheticsApi.md index ead34d9c663..4a5658c7221 100644 --- a/api/v1/datadog/docs/SyntheticsApi.md +++ b/api/v1/datadog/docs/SyntheticsApi.md @@ -4,8 +4,11 @@ All URIs are relative to *https://api.datadoghq.com* Method | HTTP request | Description ------------- | ------------- | ------------- +[**CreateGlobalVariable**](SyntheticsApi.md#CreateGlobalVariable) | **Post** /api/v1/synthetics/variables | Create a global variable [**CreateTest**](SyntheticsApi.md#CreateTest) | **Post** /api/v1/synthetics/tests | Create a test +[**DeleteGlobalVariable**](SyntheticsApi.md#DeleteGlobalVariable) | **Delete** /api/v1/synthetics/variables/{variable_id} | Delete a global variable [**DeleteTests**](SyntheticsApi.md#DeleteTests) | **Post** /api/v1/synthetics/tests/delete | Delete tests +[**EditGlobalVariable**](SyntheticsApi.md#EditGlobalVariable) | **Put** /api/v1/synthetics/variables/{variable_id} | Edit a global variable [**GetAPITestLatestResults**](SyntheticsApi.md#GetAPITestLatestResults) | **Get** /api/v1/synthetics/tests/{public_id}/results | Get the test's latest results summaries (API) [**GetAPITestResult**](SyntheticsApi.md#GetAPITestResult) | **Get** /api/v1/synthetics/tests/{public_id}/results/{result_id} | Get a test result (API) [**GetBrowserTest**](SyntheticsApi.md#GetBrowserTest) | **Get** /api/v1/synthetics/tests/browser/{public_id} | Get a test configuration (browser) @@ -19,6 +22,85 @@ Method | HTTP request | Description +## CreateGlobalVariable + +> SyntheticsGlobalVariable CreateGlobalVariable(ctx).Body(body).Execute() + +Create a global variable + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := context.WithValue( + context.Background(), + datadog.ContextAPIKeys, + map[string]datadog.APIKey{ + "apiKeyAuth": { + Key: os.Getenv("DD_CLIENT_API_KEY"), + }, + "appKeyAuth": { + Key: os.Getenv("DD_CLIENT_APP_KEY"), + }, + }, + ) + + body := datadog.SyntheticsGlobalVariable{Description: "Description_example", Id: "Id_example", Name: "Name_example", Tags: []string{"Tags_example"), Value: datadog.SyntheticsGlobalVariableValue{Secure: false, Value: "Value_example"}} // SyntheticsGlobalVariable | Details of the global variable to create. + + configuration := datadog.NewConfiguration() + api_client := datadog.NewAPIClient(configuration) + resp, r, err := api_client.SyntheticsApi.CreateGlobalVariable(ctx, body).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateGlobalVariable``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `CreateGlobalVariable`: SyntheticsGlobalVariable + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateGlobalVariable`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiCreateGlobalVariableRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**SyntheticsGlobalVariable**](SyntheticsGlobalVariable.md) | Details of the global variable to create. | + +### Return type + +[**SyntheticsGlobalVariable**](SyntheticsGlobalVariable.md) + +### Authorization + +[apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## CreateTest > SyntheticsTestDetails CreateTest(ctx).Body(body).Execute() @@ -98,6 +180,87 @@ Name | Type | Description | Notes [[Back to README]](../README.md) +## DeleteGlobalVariable + +> DeleteGlobalVariable(ctx, variableId).Execute() + +Delete a global variable + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := context.WithValue( + context.Background(), + datadog.ContextAPIKeys, + map[string]datadog.APIKey{ + "apiKeyAuth": { + Key: os.Getenv("DD_CLIENT_API_KEY"), + }, + "appKeyAuth": { + Key: os.Getenv("DD_CLIENT_APP_KEY"), + }, + }, + ) + + variableId := "variableId_example" // string | The ID of the global variable. + + configuration := datadog.NewConfiguration() + api_client := datadog.NewAPIClient(configuration) + resp, r, err := api_client.SyntheticsApi.DeleteGlobalVariable(ctx, variableId).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteGlobalVariable``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**variableId** | **string** | The ID of the global variable. | + +### Other Parameters + +Other parameters are passed through a pointer to a apiDeleteGlobalVariableRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + +### Return type + + (empty response body) + +### Authorization + +[apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## DeleteTests > SyntheticsDeleteTestsResponse DeleteTests(ctx).Body(body).Execute() @@ -177,6 +340,91 @@ Name | Type | Description | Notes [[Back to README]](../README.md) +## EditGlobalVariable + +> SyntheticsGlobalVariable EditGlobalVariable(ctx, variableId).Body(body).Execute() + +Edit a global variable + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := context.WithValue( + context.Background(), + datadog.ContextAPIKeys, + map[string]datadog.APIKey{ + "apiKeyAuth": { + Key: os.Getenv("DD_CLIENT_API_KEY"), + }, + "appKeyAuth": { + Key: os.Getenv("DD_CLIENT_APP_KEY"), + }, + }, + ) + + variableId := "variableId_example" // string | The ID of the global variable. + body := datadog.SyntheticsGlobalVariable{Description: "Description_example", Id: "Id_example", Name: "Name_example", Tags: []string{"Tags_example"), Value: datadog.SyntheticsGlobalVariableValue{Secure: false, Value: "Value_example"}} // SyntheticsGlobalVariable | Details of the global variable to update. + + configuration := datadog.NewConfiguration() + api_client := datadog.NewAPIClient(configuration) + resp, r, err := api_client.SyntheticsApi.EditGlobalVariable(ctx, variableId, body).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.EditGlobalVariable``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `EditGlobalVariable`: SyntheticsGlobalVariable + fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.EditGlobalVariable`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**variableId** | **string** | The ID of the global variable. | + +### Other Parameters + +Other parameters are passed through a pointer to a apiEditGlobalVariableRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **body** | [**SyntheticsGlobalVariable**](SyntheticsGlobalVariable.md) | Details of the global variable to update. | + +### Return type + +[**SyntheticsGlobalVariable**](SyntheticsGlobalVariable.md) + +### Authorization + +[apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## GetAPITestLatestResults > SyntheticsGetAPITestLatestResultsResponse GetAPITestLatestResults(ctx, publicId).FromTs(fromTs).ToTs(toTs).ProbeDc(probeDc).Execute() diff --git a/api/v1/datadog/docs/SyntheticsGlobalVariable.md b/api/v1/datadog/docs/SyntheticsGlobalVariable.md new file mode 100644 index 00000000000..a5b612a7801 --- /dev/null +++ b/api/v1/datadog/docs/SyntheticsGlobalVariable.md @@ -0,0 +1,140 @@ +# SyntheticsGlobalVariable + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Description** | **string** | Description of the global variable. | +**Id** | Pointer to **string** | Unique identifier of the global variable. | [optional] [readonly] +**Name** | **string** | Name of the global variable. | +**Tags** | **[]string** | Tags of the global variable. | +**Value** | [**SyntheticsGlobalVariableValue**](SyntheticsGlobalVariableValue.md) | | + +## Methods + +### NewSyntheticsGlobalVariable + +`func NewSyntheticsGlobalVariable(description string, name string, tags []string, value SyntheticsGlobalVariableValue, ) *SyntheticsGlobalVariable` + +NewSyntheticsGlobalVariable instantiates a new SyntheticsGlobalVariable 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 + +### NewSyntheticsGlobalVariableWithDefaults + +`func NewSyntheticsGlobalVariableWithDefaults() *SyntheticsGlobalVariable` + +NewSyntheticsGlobalVariableWithDefaults instantiates a new SyntheticsGlobalVariable 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 + +### GetDescription + +`func (o *SyntheticsGlobalVariable) GetDescription() string` + +GetDescription returns the Description field if non-nil, zero value otherwise. + +### GetDescriptionOk + +`func (o *SyntheticsGlobalVariable) GetDescriptionOk() (*string, bool)` + +GetDescriptionOk returns a tuple with the Description field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDescription + +`func (o *SyntheticsGlobalVariable) SetDescription(v string)` + +SetDescription sets Description field to given value. + + +### GetId + +`func (o *SyntheticsGlobalVariable) GetId() string` + +GetId returns the Id field if non-nil, zero value otherwise. + +### GetIdOk + +`func (o *SyntheticsGlobalVariable) GetIdOk() (*string, bool)` + +GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetId + +`func (o *SyntheticsGlobalVariable) SetId(v string)` + +SetId sets Id field to given value. + +### HasId + +`func (o *SyntheticsGlobalVariable) HasId() bool` + +HasId returns a boolean if a field has been set. + +### GetName + +`func (o *SyntheticsGlobalVariable) GetName() string` + +GetName returns the Name field if non-nil, zero value otherwise. + +### GetNameOk + +`func (o *SyntheticsGlobalVariable) GetNameOk() (*string, bool)` + +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetName + +`func (o *SyntheticsGlobalVariable) SetName(v string)` + +SetName sets Name field to given value. + + +### GetTags + +`func (o *SyntheticsGlobalVariable) GetTags() []string` + +GetTags returns the Tags field if non-nil, zero value otherwise. + +### GetTagsOk + +`func (o *SyntheticsGlobalVariable) GetTagsOk() (*[]string, bool)` + +GetTagsOk returns a tuple with the Tags field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTags + +`func (o *SyntheticsGlobalVariable) SetTags(v []string)` + +SetTags sets Tags field to given value. + + +### GetValue + +`func (o *SyntheticsGlobalVariable) GetValue() SyntheticsGlobalVariableValue` + +GetValue returns the Value field if non-nil, zero value otherwise. + +### GetValueOk + +`func (o *SyntheticsGlobalVariable) GetValueOk() (*SyntheticsGlobalVariableValue, bool)` + +GetValueOk returns a tuple with the Value field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetValue + +`func (o *SyntheticsGlobalVariable) SetValue(v SyntheticsGlobalVariableValue)` + +SetValue sets Value field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/SyntheticsGlobalVariableValue.md b/api/v1/datadog/docs/SyntheticsGlobalVariableValue.md new file mode 100644 index 00000000000..6e66983efa9 --- /dev/null +++ b/api/v1/datadog/docs/SyntheticsGlobalVariableValue.md @@ -0,0 +1,77 @@ +# SyntheticsGlobalVariableValue + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Secure** | Pointer to **bool** | Determines if the variable is secure. | [optional] +**Value** | **string** | Value of the global variable. | + +## Methods + +### NewSyntheticsGlobalVariableValue + +`func NewSyntheticsGlobalVariableValue(value string, ) *SyntheticsGlobalVariableValue` + +NewSyntheticsGlobalVariableValue instantiates a new SyntheticsGlobalVariableValue 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 + +### NewSyntheticsGlobalVariableValueWithDefaults + +`func NewSyntheticsGlobalVariableValueWithDefaults() *SyntheticsGlobalVariableValue` + +NewSyntheticsGlobalVariableValueWithDefaults instantiates a new SyntheticsGlobalVariableValue 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 + +### GetSecure + +`func (o *SyntheticsGlobalVariableValue) GetSecure() bool` + +GetSecure returns the Secure field if non-nil, zero value otherwise. + +### GetSecureOk + +`func (o *SyntheticsGlobalVariableValue) GetSecureOk() (*bool, bool)` + +GetSecureOk returns a tuple with the Secure field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSecure + +`func (o *SyntheticsGlobalVariableValue) SetSecure(v bool)` + +SetSecure sets Secure field to given value. + +### HasSecure + +`func (o *SyntheticsGlobalVariableValue) HasSecure() bool` + +HasSecure returns a boolean if a field has been set. + +### GetValue + +`func (o *SyntheticsGlobalVariableValue) GetValue() string` + +GetValue returns the Value field if non-nil, zero value otherwise. + +### GetValueOk + +`func (o *SyntheticsGlobalVariableValue) GetValueOk() (*string, bool)` + +GetValueOk returns a tuple with the Value field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetValue + +`func (o *SyntheticsGlobalVariableValue) SetValue(v string)` + +SetValue sets Value field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/model_synthetics_global_variable.go b/api/v1/datadog/model_synthetics_global_variable.go new file mode 100644 index 00000000000..61283181135 --- /dev/null +++ b/api/v1/datadog/model_synthetics_global_variable.go @@ -0,0 +1,231 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" +) + +// SyntheticsGlobalVariable Synthetics global variable. +type SyntheticsGlobalVariable struct { + // Description of the global variable. + Description string `json:"description"` + // Unique identifier of the global variable. + Id *string `json:"id,omitempty"` + // Name of the global variable. + Name string `json:"name"` + // Tags of the global variable. + Tags []string `json:"tags"` + Value SyntheticsGlobalVariableValue `json:"value"` +} + +// NewSyntheticsGlobalVariable instantiates a new SyntheticsGlobalVariable 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 NewSyntheticsGlobalVariable(description string, name string, tags []string, value SyntheticsGlobalVariableValue) *SyntheticsGlobalVariable { + this := SyntheticsGlobalVariable{} + this.Description = description + this.Name = name + this.Tags = tags + this.Value = value + return &this +} + +// NewSyntheticsGlobalVariableWithDefaults instantiates a new SyntheticsGlobalVariable 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 NewSyntheticsGlobalVariableWithDefaults() *SyntheticsGlobalVariable { + this := SyntheticsGlobalVariable{} + return &this +} + +// GetDescription returns the Description field value +func (o *SyntheticsGlobalVariable) GetDescription() string { + if o == nil { + var ret string + return ret + } + + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value +func (o *SyntheticsGlobalVariable) SetDescription(v string) { + o.Description = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariable) 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 *SyntheticsGlobalVariable) 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 *SyntheticsGlobalVariable) HasId() bool { + if o != nil && o.Id != nil { + return true + } + + return false +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *SyntheticsGlobalVariable) SetId(v string) { + o.Id = &v +} + +// GetName returns the Name field value +func (o *SyntheticsGlobalVariable) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *SyntheticsGlobalVariable) SetName(v string) { + o.Name = v +} + +// GetTags returns the Tags field value +func (o *SyntheticsGlobalVariable) GetTags() []string { + if o == nil { + var ret []string + return ret + } + + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetTagsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value +func (o *SyntheticsGlobalVariable) SetTags(v []string) { + o.Tags = v +} + +// GetValue returns the Value field value +func (o *SyntheticsGlobalVariable) GetValue() SyntheticsGlobalVariableValue { + if o == nil { + var ret SyntheticsGlobalVariableValue + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariable) GetValueOk() (*SyntheticsGlobalVariableValue, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value +func (o *SyntheticsGlobalVariable) SetValue(v SyntheticsGlobalVariableValue) { + o.Value = v +} + +func (o SyntheticsGlobalVariable) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["description"] = o.Description + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if true { + toSerialize["name"] = o.Name + } + if true { + toSerialize["tags"] = o.Tags + } + if true { + toSerialize["value"] = o.Value + } + return json.Marshal(toSerialize) +} + +type NullableSyntheticsGlobalVariable struct { + value *SyntheticsGlobalVariable + isSet bool +} + +func (v NullableSyntheticsGlobalVariable) Get() *SyntheticsGlobalVariable { + return v.value +} + +func (v *NullableSyntheticsGlobalVariable) Set(val *SyntheticsGlobalVariable) { + v.value = val + v.isSet = true +} + +func (v NullableSyntheticsGlobalVariable) IsSet() bool { + return v.isSet +} + +func (v *NullableSyntheticsGlobalVariable) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSyntheticsGlobalVariable(val *SyntheticsGlobalVariable) *NullableSyntheticsGlobalVariable { + return &NullableSyntheticsGlobalVariable{value: val, isSet: true} +} + +func (v NullableSyntheticsGlobalVariable) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSyntheticsGlobalVariable) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/v1/datadog/model_synthetics_global_variable_value.go b/api/v1/datadog/model_synthetics_global_variable_value.go new file mode 100644 index 00000000000..087f30d841e --- /dev/null +++ b/api/v1/datadog/model_synthetics_global_variable_value.go @@ -0,0 +1,142 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" +) + +// SyntheticsGlobalVariableValue Value of the global variable. +type SyntheticsGlobalVariableValue struct { + // Determines if the variable is secure. + Secure *bool `json:"secure,omitempty"` + // Value of the global variable. + Value string `json:"value"` +} + +// NewSyntheticsGlobalVariableValue instantiates a new SyntheticsGlobalVariableValue 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 NewSyntheticsGlobalVariableValue(value string) *SyntheticsGlobalVariableValue { + this := SyntheticsGlobalVariableValue{} + this.Value = value + return &this +} + +// NewSyntheticsGlobalVariableValueWithDefaults instantiates a new SyntheticsGlobalVariableValue 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 NewSyntheticsGlobalVariableValueWithDefaults() *SyntheticsGlobalVariableValue { + this := SyntheticsGlobalVariableValue{} + return &this +} + +// GetSecure returns the Secure field value if set, zero value otherwise. +func (o *SyntheticsGlobalVariableValue) GetSecure() bool { + if o == nil || o.Secure == nil { + var ret bool + return ret + } + return *o.Secure +} + +// GetSecureOk returns a tuple with the Secure field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableValue) GetSecureOk() (*bool, bool) { + if o == nil || o.Secure == nil { + return nil, false + } + return o.Secure, true +} + +// HasSecure returns a boolean if a field has been set. +func (o *SyntheticsGlobalVariableValue) HasSecure() bool { + if o != nil && o.Secure != nil { + return true + } + + return false +} + +// SetSecure gets a reference to the given bool and assigns it to the Secure field. +func (o *SyntheticsGlobalVariableValue) SetSecure(v bool) { + o.Secure = &v +} + +// GetValue returns the Value field value +func (o *SyntheticsGlobalVariableValue) GetValue() string { + if o == nil { + var ret string + return ret + } + + return o.Value +} + +// GetValueOk returns a tuple with the Value field value +// and a boolean to check if the value has been set. +func (o *SyntheticsGlobalVariableValue) GetValueOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Value, true +} + +// SetValue sets field value +func (o *SyntheticsGlobalVariableValue) SetValue(v string) { + o.Value = v +} + +func (o SyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.Secure != nil { + toSerialize["secure"] = o.Secure + } + if true { + toSerialize["value"] = o.Value + } + return json.Marshal(toSerialize) +} + +type NullableSyntheticsGlobalVariableValue struct { + value *SyntheticsGlobalVariableValue + isSet bool +} + +func (v NullableSyntheticsGlobalVariableValue) Get() *SyntheticsGlobalVariableValue { + return v.value +} + +func (v *NullableSyntheticsGlobalVariableValue) Set(val *SyntheticsGlobalVariableValue) { + v.value = val + v.isSet = true +} + +func (v NullableSyntheticsGlobalVariableValue) IsSet() bool { + return v.isSet +} + +func (v *NullableSyntheticsGlobalVariableValue) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSyntheticsGlobalVariableValue(val *SyntheticsGlobalVariableValue) *NullableSyntheticsGlobalVariableValue { + return &NullableSyntheticsGlobalVariableValue{value: val, isSet: true} +} + +func (v NullableSyntheticsGlobalVariableValue) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSyntheticsGlobalVariableValue) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/tests/api/v1/datadog/api_synthetics_test.go b/tests/api/v1/datadog/api_synthetics_test.go index 9c978f0c782..273ebc84ce2 100644 --- a/tests/api/v1/datadog/api_synthetics_test.go +++ b/tests/api/v1/datadog/api_synthetics_test.go @@ -13,6 +13,7 @@ import ( "io/ioutil" "log" "path/filepath" + "strings" "testing" "github.com/DataDog/datadog-api-client-go/tests" @@ -78,7 +79,7 @@ func getTestSyntheticsAPI(ctx context.Context, t *testing.T) datadog.SyntheticsT } } -func getTestSyntheticsSubtypeTcpAPI(ctx context.Context, t *testing.T) datadog.SyntheticsTestDetails { +func getTestSyntheticsSubtypeTCPAPI(ctx context.Context, t *testing.T) datadog.SyntheticsTestDetails { assertion2000 := datadog.NewSyntheticsAssertionTarget(datadog.SYNTHETICSASSERTIONOPERATOR_LESS_THAN, datadog.SYNTHETICSASSERTIONTYPE_RESPONSE_TIME) assertion2000.SetTarget(target2000) @@ -259,7 +260,7 @@ func TestSyntheticsSubtypeTcpAPITestLifecycle(t *testing.T) { assert := tests.Assert(ctx, t) // Create API test - testSyntheticsAPI := getTestSyntheticsSubtypeTcpAPI(ctx, t) + testSyntheticsAPI := getTestSyntheticsSubtypeTCPAPI(ctx, t) synt, httpresp, err := Client(ctx).SyntheticsApi.CreateTest(ctx).Body(testSyntheticsAPI).Execute() if err != nil { t.Fatalf("Error creating Synthetics test %v: Response %s: %v", testSyntheticsAPI, err.(datadog.GenericOpenAPIError).Body(), err) @@ -1000,3 +1001,47 @@ func TestSyntheticsListLocations(t *testing.T) { assert.Equal(httpresp.StatusCode, 200) assert.Greater(len(locs.GetLocations()), 0) } + +func TestSyntheticsVariableLifecycle(t *testing.T) { + ctx, finish := WithRecorder(WithTestAuth(context.Background()), t) + defer finish() + assert := tests.Assert(ctx, t) + + variable := datadog.SyntheticsGlobalVariable{ + Name: strings.Replace(strings.ToUpper(*tests.UniqueEntityName(ctx, t)), "-", "_", -1), + Description: "variable description", + Tags: []string{"synthetics"}, + Value: datadog.SyntheticsGlobalVariableValue{ + Secure: datadog.PtrBool(false), + Value: "VARIABLE_VALUE", + }, + } + + // Create variable + result, httpresp, err := Client(ctx).SyntheticsApi.CreateGlobalVariable(ctx).Body(variable).Execute() + + if err != nil { + t.Fatalf("Error creating Synthetics global variable %v: Response %s: %v", variable, err.(datadog.GenericOpenAPIError).Body(), err) + } + assert.Equal(200, httpresp.StatusCode) + assert.Equal(result.GetName(), variable.GetName()) + + // Edit variable + updatedName := fmt.Sprintf("%s_UPDATED", variable.GetName()) + variable.SetName(updatedName) + + result, httpresp, err = Client(ctx).SyntheticsApi.EditGlobalVariable(ctx, result.GetId()).Body(variable).Execute() + + if err != nil { + t.Fatalf("Error editing Synthetics global variable %v: Response %s: %v", variable, err.(datadog.GenericOpenAPIError).Body(), err) + } + assert.Equal(200, httpresp.StatusCode) + assert.Equal(result.GetName(), updatedName) + + // Delete variable + httpresp, err = Client(ctx).SyntheticsApi.DeleteGlobalVariable(ctx, result.GetId()).Execute() + if err != nil { + t.Fatalf("Error deleting Synthetics global variable %s: Response %s: %v", result.GetId(), err.(datadog.GenericOpenAPIError).Body(), err) + } + assert.Equal(200, httpresp.StatusCode) +} diff --git a/tests/api/v1/datadog/cassettes/TestSyntheticsDeleteVariable.yaml b/tests/api/v1/datadog/cassettes/TestSyntheticsDeleteVariable.yaml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.freeze b/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.freeze new file mode 100644 index 00000000000..bd428f7d7a0 --- /dev/null +++ b/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.freeze @@ -0,0 +1 @@ +2020-07-31T10:43:14.970487+02:00 \ No newline at end of file diff --git a/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.yaml b/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.yaml new file mode 100644 index 00000000000..16d1963be87 --- /dev/null +++ b/tests/api/v1/datadog/cassettes/TestSyntheticsVariableLifecycle.yaml @@ -0,0 +1,186 @@ +--- +version: 1 +interactions: +- request: + body: | + {"description":"variable description","name":"GO_TESTSYNTHETICSVARIABLELIFECYCLE_LOCAL_1596184994","tags":["synthetics"],"value":{"secure":false,"value":"VARIABLE_VALUE"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Dd-Operation-Id: + - CreateGlobalVariable + User-Agent: + - datadog-api-client-go/1.0.0-beta.8+dev (go go1.14.4; os darwin; arch amd64) + X-Datadog-Parent-Id: + - "8158679655415957407" + X-Datadog-Sampling-Priority: + - "1" + X-Datadog-Trace-Id: + - "6494845629360570831" + url: https://api.datadoghq.com/api/v1/synthetics/variables + method: POST + response: + body: '{"parse_test_extracted_at":null,"description":"variable description","tags":["synthetics"],"parse_test_public_id":null,"value":{"secure":false,"value":"VARIABLE_VALUE"},"id":"262a9e5c-c24f-47ce-b297-6a8679dc3f72","parse_test_options":null,"name":"GO_TESTSYNTHETICSVARIABLELIFECYCLE_LOCAL_1596184994","parse_test_name":null,"type":"variable"}' + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 31 Jul 2020 08:43:15 GMT + Dd-Pool: + - dogweb + Pragma: + - no-cache + Set-Cookie: + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Fri, 07-Aug-2020 08:43:15 GMT; + secure; HttpOnly + Strict-Transport-Security: + - max-age=15724800; + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Dd-Debug: + - hwI1xW1jobFHf2zp84DCOIiyi35zogyeJRd8i6KVEP/Mns/VANCoCRbonvlZZK0p + X-Dd-Version: + - "35.2814607" + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: + - "120" + X-Ratelimit-Period: + - "60" + X-Ratelimit-Remaining: + - "119" + X-Ratelimit-Reset: + - "45" + status: 200 OK + code: 200 + duration: "" +- request: + body: | + {"description":"variable description","name":"GO_TESTSYNTHETICSVARIABLELIFECYCLE_LOCAL_1596184994_UPDATED","tags":["synthetics"],"value":{"secure":false,"value":"VARIABLE_VALUE"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + Dd-Operation-Id: + - EditGlobalVariable + User-Agent: + - datadog-api-client-go/1.0.0-beta.8+dev (go go1.14.4; os darwin; arch amd64) + X-Datadog-Parent-Id: + - "3180178749687594301" + X-Datadog-Sampling-Priority: + - "1" + X-Datadog-Trace-Id: + - "6494845629360570831" + url: https://api.datadoghq.com/api/v1/synthetics/variables/262a9e5c-c24f-47ce-b297-6a8679dc3f72 + method: PUT + response: + body: '{"parse_test_extracted_at":null,"description":"variable description","tags":["synthetics"],"parse_test_public_id":null,"value":{"secure":false,"value":"VARIABLE_VALUE"},"id":"262a9e5c-c24f-47ce-b297-6a8679dc3f72","parse_test_options":null,"name":"GO_TESTSYNTHETICSVARIABLELIFECYCLE_LOCAL_1596184994_UPDATED","parse_test_name":null,"type":"variable"}' + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Type: + - application/json + Date: + - Fri, 31 Jul 2020 08:43:17 GMT + Dd-Pool: + - dogweb + Pragma: + - no-cache + Set-Cookie: + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Fri, 07-Aug-2020 08:43:16 GMT; + secure; HttpOnly + Strict-Transport-Security: + - max-age=15724800; + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Dd-Debug: + - zw3H8Hey+52s9gMQUk5aX4H++lHod0yST44vKRHh+Exv0+QWEPkaiIz7lGsCmogE + X-Dd-Version: + - "35.2814607" + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: + - "120" + X-Ratelimit-Period: + - "60" + X-Ratelimit-Remaining: + - "119" + X-Ratelimit-Reset: + - "44" + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + Dd-Operation-Id: + - DeleteGlobalVariable + User-Agent: + - datadog-api-client-go/1.0.0-beta.8+dev (go go1.14.4; os darwin; arch amd64) + X-Datadog-Parent-Id: + - "2098816966672422588" + X-Datadog-Sampling-Priority: + - "1" + X-Datadog-Trace-Id: + - "6494845629360570831" + url: https://api.datadoghq.com/api/v1/synthetics/variables/262a9e5c-c24f-47ce-b297-6a8679dc3f72 + method: DELETE + response: + body: "null" + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive + Content-Length: + - "4" + Content-Type: + - application/json + Date: + - Fri, 31 Jul 2020 08:43:17 GMT + Dd-Pool: + - dogweb + Pragma: + - no-cache + Set-Cookie: + - DD-PSHARD=233; Max-Age=604800; Path=/; expires=Fri, 07-Aug-2020 08:43:17 GMT; + secure; HttpOnly + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff + X-Dd-Debug: + - WY3vIdiOXNyg7XF0Xh2NOOYLSFLJiBmrjkeeQH86Obm8qQp3jOT59l8QZqA/Phcr + X-Dd-Version: + - "35.2814607" + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: + - "120" + X-Ratelimit-Period: + - "60" + X-Ratelimit-Remaining: + - "119" + X-Ratelimit-Reset: + - "43" + status: 200 OK + code: 200 + duration: "" diff --git a/tests/api/v1/datadog/features/synthetics.feature b/tests/api/v1/datadog/features/synthetics.feature index cf27112068c..f237526e3c3 100644 --- a/tests/api/v1/datadog/features/synthetics.feature +++ b/tests/api/v1/datadog/features/synthetics.feature @@ -100,3 +100,25 @@ Feature: Synthetics And body {} When the request is sent Then the response status is 200 OK - Returns a boolean indicating if the update was successful. + + @generated @skip + Scenario: Delete a global variable returns "OK" response + Given new "DeleteGlobalVariable" request + And request contains "variable_id" parameter from "" + When the request is sent + Then the response status is 200 OK + + @generated @skip + Scenario: Edit a global variable returns "OK" response + Given new "EditGlobalVariable" request + And request contains "variable_id" parameter from "" + And body {} + When the request is sent + Then the response status is 200 OK + + @generated @skip + Scenario: Create a global variable returns "OK" response + Given new "CreateGlobalVariable" request + And body {} + When the request is sent + Then the response status is 200 OK