From f2bc198164f5bcef6c318427dbccff3e11df4869 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, 20 Jan 2023 15:19:12 +0000 Subject: [PATCH] Add support for Fastly account API (#1750) Co-authored-by: ci.datadog-api-spec --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 495 ++++++++ api/datadogV2/api_fastly_integration.go | 1009 +++++++++++++++++ api/datadogV2/doc.go | 10 + ...model_fastly_accoun_response_attributes.go | 138 +++ .../model_fastly_account_create_request.go | 110 ++ ...astly_account_create_request_attributes.go | 171 +++ ...odel_fastly_account_create_request_data.go | 153 +++ .../model_fastly_account_response.go | 105 ++ .../model_fastly_account_response_data.go | 186 +++ api/datadogV2/model_fastly_account_type.go | 107 ++ .../model_fastly_account_update_request.go | 110 ++ ...astly_account_update_request_attributes.go | 98 ++ ...odel_fastly_account_update_request_data.go | 152 +++ .../model_fastly_accounts_response.go | 98 ++ api/datadogV2/model_fastly_service.go | 138 +++ .../model_fastly_service_attributes.go | 98 ++ api/datadogV2/model_fastly_service_data.go | 188 +++ api/datadogV2/model_fastly_service_request.go | 110 ++ .../model_fastly_service_response.go | 105 ++ api/datadogV2/model_fastly_service_type.go | 107 ++ .../model_fastly_services_response.go | 98 ++ .../fastly-integration/CreateFastlyAccount.go | 39 + .../fastly-integration/CreateFastlyService.go | 41 + .../fastly-integration/DeleteFastlyAccount.go | 25 + .../fastly-integration/DeleteFastlyService.go | 25 + .../v2/fastly-integration/GetFastlyAccount.go | 32 + .../v2/fastly-integration/GetFastlyService.go | 29 + .../fastly-integration/ListFastlyAccounts.go | 29 + .../fastly-integration/ListFastlyServices.go | 29 + .../fastly-integration/UpdateFastlyAccount.go | 40 + .../fastly-integration/UpdateFastlyService.go | 41 + tests/scenarios/api_mappings.go | 1 + ...ly_account_returns_CREATED_response.freeze | 1 + ...stly_account_returns_CREATED_response.yaml | 39 + ..._Fastly_account_returns_OK_response.freeze | 1 + ...et_Fastly_account_returns_OK_response.yaml | 57 + ...Fastly_accounts_returns_OK_response.freeze | 1 + ...t_Fastly_accounts_returns_OK_response.yaml | 57 + ..._Fastly_account_returns_OK_response.freeze | 1 + ...te_Fastly_account_returns_OK_response.yaml | 60 + .../features/v2/fastly_integration.feature | 238 ++++ tests/scenarios/features/v2/given.json | 12 + tests/scenarios/features/v2/undo.json | 74 ++ 44 files changed, 4662 insertions(+), 4 deletions(-) create mode 100644 api/datadogV2/api_fastly_integration.go create mode 100644 api/datadogV2/model_fastly_accoun_response_attributes.go create mode 100644 api/datadogV2/model_fastly_account_create_request.go create mode 100644 api/datadogV2/model_fastly_account_create_request_attributes.go create mode 100644 api/datadogV2/model_fastly_account_create_request_data.go create mode 100644 api/datadogV2/model_fastly_account_response.go create mode 100644 api/datadogV2/model_fastly_account_response_data.go create mode 100644 api/datadogV2/model_fastly_account_type.go create mode 100644 api/datadogV2/model_fastly_account_update_request.go create mode 100644 api/datadogV2/model_fastly_account_update_request_attributes.go create mode 100644 api/datadogV2/model_fastly_account_update_request_data.go create mode 100644 api/datadogV2/model_fastly_accounts_response.go create mode 100644 api/datadogV2/model_fastly_service.go create mode 100644 api/datadogV2/model_fastly_service_attributes.go create mode 100644 api/datadogV2/model_fastly_service_data.go create mode 100644 api/datadogV2/model_fastly_service_request.go create mode 100644 api/datadogV2/model_fastly_service_response.go create mode 100644 api/datadogV2/model_fastly_service_type.go create mode 100644 api/datadogV2/model_fastly_services_response.go create mode 100644 examples/v2/fastly-integration/CreateFastlyAccount.go create mode 100644 examples/v2/fastly-integration/CreateFastlyService.go create mode 100644 examples/v2/fastly-integration/DeleteFastlyAccount.go create mode 100644 examples/v2/fastly-integration/DeleteFastlyService.go create mode 100644 examples/v2/fastly-integration/GetFastlyAccount.go create mode 100644 examples/v2/fastly-integration/GetFastlyService.go create mode 100644 examples/v2/fastly-integration/ListFastlyAccounts.go create mode 100644 examples/v2/fastly-integration/ListFastlyServices.go create mode 100644 examples/v2/fastly-integration/UpdateFastlyAccount.go create mode 100644 examples/v2/fastly-integration/UpdateFastlyService.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.yaml create mode 100644 tests/scenarios/features/v2/fastly_integration.feature diff --git a/.apigentools-info b/.apigentools-info index a9436370a10..78215dda926 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-01-19 18:19:43.469415", - "spec_repo_commit": "6cb19a59" + "regenerated": "2023-01-20 15:00:23.592736", + "spec_repo_commit": "8dc3510b" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-01-19 18:19:43.486426", - "spec_repo_commit": "6cb19a59" + "regenerated": "2023-01-20 15:00:23.604471", + "spec_repo_commit": "8dc3510b" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9286d5ea996..2c9bf7c4143 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -159,6 +159,20 @@ components: required: true schema: type: string + FastlyAccountID: + description: Fastly Account id. + in: path + name: account_id + required: true + schema: + type: string + FastlyServiceID: + description: Fastly Service ID. + in: path + name: service_id + required: true + schema: + type: string IncidentAttachmentFilterQueryParameter: description: Specifies which types of attachments are included in the response. explode: false @@ -3316,6 +3330,201 @@ components: from the other indexes. type: string type: object + FastlyAccounResponseAttributes: + description: Attributes object of a Fastly account. + properties: + name: + description: The name of the Fastly account. + example: test-name + type: string + services: + description: A list of services belonging to the parent account. + items: + $ref: '#/components/schemas/FastlyService' + type: array + required: + - name + type: object + FastlyAccountCreateRequest: + description: Payload schema when adding a Fastly account. + properties: + data: + $ref: '#/components/schemas/FastlyAccountCreateRequestData' + required: + - data + type: object + FastlyAccountCreateRequestAttributes: + description: Attributes object for creating a Fastly account. + properties: + api_key: + description: The API key for the Fastly account. + example: ABCDEFG123 + type: string + name: + description: The name of the Fastly account. + example: test-name + type: string + services: + description: A list of services belonging to the parent account. + items: + $ref: '#/components/schemas/FastlyService' + type: array + required: + - api_key + - name + type: object + FastlyAccountCreateRequestData: + description: Data object for creating a Fastly account. + properties: + attributes: + $ref: '#/components/schemas/FastlyAccountCreateRequestAttributes' + type: + $ref: '#/components/schemas/FastlyAccountType' + required: + - attributes + - type + type: object + FastlyAccountResponse: + description: The expected response schema when getting a Fastly account. + properties: + data: + $ref: '#/components/schemas/FastlyAccountResponseData' + type: object + FastlyAccountResponseData: + description: Data object of a Fastly account. + properties: + attributes: + $ref: '#/components/schemas/FastlyAccounResponseAttributes' + id: + description: The ID of the Fastly account, a hash of the account name. + example: abc123 + type: string + type: + $ref: '#/components/schemas/FastlyAccountType' + required: + - attributes + - id + - type + type: object + FastlyAccountType: + default: fastly-accounts + description: The JSON:API type for this API. Should always be `fastly-accounts`. + enum: + - fastly-accounts + example: fastly-accounts + type: string + x-enum-varnames: + - FASTLY_ACCOUNTS + FastlyAccountUpdateRequest: + description: Payload schema when updating a Fastly account. + properties: + data: + $ref: '#/components/schemas/FastlyAccountUpdateRequestData' + required: + - data + type: object + FastlyAccountUpdateRequestAttributes: + description: Attributes object for updating a Fastly account. + properties: + api_key: + description: The API key of the Fastly account. + example: ABCDEFG123 + type: string + type: object + FastlyAccountUpdateRequestData: + description: Data object for updating a Fastly account. + properties: + attributes: + $ref: '#/components/schemas/FastlyAccountUpdateRequestAttributes' + type: + $ref: '#/components/schemas/FastlyAccountType' + type: object + FastlyAccountsResponse: + description: The expected response schema when getting Fastly accounts. + properties: + data: + description: The JSON:API data schema. + items: + $ref: '#/components/schemas/FastlyAccountResponseData' + type: array + type: object + FastlyService: + description: The schema representation of a Fastly service. + properties: + id: + description: The id of the Fastly service + example: 6abc7de6893AbcDe9fghIj + type: string + tags: + description: A list of tags for the Fastly service. + example: + - myTag + - myTag2:myValue + items: + type: string + type: array + required: + - id + type: object + FastlyServiceAttributes: + description: Attributes object for Fastly service requests. + properties: + tags: + description: A list of tags for the Fastly service. + example: + - myTag + - myTag2:myValue + items: + type: string + type: array + type: object + FastlyServiceData: + description: Data object for Fastly service requests. + properties: + attributes: + $ref: '#/components/schemas/FastlyServiceAttributes' + id: + description: The ID of the Fastly service. + example: abc123 + type: string + type: + $ref: '#/components/schemas/FastlyServiceType' + required: + - id + - type + type: object + FastlyServiceRequest: + description: Payload schema for Fastly service requests. + properties: + data: + $ref: '#/components/schemas/FastlyServiceData' + required: + - data + type: object + FastlyServiceResponse: + description: The expected response schema when getting a Fastly service. + properties: + data: + $ref: '#/components/schemas/FastlyServiceData' + type: object + FastlyServiceType: + default: fastly-services + description: The JSON:API type for this API. Should always be `fastly-services`. + enum: + - fastly-services + example: fastly-services + type: string + x-enum-varnames: + - FASTLY_SERVICES + FastlyServicesResponse: + description: The expected response schema when getting Fastly services. + properties: + data: + description: The JSON:API data schema. + items: + $ref: '#/components/schemas/FastlyServiceResponse' + type: array + type: object FormulaLimit: description: Message for specifying limits to the number of values returned by a query. @@ -14350,6 +14559,289 @@ paths: operator: OR permissions: - STANDARD + /api/v2/integrations/fastly/accounts: + get: + description: List Fastly accounts. + operationId: ListFastlyAccounts + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List Fastly accounts + tags: + - Fastly Integration + post: + description: Create a Fastly account. + operationId: CreateFastlyAccount + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountResponse' + description: CREATED + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Add Fastly account + tags: + - Fastly Integration + x-codegen-request-body-name: body + /api/v2/integrations/fastly/accounts/{account_id}: + delete: + description: Delete a Fastly account. + operationId: DeleteFastlyAccount + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete Fastly account + tags: + - Fastly Integration + get: + description: Get a Fastly account. + operationId: GetFastlyAccount + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get Fastly account + tags: + - Fastly Integration + patch: + description: Update a Fastly account. + operationId: UpdateFastlyAccount + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyAccountResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update Fastly account + tags: + - Fastly Integration + x-codegen-request-body-name: body + /api/v2/integrations/fastly/accounts/{account_id}/services: + get: + description: List Fastly services for an account. + operationId: ListFastlyServices + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServicesResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: List Fastly services + tags: + - Fastly Integration + post: + description: Create a Fastly service for an account. + operationId: CreateFastlyService + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServiceRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServiceResponse' + description: CREATED + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Add Fastly service + tags: + - Fastly Integration + x-codegen-request-body-name: body + /api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}: + delete: + description: Delete a Fastly service for an account. + operationId: DeleteFastlyService + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + - $ref: '#/components/parameters/FastlyServiceID' + responses: + '204': + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete Fastly service + tags: + - Fastly Integration + get: + description: Get a Fastly service for an account. + operationId: GetFastlyService + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + - $ref: '#/components/parameters/FastlyServiceID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServiceResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get Fastly service + tags: + - Fastly Integration + patch: + description: Update a Fastly service for an account. + operationId: UpdateFastlyService + parameters: + - $ref: '#/components/parameters/FastlyAccountID' + - $ref: '#/components/parameters/FastlyServiceID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServiceRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FastlyServiceResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update Fastly service + tags: + - Fastly Integration + x-codegen-request-body-name: body /api/v2/logs: post: description: 'Send your logs to your Datadog platform over HTTP. Limits per @@ -19766,6 +20258,9 @@ tags: first 4000 characters are displayed.' name: Events +- description: Configure your Datadog Fastly integration directly through the Datadog + API. + name: Fastly Integration - description: Create, update, delete, and retrieve services which can be associated with incidents. name: Incident Services diff --git a/api/datadogV2/api_fastly_integration.go b/api/datadogV2/api_fastly_integration.go new file mode 100644 index 00000000000..b5d0a5cc67e --- /dev/null +++ b/api/datadogV2/api_fastly_integration.go @@ -0,0 +1,1009 @@ +// 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 ( + "bytes" + _context "context" + _io "io" + _nethttp "net/http" + _neturl "net/url" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FastlyIntegrationApi service type +type FastlyIntegrationApi datadog.Service + +type apiCreateFastlyAccountRequest struct { + ctx _context.Context + body *FastlyAccountCreateRequest +} + +func (a *FastlyIntegrationApi) buildCreateFastlyAccountRequest(ctx _context.Context, body FastlyAccountCreateRequest) (apiCreateFastlyAccountRequest, error) { + req := apiCreateFastlyAccountRequest{ + ctx: ctx, + body: &body, + } + return req, nil +} + +// CreateFastlyAccount Add Fastly account. +// Create a Fastly account. +func (a *FastlyIntegrationApi) CreateFastlyAccount(ctx _context.Context, body FastlyAccountCreateRequest) (FastlyAccountResponse, *_nethttp.Response, error) { + req, err := a.buildCreateFastlyAccountRequest(ctx, body) + if err != nil { + var localVarReturnValue FastlyAccountResponse + return localVarReturnValue, nil, err + } + + return a.createFastlyAccountExecute(req) +} + +// createFastlyAccountExecute executes the request. +func (a *FastlyIntegrationApi) createFastlyAccountExecute(r apiCreateFastlyAccountRequest) (FastlyAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue FastlyAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.CreateFastlyAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiCreateFastlyServiceRequest struct { + ctx _context.Context + accountId string + body *FastlyServiceRequest +} + +func (a *FastlyIntegrationApi) buildCreateFastlyServiceRequest(ctx _context.Context, accountId string, body FastlyServiceRequest) (apiCreateFastlyServiceRequest, error) { + req := apiCreateFastlyServiceRequest{ + ctx: ctx, + accountId: accountId, + body: &body, + } + return req, nil +} + +// CreateFastlyService Add Fastly service. +// Create a Fastly service for an account. +func (a *FastlyIntegrationApi) CreateFastlyService(ctx _context.Context, accountId string, body FastlyServiceRequest) (FastlyServiceResponse, *_nethttp.Response, error) { + req, err := a.buildCreateFastlyServiceRequest(ctx, accountId, body) + if err != nil { + var localVarReturnValue FastlyServiceResponse + return localVarReturnValue, nil, err + } + + return a.createFastlyServiceExecute(req) +} + +// createFastlyServiceExecute executes the request. +func (a *FastlyIntegrationApi) createFastlyServiceExecute(r apiCreateFastlyServiceRequest) (FastlyServiceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue FastlyServiceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.CreateFastlyService") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}/services" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiDeleteFastlyAccountRequest struct { + ctx _context.Context + accountId string +} + +func (a *FastlyIntegrationApi) buildDeleteFastlyAccountRequest(ctx _context.Context, accountId string) (apiDeleteFastlyAccountRequest, error) { + req := apiDeleteFastlyAccountRequest{ + ctx: ctx, + accountId: accountId, + } + return req, nil +} + +// DeleteFastlyAccount Delete Fastly account. +// Delete a Fastly account. +func (a *FastlyIntegrationApi) DeleteFastlyAccount(ctx _context.Context, accountId string) (*_nethttp.Response, error) { + req, err := a.buildDeleteFastlyAccountRequest(ctx, accountId) + if err != nil { + return nil, err + } + + return a.deleteFastlyAccountExecute(req) +} + +// deleteFastlyAccountExecute executes the request. +func (a *FastlyIntegrationApi) deleteFastlyAccountExecute(r apiDeleteFastlyAccountRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.DeleteFastlyAccount") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return 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 localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type apiDeleteFastlyServiceRequest struct { + ctx _context.Context + accountId string + serviceId string +} + +func (a *FastlyIntegrationApi) buildDeleteFastlyServiceRequest(ctx _context.Context, accountId string, serviceId string) (apiDeleteFastlyServiceRequest, error) { + req := apiDeleteFastlyServiceRequest{ + ctx: ctx, + accountId: accountId, + serviceId: serviceId, + } + return req, nil +} + +// DeleteFastlyService Delete Fastly service. +// Delete a Fastly service for an account. +func (a *FastlyIntegrationApi) DeleteFastlyService(ctx _context.Context, accountId string, serviceId string) (*_nethttp.Response, error) { + req, err := a.buildDeleteFastlyServiceRequest(ctx, accountId, serviceId) + if err != nil { + return nil, err + } + + return a.deleteFastlyServiceExecute(req) +} + +// deleteFastlyServiceExecute executes the request. +func (a *FastlyIntegrationApi) deleteFastlyServiceExecute(r apiDeleteFastlyServiceRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.DeleteFastlyService") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"service_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.serviceId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return 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 localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +type apiGetFastlyAccountRequest struct { + ctx _context.Context + accountId string +} + +func (a *FastlyIntegrationApi) buildGetFastlyAccountRequest(ctx _context.Context, accountId string) (apiGetFastlyAccountRequest, error) { + req := apiGetFastlyAccountRequest{ + ctx: ctx, + accountId: accountId, + } + return req, nil +} + +// GetFastlyAccount Get Fastly account. +// Get a Fastly account. +func (a *FastlyIntegrationApi) GetFastlyAccount(ctx _context.Context, accountId string) (FastlyAccountResponse, *_nethttp.Response, error) { + req, err := a.buildGetFastlyAccountRequest(ctx, accountId) + if err != nil { + var localVarReturnValue FastlyAccountResponse + return localVarReturnValue, nil, err + } + + return a.getFastlyAccountExecute(req) +} + +// getFastlyAccountExecute executes the request. +func (a *FastlyIntegrationApi) getFastlyAccountExecute(r apiGetFastlyAccountRequest) (FastlyAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FastlyAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.GetFastlyAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiGetFastlyServiceRequest struct { + ctx _context.Context + accountId string + serviceId string +} + +func (a *FastlyIntegrationApi) buildGetFastlyServiceRequest(ctx _context.Context, accountId string, serviceId string) (apiGetFastlyServiceRequest, error) { + req := apiGetFastlyServiceRequest{ + ctx: ctx, + accountId: accountId, + serviceId: serviceId, + } + return req, nil +} + +// GetFastlyService Get Fastly service. +// Get a Fastly service for an account. +func (a *FastlyIntegrationApi) GetFastlyService(ctx _context.Context, accountId string, serviceId string) (FastlyServiceResponse, *_nethttp.Response, error) { + req, err := a.buildGetFastlyServiceRequest(ctx, accountId, serviceId) + if err != nil { + var localVarReturnValue FastlyServiceResponse + return localVarReturnValue, nil, err + } + + return a.getFastlyServiceExecute(req) +} + +// getFastlyServiceExecute executes the request. +func (a *FastlyIntegrationApi) getFastlyServiceExecute(r apiGetFastlyServiceRequest) (FastlyServiceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FastlyServiceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.GetFastlyService") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"service_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.serviceId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiListFastlyAccountsRequest struct { + ctx _context.Context +} + +func (a *FastlyIntegrationApi) buildListFastlyAccountsRequest(ctx _context.Context) (apiListFastlyAccountsRequest, error) { + req := apiListFastlyAccountsRequest{ + ctx: ctx, + } + return req, nil +} + +// ListFastlyAccounts List Fastly accounts. +// List Fastly accounts. +func (a *FastlyIntegrationApi) ListFastlyAccounts(ctx _context.Context) (FastlyAccountsResponse, *_nethttp.Response, error) { + req, err := a.buildListFastlyAccountsRequest(ctx) + if err != nil { + var localVarReturnValue FastlyAccountsResponse + return localVarReturnValue, nil, err + } + + return a.listFastlyAccountsExecute(req) +} + +// listFastlyAccountsExecute executes the request. +func (a *FastlyIntegrationApi) listFastlyAccountsExecute(r apiListFastlyAccountsRequest) (FastlyAccountsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FastlyAccountsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.ListFastlyAccounts") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiListFastlyServicesRequest struct { + ctx _context.Context + accountId string +} + +func (a *FastlyIntegrationApi) buildListFastlyServicesRequest(ctx _context.Context, accountId string) (apiListFastlyServicesRequest, error) { + req := apiListFastlyServicesRequest{ + ctx: ctx, + accountId: accountId, + } + return req, nil +} + +// ListFastlyServices List Fastly services. +// List Fastly services for an account. +func (a *FastlyIntegrationApi) ListFastlyServices(ctx _context.Context, accountId string) (FastlyServicesResponse, *_nethttp.Response, error) { + req, err := a.buildListFastlyServicesRequest(ctx, accountId) + if err != nil { + var localVarReturnValue FastlyServicesResponse + return localVarReturnValue, nil, err + } + + return a.listFastlyServicesExecute(req) +} + +// listFastlyServicesExecute executes the request. +func (a *FastlyIntegrationApi) listFastlyServicesExecute(r apiListFastlyServicesRequest) (FastlyServicesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FastlyServicesResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.ListFastlyServices") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}/services" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiUpdateFastlyAccountRequest struct { + ctx _context.Context + accountId string + body *FastlyAccountUpdateRequest +} + +func (a *FastlyIntegrationApi) buildUpdateFastlyAccountRequest(ctx _context.Context, accountId string, body FastlyAccountUpdateRequest) (apiUpdateFastlyAccountRequest, error) { + req := apiUpdateFastlyAccountRequest{ + ctx: ctx, + accountId: accountId, + body: &body, + } + return req, nil +} + +// UpdateFastlyAccount Update Fastly account. +// Update a Fastly account. +func (a *FastlyIntegrationApi) UpdateFastlyAccount(ctx _context.Context, accountId string, body FastlyAccountUpdateRequest) (FastlyAccountResponse, *_nethttp.Response, error) { + req, err := a.buildUpdateFastlyAccountRequest(ctx, accountId, body) + if err != nil { + var localVarReturnValue FastlyAccountResponse + return localVarReturnValue, nil, err + } + + return a.updateFastlyAccountExecute(req) +} + +// updateFastlyAccountExecute executes the request. +func (a *FastlyIntegrationApi) updateFastlyAccountExecute(r apiUpdateFastlyAccountRequest) (FastlyAccountResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue FastlyAccountResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.UpdateFastlyAccount") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +type apiUpdateFastlyServiceRequest struct { + ctx _context.Context + accountId string + serviceId string + body *FastlyServiceRequest +} + +func (a *FastlyIntegrationApi) buildUpdateFastlyServiceRequest(ctx _context.Context, accountId string, serviceId string, body FastlyServiceRequest) (apiUpdateFastlyServiceRequest, error) { + req := apiUpdateFastlyServiceRequest{ + ctx: ctx, + accountId: accountId, + serviceId: serviceId, + body: &body, + } + return req, nil +} + +// UpdateFastlyService Update Fastly service. +// Update a Fastly service for an account. +func (a *FastlyIntegrationApi) UpdateFastlyService(ctx _context.Context, accountId string, serviceId string, body FastlyServiceRequest) (FastlyServiceResponse, *_nethttp.Response, error) { + req, err := a.buildUpdateFastlyServiceRequest(ctx, accountId, serviceId, body) + if err != nil { + var localVarReturnValue FastlyServiceResponse + return localVarReturnValue, nil, err + } + + return a.updateFastlyServiceExecute(req) +} + +// updateFastlyServiceExecute executes the request. +func (a *FastlyIntegrationApi) updateFastlyServiceExecute(r apiUpdateFastlyServiceRequest) (FastlyServiceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue FastlyServiceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.FastlyIntegrationApi.UpdateFastlyService") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}" + localVarPath = strings.Replace(localVarPath, "{"+"account_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.accountId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"service_id"+"}", _neturl.PathEscape(datadog.ParameterToString(r.serviceId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.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 := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + 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 +} + +// NewFastlyIntegrationApi Returns NewFastlyIntegrationApi. +func NewFastlyIntegrationApi(client *datadog.APIClient) *FastlyIntegrationApi { + return &FastlyIntegrationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 409a0d70aa3..3896ac3772d 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -43,6 +43,16 @@ // - [DashboardListsApi.UpdateDashboardListItems] // - [EventsApi.ListEvents] // - [EventsApi.SearchEvents] +// - [FastlyIntegrationApi.CreateFastlyAccount] +// - [FastlyIntegrationApi.CreateFastlyService] +// - [FastlyIntegrationApi.DeleteFastlyAccount] +// - [FastlyIntegrationApi.DeleteFastlyService] +// - [FastlyIntegrationApi.GetFastlyAccount] +// - [FastlyIntegrationApi.GetFastlyService] +// - [FastlyIntegrationApi.ListFastlyAccounts] +// - [FastlyIntegrationApi.ListFastlyServices] +// - [FastlyIntegrationApi.UpdateFastlyAccount] +// - [FastlyIntegrationApi.UpdateFastlyService] // - [IncidentServicesApi.CreateIncidentService] // - [IncidentServicesApi.DeleteIncidentService] // - [IncidentServicesApi.GetIncidentService] diff --git a/api/datadogV2/model_fastly_accoun_response_attributes.go b/api/datadogV2/model_fastly_accoun_response_attributes.go new file mode 100644 index 00000000000..4901e050e0c --- /dev/null +++ b/api/datadogV2/model_fastly_accoun_response_attributes.go @@ -0,0 +1,138 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyAccounResponseAttributes Attributes object of a Fastly account. +type FastlyAccounResponseAttributes struct { + // The name of the Fastly account. + Name string `json:"name"` + // A list of services belonging to the parent account. + Services []FastlyService `json:"services,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{} +} + +// NewFastlyAccounResponseAttributes instantiates a new FastlyAccounResponseAttributes 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 NewFastlyAccounResponseAttributes(name string) *FastlyAccounResponseAttributes { + this := FastlyAccounResponseAttributes{} + this.Name = name + return &this +} + +// NewFastlyAccounResponseAttributesWithDefaults instantiates a new FastlyAccounResponseAttributes 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 NewFastlyAccounResponseAttributesWithDefaults() *FastlyAccounResponseAttributes { + this := FastlyAccounResponseAttributes{} + return &this +} + +// GetName returns the Name field value. +func (o *FastlyAccounResponseAttributes) 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 *FastlyAccounResponseAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *FastlyAccounResponseAttributes) SetName(v string) { + o.Name = v +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *FastlyAccounResponseAttributes) GetServices() []FastlyService { + if o == nil || o.Services == nil { + var ret []FastlyService + return ret + } + return o.Services +} + +// GetServicesOk returns a tuple with the Services field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FastlyAccounResponseAttributes) GetServicesOk() (*[]FastlyService, bool) { + if o == nil || o.Services == nil { + return nil, false + } + return &o.Services, true +} + +// HasServices returns a boolean if a field has been set. +func (o *FastlyAccounResponseAttributes) HasServices() bool { + return o != nil && o.Services != nil +} + +// SetServices gets a reference to the given []FastlyService and assigns it to the Services field. +func (o *FastlyAccounResponseAttributes) SetServices(v []FastlyService) { + o.Services = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccounResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + if o.Services != nil { + toSerialize["services"] = o.Services + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccounResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Name *string `json:"name"` + }{} + all := struct { + Name string `json:"name"` + Services []FastlyService `json:"services,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Name == nil { + return fmt.Errorf("required field name missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Name = all.Name + o.Services = all.Services + return nil +} diff --git a/api/datadogV2/model_fastly_account_create_request.go b/api/datadogV2/model_fastly_account_create_request.go new file mode 100644 index 00000000000..d9754d2f4e4 --- /dev/null +++ b/api/datadogV2/model_fastly_account_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// FastlyAccountCreateRequest Payload schema when adding a Fastly account. +type FastlyAccountCreateRequest struct { + // Data object for creating a Fastly account. + Data FastlyAccountCreateRequestData `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{} +} + +// NewFastlyAccountCreateRequest instantiates a new FastlyAccountCreateRequest 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 NewFastlyAccountCreateRequest(data FastlyAccountCreateRequestData) *FastlyAccountCreateRequest { + this := FastlyAccountCreateRequest{} + this.Data = data + return &this +} + +// NewFastlyAccountCreateRequestWithDefaults instantiates a new FastlyAccountCreateRequest 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 NewFastlyAccountCreateRequestWithDefaults() *FastlyAccountCreateRequest { + this := FastlyAccountCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *FastlyAccountCreateRequest) GetData() FastlyAccountCreateRequestData { + if o == nil { + var ret FastlyAccountCreateRequestData + 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 *FastlyAccountCreateRequest) GetDataOk() (*FastlyAccountCreateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FastlyAccountCreateRequest) SetData(v FastlyAccountCreateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *FastlyAccountCreateRequestData `json:"data"` + }{} + all := struct { + Data FastlyAccountCreateRequestData `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_account_create_request_attributes.go b/api/datadogV2/model_fastly_account_create_request_attributes.go new file mode 100644 index 00000000000..620b699f80e --- /dev/null +++ b/api/datadogV2/model_fastly_account_create_request_attributes.go @@ -0,0 +1,171 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyAccountCreateRequestAttributes Attributes object for creating a Fastly account. +type FastlyAccountCreateRequestAttributes struct { + // The API key for the Fastly account. + ApiKey string `json:"api_key"` + // The name of the Fastly account. + Name string `json:"name"` + // A list of services belonging to the parent account. + Services []FastlyService `json:"services,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{} +} + +// NewFastlyAccountCreateRequestAttributes instantiates a new FastlyAccountCreateRequestAttributes 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 NewFastlyAccountCreateRequestAttributes(apiKey string, name string) *FastlyAccountCreateRequestAttributes { + this := FastlyAccountCreateRequestAttributes{} + this.ApiKey = apiKey + this.Name = name + return &this +} + +// NewFastlyAccountCreateRequestAttributesWithDefaults instantiates a new FastlyAccountCreateRequestAttributes 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 NewFastlyAccountCreateRequestAttributesWithDefaults() *FastlyAccountCreateRequestAttributes { + this := FastlyAccountCreateRequestAttributes{} + return &this +} + +// GetApiKey returns the ApiKey field value. +func (o *FastlyAccountCreateRequestAttributes) GetApiKey() string { + if o == nil { + var ret string + return ret + } + return o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value +// and a boolean to check if the value has been set. +func (o *FastlyAccountCreateRequestAttributes) GetApiKeyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ApiKey, true +} + +// SetApiKey sets field value. +func (o *FastlyAccountCreateRequestAttributes) SetApiKey(v string) { + o.ApiKey = v +} + +// GetName returns the Name field value. +func (o *FastlyAccountCreateRequestAttributes) 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 *FastlyAccountCreateRequestAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *FastlyAccountCreateRequestAttributes) SetName(v string) { + o.Name = v +} + +// GetServices returns the Services field value if set, zero value otherwise. +func (o *FastlyAccountCreateRequestAttributes) GetServices() []FastlyService { + if o == nil || o.Services == nil { + var ret []FastlyService + return ret + } + return o.Services +} + +// GetServicesOk returns a tuple with the Services field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FastlyAccountCreateRequestAttributes) GetServicesOk() (*[]FastlyService, bool) { + if o == nil || o.Services == nil { + return nil, false + } + return &o.Services, true +} + +// HasServices returns a boolean if a field has been set. +func (o *FastlyAccountCreateRequestAttributes) HasServices() bool { + return o != nil && o.Services != nil +} + +// SetServices gets a reference to the given []FastlyService and assigns it to the Services field. +func (o *FastlyAccountCreateRequestAttributes) SetServices(v []FastlyService) { + o.Services = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountCreateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["api_key"] = o.ApiKey + toSerialize["name"] = o.Name + if o.Services != nil { + toSerialize["services"] = o.Services + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + ApiKey *string `json:"api_key"` + Name *string `json:"name"` + }{} + all := struct { + ApiKey string `json:"api_key"` + Name string `json:"name"` + Services []FastlyService `json:"services,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.ApiKey == nil { + return fmt.Errorf("required field api_key missing") + } + if required.Name == nil { + return fmt.Errorf("required field name missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.ApiKey = all.ApiKey + o.Name = all.Name + o.Services = all.Services + return nil +} diff --git a/api/datadogV2/model_fastly_account_create_request_data.go b/api/datadogV2/model_fastly_account_create_request_data.go new file mode 100644 index 00000000000..394730c1a8d --- /dev/null +++ b/api/datadogV2/model_fastly_account_create_request_data.go @@ -0,0 +1,153 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyAccountCreateRequestData Data object for creating a Fastly account. +type FastlyAccountCreateRequestData struct { + // Attributes object for creating a Fastly account. + Attributes FastlyAccountCreateRequestAttributes `json:"attributes"` + // The JSON:API type for this API. Should always be `fastly-accounts`. + Type FastlyAccountType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewFastlyAccountCreateRequestData instantiates a new FastlyAccountCreateRequestData 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 NewFastlyAccountCreateRequestData(attributes FastlyAccountCreateRequestAttributes, typeVar FastlyAccountType) *FastlyAccountCreateRequestData { + this := FastlyAccountCreateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewFastlyAccountCreateRequestDataWithDefaults instantiates a new FastlyAccountCreateRequestData 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 NewFastlyAccountCreateRequestDataWithDefaults() *FastlyAccountCreateRequestData { + this := FastlyAccountCreateRequestData{} + var typeVar FastlyAccountType = FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *FastlyAccountCreateRequestData) GetAttributes() FastlyAccountCreateRequestAttributes { + if o == nil { + var ret FastlyAccountCreateRequestAttributes + 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 *FastlyAccountCreateRequestData) GetAttributesOk() (*FastlyAccountCreateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *FastlyAccountCreateRequestData) SetAttributes(v FastlyAccountCreateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *FastlyAccountCreateRequestData) GetType() FastlyAccountType { + if o == nil { + var ret FastlyAccountType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FastlyAccountCreateRequestData) GetTypeOk() (*FastlyAccountType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FastlyAccountCreateRequestData) SetType(v FastlyAccountType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountCreateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountCreateRequestData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *FastlyAccountCreateRequestAttributes `json:"attributes"` + Type *FastlyAccountType `json:"type"` + }{} + all := struct { + Attributes FastlyAccountCreateRequestAttributes `json:"attributes"` + Type FastlyAccountType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_fastly_account_response.go b/api/datadogV2/model_fastly_account_response.go new file mode 100644 index 00000000000..18893642bcb --- /dev/null +++ b/api/datadogV2/model_fastly_account_response.go @@ -0,0 +1,105 @@ +// 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 ( + "encoding/json" +) + +// FastlyAccountResponse The expected response schema when getting a Fastly account. +type FastlyAccountResponse struct { + // Data object of a Fastly account. + Data *FastlyAccountResponseData `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{} +} + +// NewFastlyAccountResponse instantiates a new FastlyAccountResponse 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 NewFastlyAccountResponse() *FastlyAccountResponse { + this := FastlyAccountResponse{} + return &this +} + +// NewFastlyAccountResponseWithDefaults instantiates a new FastlyAccountResponse 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 NewFastlyAccountResponseWithDefaults() *FastlyAccountResponse { + this := FastlyAccountResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *FastlyAccountResponse) GetData() FastlyAccountResponseData { + if o == nil || o.Data == nil { + var ret FastlyAccountResponseData + 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 *FastlyAccountResponse) GetDataOk() (*FastlyAccountResponseData, 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 *FastlyAccountResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given FastlyAccountResponseData and assigns it to the Data field. +func (o *FastlyAccountResponse) SetData(v FastlyAccountResponseData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *FastlyAccountResponseData `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_account_response_data.go b/api/datadogV2/model_fastly_account_response_data.go new file mode 100644 index 00000000000..63398f4af82 --- /dev/null +++ b/api/datadogV2/model_fastly_account_response_data.go @@ -0,0 +1,186 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyAccountResponseData Data object of a Fastly account. +type FastlyAccountResponseData struct { + // Attributes object of a Fastly account. + Attributes FastlyAccounResponseAttributes `json:"attributes"` + // The ID of the Fastly account, a hash of the account name. + Id string `json:"id"` + // The JSON:API type for this API. Should always be `fastly-accounts`. + Type FastlyAccountType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewFastlyAccountResponseData instantiates a new FastlyAccountResponseData 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 NewFastlyAccountResponseData(attributes FastlyAccounResponseAttributes, id string, typeVar FastlyAccountType) *FastlyAccountResponseData { + this := FastlyAccountResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewFastlyAccountResponseDataWithDefaults instantiates a new FastlyAccountResponseData 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 NewFastlyAccountResponseDataWithDefaults() *FastlyAccountResponseData { + this := FastlyAccountResponseData{} + var typeVar FastlyAccountType = FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *FastlyAccountResponseData) GetAttributes() FastlyAccounResponseAttributes { + if o == nil { + var ret FastlyAccounResponseAttributes + 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 *FastlyAccountResponseData) GetAttributesOk() (*FastlyAccounResponseAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *FastlyAccountResponseData) SetAttributes(v FastlyAccounResponseAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *FastlyAccountResponseData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *FastlyAccountResponseData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *FastlyAccountResponseData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *FastlyAccountResponseData) GetType() FastlyAccountType { + if o == nil { + var ret FastlyAccountType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FastlyAccountResponseData) GetTypeOk() (*FastlyAccountType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FastlyAccountResponseData) SetType(v FastlyAccountType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountResponseData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountResponseData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *FastlyAccounResponseAttributes `json:"attributes"` + Id *string `json:"id"` + Type *FastlyAccountType `json:"type"` + }{} + all := struct { + Attributes FastlyAccounResponseAttributes `json:"attributes"` + Id string `json:"id"` + Type FastlyAccountType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Id == nil { + return fmt.Errorf("required field id missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_fastly_account_type.go b/api/datadogV2/model_fastly_account_type.go new file mode 100644 index 00000000000..672e018c34e --- /dev/null +++ b/api/datadogV2/model_fastly_account_type.go @@ -0,0 +1,107 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyAccountType The JSON:API type for this API. Should always be `fastly-accounts`. +type FastlyAccountType string + +// List of FastlyAccountType. +const ( + FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS FastlyAccountType = "fastly-accounts" +) + +var allowedFastlyAccountTypeEnumValues = []FastlyAccountType{ + FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FastlyAccountType) GetAllowedValues() []FastlyAccountType { + return allowedFastlyAccountTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FastlyAccountType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FastlyAccountType(value) + return nil +} + +// NewFastlyAccountTypeFromValue returns a pointer to a valid FastlyAccountType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFastlyAccountTypeFromValue(v string) (*FastlyAccountType, error) { + ev := FastlyAccountType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FastlyAccountType: valid values are %v", v, allowedFastlyAccountTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FastlyAccountType) IsValid() bool { + for _, existing := range allowedFastlyAccountTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FastlyAccountType value. +func (v FastlyAccountType) Ptr() *FastlyAccountType { + return &v +} + +// NullableFastlyAccountType handles when a null is used for FastlyAccountType. +type NullableFastlyAccountType struct { + value *FastlyAccountType + isSet bool +} + +// Get returns the associated value. +func (v NullableFastlyAccountType) Get() *FastlyAccountType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableFastlyAccountType) Set(val *FastlyAccountType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableFastlyAccountType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableFastlyAccountType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableFastlyAccountType initializes the struct as if Set has been called. +func NewNullableFastlyAccountType(val *FastlyAccountType) *NullableFastlyAccountType { + return &NullableFastlyAccountType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableFastlyAccountType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableFastlyAccountType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_fastly_account_update_request.go b/api/datadogV2/model_fastly_account_update_request.go new file mode 100644 index 00000000000..62a1bc8c540 --- /dev/null +++ b/api/datadogV2/model_fastly_account_update_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 ( + "encoding/json" + "fmt" +) + +// FastlyAccountUpdateRequest Payload schema when updating a Fastly account. +type FastlyAccountUpdateRequest struct { + // Data object for updating a Fastly account. + Data FastlyAccountUpdateRequestData `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{} +} + +// NewFastlyAccountUpdateRequest instantiates a new FastlyAccountUpdateRequest 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 NewFastlyAccountUpdateRequest(data FastlyAccountUpdateRequestData) *FastlyAccountUpdateRequest { + this := FastlyAccountUpdateRequest{} + this.Data = data + return &this +} + +// NewFastlyAccountUpdateRequestWithDefaults instantiates a new FastlyAccountUpdateRequest 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 NewFastlyAccountUpdateRequestWithDefaults() *FastlyAccountUpdateRequest { + this := FastlyAccountUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *FastlyAccountUpdateRequest) GetData() FastlyAccountUpdateRequestData { + if o == nil { + var ret FastlyAccountUpdateRequestData + 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 *FastlyAccountUpdateRequest) GetDataOk() (*FastlyAccountUpdateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FastlyAccountUpdateRequest) SetData(v FastlyAccountUpdateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *FastlyAccountUpdateRequestData `json:"data"` + }{} + all := struct { + Data FastlyAccountUpdateRequestData `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_account_update_request_attributes.go b/api/datadogV2/model_fastly_account_update_request_attributes.go new file mode 100644 index 00000000000..9bc006c58f3 --- /dev/null +++ b/api/datadogV2/model_fastly_account_update_request_attributes.go @@ -0,0 +1,98 @@ +// 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 ( + "encoding/json" +) + +// FastlyAccountUpdateRequestAttributes Attributes object for updating a Fastly account. +type FastlyAccountUpdateRequestAttributes struct { + // The API key of the Fastly account. + ApiKey *string `json:"api_key,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{} +} + +// NewFastlyAccountUpdateRequestAttributes instantiates a new FastlyAccountUpdateRequestAttributes 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 NewFastlyAccountUpdateRequestAttributes() *FastlyAccountUpdateRequestAttributes { + this := FastlyAccountUpdateRequestAttributes{} + return &this +} + +// NewFastlyAccountUpdateRequestAttributesWithDefaults instantiates a new FastlyAccountUpdateRequestAttributes 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 NewFastlyAccountUpdateRequestAttributesWithDefaults() *FastlyAccountUpdateRequestAttributes { + this := FastlyAccountUpdateRequestAttributes{} + return &this +} + +// GetApiKey returns the ApiKey field value if set, zero value otherwise. +func (o *FastlyAccountUpdateRequestAttributes) GetApiKey() string { + if o == nil || o.ApiKey == nil { + var ret string + return ret + } + return *o.ApiKey +} + +// GetApiKeyOk returns a tuple with the ApiKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FastlyAccountUpdateRequestAttributes) GetApiKeyOk() (*string, bool) { + if o == nil || o.ApiKey == nil { + return nil, false + } + return o.ApiKey, true +} + +// HasApiKey returns a boolean if a field has been set. +func (o *FastlyAccountUpdateRequestAttributes) HasApiKey() bool { + return o != nil && o.ApiKey != nil +} + +// SetApiKey gets a reference to the given string and assigns it to the ApiKey field. +func (o *FastlyAccountUpdateRequestAttributes) SetApiKey(v string) { + o.ApiKey = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.ApiKey != nil { + toSerialize["api_key"] = o.ApiKey + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + ApiKey *string `json:"api_key,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.ApiKey = all.ApiKey + return nil +} diff --git a/api/datadogV2/model_fastly_account_update_request_data.go b/api/datadogV2/model_fastly_account_update_request_data.go new file mode 100644 index 00000000000..9650f85b254 --- /dev/null +++ b/api/datadogV2/model_fastly_account_update_request_data.go @@ -0,0 +1,152 @@ +// 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 ( + "encoding/json" +) + +// FastlyAccountUpdateRequestData Data object for updating a Fastly account. +type FastlyAccountUpdateRequestData struct { + // Attributes object for updating a Fastly account. + Attributes *FastlyAccountUpdateRequestAttributes `json:"attributes,omitempty"` + // The JSON:API type for this API. Should always be `fastly-accounts`. + Type *FastlyAccountType `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{} +} + +// NewFastlyAccountUpdateRequestData instantiates a new FastlyAccountUpdateRequestData 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 NewFastlyAccountUpdateRequestData() *FastlyAccountUpdateRequestData { + this := FastlyAccountUpdateRequestData{} + var typeVar FastlyAccountType = FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS + this.Type = &typeVar + return &this +} + +// NewFastlyAccountUpdateRequestDataWithDefaults instantiates a new FastlyAccountUpdateRequestData 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 NewFastlyAccountUpdateRequestDataWithDefaults() *FastlyAccountUpdateRequestData { + this := FastlyAccountUpdateRequestData{} + var typeVar FastlyAccountType = FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *FastlyAccountUpdateRequestData) GetAttributes() FastlyAccountUpdateRequestAttributes { + if o == nil || o.Attributes == nil { + var ret FastlyAccountUpdateRequestAttributes + 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 *FastlyAccountUpdateRequestData) GetAttributesOk() (*FastlyAccountUpdateRequestAttributes, 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 *FastlyAccountUpdateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given FastlyAccountUpdateRequestAttributes and assigns it to the Attributes field. +func (o *FastlyAccountUpdateRequestData) SetAttributes(v FastlyAccountUpdateRequestAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *FastlyAccountUpdateRequestData) GetType() FastlyAccountType { + if o == nil || o.Type == nil { + var ret FastlyAccountType + 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 *FastlyAccountUpdateRequestData) GetTypeOk() (*FastlyAccountType, 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 *FastlyAccountUpdateRequestData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given FastlyAccountType and assigns it to the Type field. +func (o *FastlyAccountUpdateRequestData) SetType(v FastlyAccountType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountUpdateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *FastlyAccountUpdateRequestAttributes `json:"attributes,omitempty"` + Type *FastlyAccountType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_fastly_accounts_response.go b/api/datadogV2/model_fastly_accounts_response.go new file mode 100644 index 00000000000..c6fb222710d --- /dev/null +++ b/api/datadogV2/model_fastly_accounts_response.go @@ -0,0 +1,98 @@ +// 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 ( + "encoding/json" +) + +// FastlyAccountsResponse The expected response schema when getting Fastly accounts. +type FastlyAccountsResponse struct { + // The JSON:API data schema. + Data []FastlyAccountResponseData `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{} +} + +// NewFastlyAccountsResponse instantiates a new FastlyAccountsResponse 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 NewFastlyAccountsResponse() *FastlyAccountsResponse { + this := FastlyAccountsResponse{} + return &this +} + +// NewFastlyAccountsResponseWithDefaults instantiates a new FastlyAccountsResponse 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 NewFastlyAccountsResponseWithDefaults() *FastlyAccountsResponse { + this := FastlyAccountsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *FastlyAccountsResponse) GetData() []FastlyAccountResponseData { + if o == nil || o.Data == nil { + var ret []FastlyAccountResponseData + 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 *FastlyAccountsResponse) GetDataOk() (*[]FastlyAccountResponseData, 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 *FastlyAccountsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []FastlyAccountResponseData and assigns it to the Data field. +func (o *FastlyAccountsResponse) SetData(v []FastlyAccountResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyAccountsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyAccountsResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data []FastlyAccountResponseData `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_service.go b/api/datadogV2/model_fastly_service.go new file mode 100644 index 00000000000..09310f3a989 --- /dev/null +++ b/api/datadogV2/model_fastly_service.go @@ -0,0 +1,138 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyService The schema representation of a Fastly service. +type FastlyService struct { + // The id of the Fastly service + Id string `json:"id"` + // A list of tags for the Fastly service. + Tags []string `json:"tags,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{} +} + +// NewFastlyService instantiates a new FastlyService 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 NewFastlyService(id string) *FastlyService { + this := FastlyService{} + this.Id = id + return &this +} + +// NewFastlyServiceWithDefaults instantiates a new FastlyService 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 NewFastlyServiceWithDefaults() *FastlyService { + this := FastlyService{} + return &this +} + +// GetId returns the Id field value. +func (o *FastlyService) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *FastlyService) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *FastlyService) SetId(v string) { + o.Id = v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *FastlyService) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FastlyService) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *FastlyService) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *FastlyService) SetTags(v []string) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyService) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyService) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Id *string `json:"id"` + }{} + all := struct { + Id string `json:"id"` + Tags []string `json:"tags,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Id == nil { + return fmt.Errorf("required field id missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Id = all.Id + o.Tags = all.Tags + return nil +} diff --git a/api/datadogV2/model_fastly_service_attributes.go b/api/datadogV2/model_fastly_service_attributes.go new file mode 100644 index 00000000000..d70c6c1d0fe --- /dev/null +++ b/api/datadogV2/model_fastly_service_attributes.go @@ -0,0 +1,98 @@ +// 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 ( + "encoding/json" +) + +// FastlyServiceAttributes Attributes object for Fastly service requests. +type FastlyServiceAttributes struct { + // A list of tags for the Fastly service. + Tags []string `json:"tags,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{} +} + +// NewFastlyServiceAttributes instantiates a new FastlyServiceAttributes 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 NewFastlyServiceAttributes() *FastlyServiceAttributes { + this := FastlyServiceAttributes{} + return &this +} + +// NewFastlyServiceAttributesWithDefaults instantiates a new FastlyServiceAttributes 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 NewFastlyServiceAttributesWithDefaults() *FastlyServiceAttributes { + this := FastlyServiceAttributes{} + return &this +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *FastlyServiceAttributes) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FastlyServiceAttributes) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *FastlyServiceAttributes) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *FastlyServiceAttributes) SetTags(v []string) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyServiceAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyServiceAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Tags []string `json:"tags,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Tags = all.Tags + return nil +} diff --git a/api/datadogV2/model_fastly_service_data.go b/api/datadogV2/model_fastly_service_data.go new file mode 100644 index 00000000000..de47adb7fd3 --- /dev/null +++ b/api/datadogV2/model_fastly_service_data.go @@ -0,0 +1,188 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyServiceData Data object for Fastly service requests. +type FastlyServiceData struct { + // Attributes object for Fastly service requests. + Attributes *FastlyServiceAttributes `json:"attributes,omitempty"` + // The ID of the Fastly service. + Id string `json:"id"` + // The JSON:API type for this API. Should always be `fastly-services`. + Type FastlyServiceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewFastlyServiceData instantiates a new FastlyServiceData 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 NewFastlyServiceData(id string, typeVar FastlyServiceType) *FastlyServiceData { + this := FastlyServiceData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewFastlyServiceDataWithDefaults instantiates a new FastlyServiceData 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 NewFastlyServiceDataWithDefaults() *FastlyServiceData { + this := FastlyServiceData{} + var typeVar FastlyServiceType = FASTLYSERVICETYPE_FASTLY_SERVICES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *FastlyServiceData) GetAttributes() FastlyServiceAttributes { + if o == nil || o.Attributes == nil { + var ret FastlyServiceAttributes + 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 *FastlyServiceData) GetAttributesOk() (*FastlyServiceAttributes, 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 *FastlyServiceData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given FastlyServiceAttributes and assigns it to the Attributes field. +func (o *FastlyServiceData) SetAttributes(v FastlyServiceAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value. +func (o *FastlyServiceData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *FastlyServiceData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *FastlyServiceData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *FastlyServiceData) GetType() FastlyServiceType { + if o == nil { + var ret FastlyServiceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FastlyServiceData) GetTypeOk() (*FastlyServiceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FastlyServiceData) SetType(v FastlyServiceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyServiceData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyServiceData) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Id *string `json:"id"` + Type *FastlyServiceType `json:"type"` + }{} + all := struct { + Attributes *FastlyServiceAttributes `json:"attributes,omitempty"` + Id string `json:"id"` + Type FastlyServiceType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Id == nil { + return fmt.Errorf("required field id missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Id = all.Id + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_fastly_service_request.go b/api/datadogV2/model_fastly_service_request.go new file mode 100644 index 00000000000..7c995788381 --- /dev/null +++ b/api/datadogV2/model_fastly_service_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 ( + "encoding/json" + "fmt" +) + +// FastlyServiceRequest Payload schema for Fastly service requests. +type FastlyServiceRequest struct { + // Data object for Fastly service requests. + Data FastlyServiceData `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{} +} + +// NewFastlyServiceRequest instantiates a new FastlyServiceRequest 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 NewFastlyServiceRequest(data FastlyServiceData) *FastlyServiceRequest { + this := FastlyServiceRequest{} + this.Data = data + return &this +} + +// NewFastlyServiceRequestWithDefaults instantiates a new FastlyServiceRequest 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 NewFastlyServiceRequestWithDefaults() *FastlyServiceRequest { + this := FastlyServiceRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *FastlyServiceRequest) GetData() FastlyServiceData { + if o == nil { + var ret FastlyServiceData + 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 *FastlyServiceRequest) GetDataOk() (*FastlyServiceData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FastlyServiceRequest) SetData(v FastlyServiceData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyServiceRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyServiceRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *FastlyServiceData `json:"data"` + }{} + all := struct { + Data FastlyServiceData `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_service_response.go b/api/datadogV2/model_fastly_service_response.go new file mode 100644 index 00000000000..9d3642e2e79 --- /dev/null +++ b/api/datadogV2/model_fastly_service_response.go @@ -0,0 +1,105 @@ +// 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 ( + "encoding/json" +) + +// FastlyServiceResponse The expected response schema when getting a Fastly service. +type FastlyServiceResponse struct { + // Data object for Fastly service requests. + Data *FastlyServiceData `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{} +} + +// NewFastlyServiceResponse instantiates a new FastlyServiceResponse 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 NewFastlyServiceResponse() *FastlyServiceResponse { + this := FastlyServiceResponse{} + return &this +} + +// NewFastlyServiceResponseWithDefaults instantiates a new FastlyServiceResponse 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 NewFastlyServiceResponseWithDefaults() *FastlyServiceResponse { + this := FastlyServiceResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *FastlyServiceResponse) GetData() FastlyServiceData { + if o == nil || o.Data == nil { + var ret FastlyServiceData + 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 *FastlyServiceResponse) GetDataOk() (*FastlyServiceData, 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 *FastlyServiceResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given FastlyServiceData and assigns it to the Data field. +func (o *FastlyServiceResponse) SetData(v FastlyServiceData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyServiceResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyServiceResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *FastlyServiceData `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_fastly_service_type.go b/api/datadogV2/model_fastly_service_type.go new file mode 100644 index 00000000000..8f484660ff4 --- /dev/null +++ b/api/datadogV2/model_fastly_service_type.go @@ -0,0 +1,107 @@ +// 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 ( + "encoding/json" + "fmt" +) + +// FastlyServiceType The JSON:API type for this API. Should always be `fastly-services`. +type FastlyServiceType string + +// List of FastlyServiceType. +const ( + FASTLYSERVICETYPE_FASTLY_SERVICES FastlyServiceType = "fastly-services" +) + +var allowedFastlyServiceTypeEnumValues = []FastlyServiceType{ + FASTLYSERVICETYPE_FASTLY_SERVICES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FastlyServiceType) GetAllowedValues() []FastlyServiceType { + return allowedFastlyServiceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FastlyServiceType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FastlyServiceType(value) + return nil +} + +// NewFastlyServiceTypeFromValue returns a pointer to a valid FastlyServiceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFastlyServiceTypeFromValue(v string) (*FastlyServiceType, error) { + ev := FastlyServiceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FastlyServiceType: valid values are %v", v, allowedFastlyServiceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FastlyServiceType) IsValid() bool { + for _, existing := range allowedFastlyServiceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FastlyServiceType value. +func (v FastlyServiceType) Ptr() *FastlyServiceType { + return &v +} + +// NullableFastlyServiceType handles when a null is used for FastlyServiceType. +type NullableFastlyServiceType struct { + value *FastlyServiceType + isSet bool +} + +// Get returns the associated value. +func (v NullableFastlyServiceType) Get() *FastlyServiceType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableFastlyServiceType) Set(val *FastlyServiceType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableFastlyServiceType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableFastlyServiceType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableFastlyServiceType initializes the struct as if Set has been called. +func NewNullableFastlyServiceType(val *FastlyServiceType) *NullableFastlyServiceType { + return &NullableFastlyServiceType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableFastlyServiceType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableFastlyServiceType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_fastly_services_response.go b/api/datadogV2/model_fastly_services_response.go new file mode 100644 index 00000000000..515676337f9 --- /dev/null +++ b/api/datadogV2/model_fastly_services_response.go @@ -0,0 +1,98 @@ +// 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 ( + "encoding/json" +) + +// FastlyServicesResponse The expected response schema when getting Fastly services. +type FastlyServicesResponse struct { + // The JSON:API data schema. + Data []FastlyServiceResponse `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{} +} + +// NewFastlyServicesResponse instantiates a new FastlyServicesResponse 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 NewFastlyServicesResponse() *FastlyServicesResponse { + this := FastlyServicesResponse{} + return &this +} + +// NewFastlyServicesResponseWithDefaults instantiates a new FastlyServicesResponse 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 NewFastlyServicesResponseWithDefaults() *FastlyServicesResponse { + this := FastlyServicesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *FastlyServicesResponse) GetData() []FastlyServiceResponse { + if o == nil || o.Data == nil { + var ret []FastlyServiceResponse + 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 *FastlyServicesResponse) GetDataOk() (*[]FastlyServiceResponse, 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 *FastlyServicesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []FastlyServiceResponse and assigns it to the Data field. +func (o *FastlyServicesResponse) SetData(v []FastlyServiceResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FastlyServicesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FastlyServicesResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data []FastlyServiceResponse `json:"data,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Data = all.Data + return nil +} diff --git a/examples/v2/fastly-integration/CreateFastlyAccount.go b/examples/v2/fastly-integration/CreateFastlyAccount.go new file mode 100644 index 00000000000..21ef1c89d1d --- /dev/null +++ b/examples/v2/fastly-integration/CreateFastlyAccount.go @@ -0,0 +1,39 @@ +// Add Fastly account returns "CREATED" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.FastlyAccountCreateRequest{ + Data: datadogV2.FastlyAccountCreateRequestData{ + Attributes: datadogV2.FastlyAccountCreateRequestAttributes{ + ApiKey: "ExampleAddFastlyaccountreturnsCREATEDresponse", + Name: "Example-Add_Fastly_account_returns_CREATED_response", + Services: []datadogV2.FastlyService{}, + }, + Type: datadogV2.FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.CreateFastlyAccount(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.CreateFastlyAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.CreateFastlyAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/CreateFastlyService.go b/examples/v2/fastly-integration/CreateFastlyService.go new file mode 100644 index 00000000000..6272b7f3fc6 --- /dev/null +++ b/examples/v2/fastly-integration/CreateFastlyService.go @@ -0,0 +1,41 @@ +// Add Fastly service returns "CREATED" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.FastlyServiceRequest{ + Data: datadogV2.FastlyServiceData{ + Attributes: &datadogV2.FastlyServiceAttributes{ + Tags: []string{ + "myTag", + "myTag2:myValue", + }, + }, + Id: "abc123", + Type: datadogV2.FASTLYSERVICETYPE_FASTLY_SERVICES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.CreateFastlyService(ctx, "account_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.CreateFastlyService`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.CreateFastlyService`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/DeleteFastlyAccount.go b/examples/v2/fastly-integration/DeleteFastlyAccount.go new file mode 100644 index 00000000000..76f7ad49fd7 --- /dev/null +++ b/examples/v2/fastly-integration/DeleteFastlyAccount.go @@ -0,0 +1,25 @@ +// Delete Fastly account 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + r, err := api.DeleteFastlyAccount(ctx, "account_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.DeleteFastlyAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/fastly-integration/DeleteFastlyService.go b/examples/v2/fastly-integration/DeleteFastlyService.go new file mode 100644 index 00000000000..fe93d4eed2d --- /dev/null +++ b/examples/v2/fastly-integration/DeleteFastlyService.go @@ -0,0 +1,25 @@ +// Delete Fastly service 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + r, err := api.DeleteFastlyService(ctx, "account_id", "service_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.DeleteFastlyService`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/fastly-integration/GetFastlyAccount.go b/examples/v2/fastly-integration/GetFastlyAccount.go new file mode 100644 index 00000000000..26cb1a85dbe --- /dev/null +++ b/examples/v2/fastly-integration/GetFastlyAccount.go @@ -0,0 +1,32 @@ +// Get Fastly account 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 "fastly_account" in the system + FastlyAccountDataID := os.Getenv("FASTLY_ACCOUNT_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.GetFastlyAccount(ctx, FastlyAccountDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.GetFastlyAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.GetFastlyAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/GetFastlyService.go b/examples/v2/fastly-integration/GetFastlyService.go new file mode 100644 index 00000000000..884b1888399 --- /dev/null +++ b/examples/v2/fastly-integration/GetFastlyService.go @@ -0,0 +1,29 @@ +// Get Fastly service returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.GetFastlyService(ctx, "account_id", "service_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.GetFastlyService`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.GetFastlyService`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/ListFastlyAccounts.go b/examples/v2/fastly-integration/ListFastlyAccounts.go new file mode 100644 index 00000000000..ddeb4c77c54 --- /dev/null +++ b/examples/v2/fastly-integration/ListFastlyAccounts.go @@ -0,0 +1,29 @@ +// List Fastly accounts returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.ListFastlyAccounts(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.ListFastlyAccounts`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.ListFastlyAccounts`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/ListFastlyServices.go b/examples/v2/fastly-integration/ListFastlyServices.go new file mode 100644 index 00000000000..6ca9c0171b9 --- /dev/null +++ b/examples/v2/fastly-integration/ListFastlyServices.go @@ -0,0 +1,29 @@ +// List Fastly services returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.ListFastlyServices(ctx, "account_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.ListFastlyServices`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.ListFastlyServices`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/UpdateFastlyAccount.go b/examples/v2/fastly-integration/UpdateFastlyAccount.go new file mode 100644 index 00000000000..1c79483d4d9 --- /dev/null +++ b/examples/v2/fastly-integration/UpdateFastlyAccount.go @@ -0,0 +1,40 @@ +// Update Fastly account 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 "fastly_account" in the system + FastlyAccountDataID := os.Getenv("FASTLY_ACCOUNT_DATA_ID") + + body := datadogV2.FastlyAccountUpdateRequest{ + Data: datadogV2.FastlyAccountUpdateRequestData{ + Attributes: &datadogV2.FastlyAccountUpdateRequestAttributes{ + ApiKey: datadog.PtrString("update-secret"), + }, + Type: datadogV2.FASTLYACCOUNTTYPE_FASTLY_ACCOUNTS.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.UpdateFastlyAccount(ctx, FastlyAccountDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.UpdateFastlyAccount`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.UpdateFastlyAccount`:\n%s\n", responseContent) +} diff --git a/examples/v2/fastly-integration/UpdateFastlyService.go b/examples/v2/fastly-integration/UpdateFastlyService.go new file mode 100644 index 00000000000..e666c081d64 --- /dev/null +++ b/examples/v2/fastly-integration/UpdateFastlyService.go @@ -0,0 +1,41 @@ +// Update Fastly service 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.FastlyServiceRequest{ + Data: datadogV2.FastlyServiceData{ + Attributes: &datadogV2.FastlyServiceAttributes{ + Tags: []string{ + "myTag", + "myTag2:myValue", + }, + }, + Id: "abc123", + Type: datadogV2.FASTLYSERVICETYPE_FASTLY_SERVICES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFastlyIntegrationApi(apiClient) + resp, r, err := api.UpdateFastlyService(ctx, "account_id", "service_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FastlyIntegrationApi.UpdateFastlyService`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FastlyIntegrationApi.UpdateFastlyService`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index d9f72e807ff..a460b95588d 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -55,6 +55,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "OpsgenieIntegrationApi": reflect.ValueOf(datadogV2.NewOpsgenieIntegrationApi), "CloudflareIntegrationApi": reflect.ValueOf(datadogV2.NewCloudflareIntegrationApi), "ConfluentCloudApi": reflect.ValueOf(datadogV2.NewConfluentCloudApi), + "FastlyIntegrationApi": reflect.ValueOf(datadogV2.NewFastlyIntegrationApi), "LogsApi": reflect.ValueOf(datadogV2.NewLogsApi), "LogsArchivesApi": reflect.ValueOf(datadogV2.NewLogsArchivesApi), "LogsMetricsApi": reflect.ValueOf(datadogV2.NewLogsMetricsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.freeze new file mode 100644 index 00000000000..f0b6e19ec2d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.freeze @@ -0,0 +1 @@ +2023-01-19T15:15:56.412Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.yaml new file mode 100644 index 00000000000..20ea86ba9cb --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Add_Fastly_account_returns_CREATED_response.yaml @@ -0,0 +1,39 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"api_key":"TestAddFastlyaccountreturnsCREATEDresponse1674141356","name":"Test-Add_Fastly_account_returns_CREATED_response-1674141356","services":[]},"type":"fastly-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts + response: + body: '{"data":{"attributes":{"services":[],"name":"Test-Add_Fastly_account_returns_CREATED_response-1674141356"},"type":"fastly-accounts","id":"0427b05b6f56f454ca1477aa8df5e75d"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/0427b05b6f56f454ca1477aa8df5e75d + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.freeze new file mode 100644 index 00000000000..b15bb846a07 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-11-11T16:54:36.129Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.yaml new file mode 100644 index 00000000000..a0b4aa91c61 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Get_Fastly_account_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"api_key":"TestGetFastlyaccountreturnsOKresponse1668185676","name":"test-name","services":[]},"type":"fastly-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts + response: + body: '{"data":{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/42ed7da188c8af4a6964376d49bb7caa + response: + body: '{"data":{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/42ed7da188c8af4a6964376d49bb7caa + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.freeze new file mode 100644 index 00000000000..08dd5e3dac4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-11-11T16:54:37.514Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.yaml new file mode 100644 index 00000000000..74c4c1d82c3 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_List_Fastly_accounts_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"api_key":"TestListFastlyaccountsreturnsOKresponse1668185677","name":"test-name","services":[]},"type":"fastly-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts + response: + body: '{"data":{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts + response: + body: '{"data":[{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}]} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/42ed7da188c8af4a6964376d49bb7caa + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.freeze new file mode 100644 index 00000000000..b8fbcd77e4c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-01-04T18:06:55.859Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.yaml new file mode 100644 index 00000000000..7ef69b191d9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Fastly_Integration/Scenario_Update_Fastly_account_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"api_key":"TestUpdateFastlyaccountreturnsOKresponse1672855615","name":"test-name","services":[]},"type":"fastly-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts + response: + body: '{"data":{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}} + + ' + code: 201 + duration: '' + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"api_key":"update-secret"},"type":"fastly-accounts"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: PATCH + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/42ed7da188c8af4a6964376d49bb7caa + response: + body: '{"data":{"attributes":{"services":[],"name":"test-name"},"type":"fastly-accounts","id":"42ed7da188c8af4a6964376d49bb7caa"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + method: DELETE + url: https://api.datadoghq.com/api/v2/integrations/fastly/accounts/42ed7da188c8af4a6964376d49bb7caa + response: + body: '' + code: 204 + duration: '' + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 1 diff --git a/tests/scenarios/features/v2/fastly_integration.feature b/tests/scenarios/features/v2/fastly_integration.feature new file mode 100644 index 00000000000..b8ad6e407a0 --- /dev/null +++ b/tests/scenarios/features/v2/fastly_integration.feature @@ -0,0 +1,238 @@ +@endpoint(fastly-integration) @endpoint(fastly-integration-v2) +Feature: Fastly Integration + Configure your Datadog Fastly integration directly through the Datadog + API. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "FastlyIntegration" API + + @generated @skip @team:Datadog/web-integrations + Scenario: Add Fastly account returns "Bad Request" response + Given new "CreateFastlyAccount" request + And body with value {"data": {"attributes": {"api_key": "ABCDEFG123", "name": "test-name", "services": [{"id": "6abc7de6893AbcDe9fghIj", "tags": ["myTag", "myTag2:myValue"]}]}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:Datadog/web-integrations + Scenario: Add Fastly account returns "CREATED" response + Given new "CreateFastlyAccount" request + And body with value {"data": {"attributes": {"api_key": "{{ unique_alnum }}", "name": "{{ unique }}", "services": []}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 201 CREATED + + @generated @skip @team:Datadog/web-integrations + Scenario: Add Fastly account returns "Not Found" response + Given new "CreateFastlyAccount" request + And body with value {"data": {"attributes": {"api_key": "ABCDEFG123", "name": "test-name", "services": [{"id": "6abc7de6893AbcDe9fghIj", "tags": ["myTag", "myTag2:myValue"]}]}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Add Fastly service returns "Bad Request" response + Given new "CreateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Add Fastly service returns "CREATED" response + Given new "CreateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 201 CREATED + + @generated @skip @team:Datadog/web-integrations + Scenario: Add Fastly service returns "Not Found" response + Given new "CreateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly account returns "Bad Request" response + Given new "DeleteFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly account returns "Not Found" response + Given new "DeleteFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly account returns "OK" response + Given new "DeleteFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly service returns "Bad Request" response + Given new "DeleteFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly service returns "Not Found" response + Given new "DeleteFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Delete Fastly service returns "OK" response + Given new "DeleteFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Get Fastly account returns "Bad Request" response + Given new "GetFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Get Fastly account returns "Not Found" response + Given new "GetFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Get Fastly account returns "OK" response + Given there is a valid "fastly_account" in the system + And new "GetFastlyAccount" request + And request contains "account_id" parameter from "fastly_account.data.id" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Get Fastly service returns "Bad Request" response + Given new "GetFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Get Fastly service returns "Not Found" response + Given new "GetFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Get Fastly service returns "OK" response + Given new "GetFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: List Fastly accounts returns "Bad Request" response + Given new "ListFastlyAccounts" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: List Fastly accounts returns "Not Found" response + Given new "ListFastlyAccounts" request + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: List Fastly accounts returns "OK" response + Given there is a valid "fastly_account" in the system + And new "ListFastlyAccounts" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: List Fastly services returns "Bad Request" response + Given new "ListFastlyServices" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: List Fastly services returns "Not Found" response + Given new "ListFastlyServices" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: List Fastly services returns "OK" response + Given new "ListFastlyServices" request + And request contains "account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/web-integrations + Scenario: Update Fastly account returns "Bad Request" response + Given new "UpdateFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "ABCDEFG123"}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Update Fastly account returns "Not Found" response + Given new "UpdateFastlyAccount" request + And request contains "account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"api_key": "ABCDEFG123"}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 404 Not Found + + @team:Datadog/web-integrations + Scenario: Update Fastly account returns "OK" response + Given there is a valid "fastly_account" in the system + And new "UpdateFastlyAccount" request + And request contains "account_id" parameter from "fastly_account.data.id" + And body with value {"data": {"attributes": {"api_key": "update-secret"}, "type": "fastly-accounts"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "{{fastly_account.data.attributes.name }}" + + @generated @skip @team:Datadog/web-integrations + Scenario: Update Fastly service returns "Bad Request" response + Given new "UpdateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/web-integrations + Scenario: Update Fastly service returns "Not Found" response + Given new "UpdateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/web-integrations + Scenario: Update Fastly service returns "OK" response + Given new "UpdateFastlyService" request + And request contains "account_id" parameter from "REPLACE.ME" + And request contains "service_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"tags": ["myTag", "myTag2:myValue"]}, "id": "abc123", "type": "fastly-services"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 695bb8b1146..0ad55a7f2c1 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -131,6 +131,18 @@ "tag": "Confluent Cloud", "operationId": "CreateConfluentAccount" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"fastly-accounts\",\n \"attributes\": {\n \"api_key\": \"{{ unique_alnum }}\",\n \"name\": \"test-name\",\n \"services\": []\n }\n }\n}" + } + ], + "step": "there is a valid \"fastly_account\" in the system", + "key": "fastly_account", + "tag": "Fastly Integration", + "operationId": "CreateFastlyAccount" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 67a84247440..82e5e3aa057 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -414,6 +414,80 @@ "type": "idempotent" } }, + "ListFastlyAccounts": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, + "CreateFastlyAccount": { + "tag": "Fastly Integration", + "undo": { + "operationId": "DeleteFastlyAccount", + "parameters": [ + { + "name": "account_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteFastlyAccount": { + "tag": "Fastly Integration", + "undo": { + "type": "idempotent" + } + }, + "GetFastlyAccount": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, + "UpdateFastlyAccount": { + "tag": "Fastly Integration", + "undo": { + "type": "idempotent" + } + }, + "ListFastlyServices": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, + "CreateFastlyService": { + "tag": "Fastly Integration", + "undo": { + "operationId": "DeleteFastlyService", + "parameters": [ + { + "name": "account_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteFastlyService": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, + "GetFastlyService": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, + "UpdateFastlyService": { + "tag": "Fastly Integration", + "undo": { + "type": "safe" + } + }, "SubmitLog": { "tag": "Logs", "undo": {