Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoint to get and set on demand concurrency cap for Synthetics #1870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.4",
"regenerated": "2023-02-16 09:01:11.175413",
"spec_repo_commit": "4982e03d"
"regenerated": "2023-02-17 16:19:17.421294",
"spec_repo_commit": "a05a9d36"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2023-02-16 09:01:11.190527",
"spec_repo_commit": "4982e03d"
"regenerated": "2023-02-17 16:19:17.436601",
"spec_repo_commit": "a05a9d36"
}
}
}
66 changes: 66 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7542,6 +7542,26 @@ components:
- id
- type
type: object
OnDemandConcurrencyCap:
description: On-demand concurrency cap.
properties:
attributes:
$ref: '#/components/schemas/OnDemandConcurrencyCapAttributes'
type: object
OnDemandConcurrencyCapAttributes:
description: On-demand concurrency cap attributes.
properties:
on_demand_concurrency_cap:
description: Value of the on-demand concurrency cap.
format: double
type: number
type: object
OnDemandConcurrencyCapResponse:
description: On-demand concurrency cap response.
properties:
data:
$ref: '#/components/schemas/OnDemandConcurrencyCap'
type: object
OpsgenieServiceCreateAttributes:
description: The Opsgenie service attributes for a create request.
properties:
Expand Down Expand Up @@ -19685,6 +19705,45 @@ paths:
x-unstable: '**Note**: This endpoint is in public beta.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/synthetics/settings/on_demand_concurrency_cap:
get:
description: Get the on-demand concurrency cap.
operationId: GetOnDemandConcurrencyCap
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/OnDemandConcurrencyCapResponse'
description: OK
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Get the on-demand concurrency cap
tags:
- Synthetics
post:
description: Save new value for on-demand concurrency cap.
operationId: SetOnDemandConcurrencyCap
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OnDemandConcurrencyCapAttributes'
description: .
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/OnDemandConcurrencyCapResponse'
description: OK
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Save new value for on-demand concurrency cap
tags:
- Synthetics
x-codegen-request-body-name: body
/api/v2/teams:
get:
description: Get all incident teams for the requesting user's organization.
Expand Down Expand Up @@ -20963,6 +21022,13 @@ tags:
externalDocs:
url: https://docs.datadoghq.com/tracing/service_catalog/
name: Service Definition
- description: "Datadog Synthetics uses simulated user requests and browser rendering
to help you ensure uptime,\nidentify regional issues, and track your application
performance. Datadog Synthetics tests come in\ntwo different flavors, [API tests](https://docs.datadoghq.com/synthetics/api_tests/)\nand
[browser tests](https://docs.datadoghq.com/synthetics/browser_tests). You can
use Datadog\u2019s API to\nmanage both test types programmatically.\n\nFor more
information about Synthetics, see the [Synthetics overview](https://docs.datadoghq.com/synthetics/)."
name: Synthetics
- description: 'The usage metering API allows you to get hourly, daily, and

monthly usage across multiple facets of Datadog.
Expand Down
215 changes: 215 additions & 0 deletions api/datadogV2/api_synthetics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

package datadogV2

import (
_context "context"
_nethttp "net/http"
_neturl "net/url"

"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// SyntheticsApi service type
type SyntheticsApi datadog.Service

type apiGetOnDemandConcurrencyCapRequest struct {
ctx _context.Context
}

func (a *SyntheticsApi) buildGetOnDemandConcurrencyCapRequest(ctx _context.Context) (apiGetOnDemandConcurrencyCapRequest, error) {
req := apiGetOnDemandConcurrencyCapRequest{
ctx: ctx,
}
return req, nil
}

// GetOnDemandConcurrencyCap Get the on-demand concurrency cap.
// Get the on-demand concurrency cap.
func (a *SyntheticsApi) GetOnDemandConcurrencyCap(ctx _context.Context) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) {
req, err := a.buildGetOnDemandConcurrencyCapRequest(ctx)
if err != nil {
var localVarReturnValue OnDemandConcurrencyCapResponse
return localVarReturnValue, nil, err
}

return a.getOnDemandConcurrencyCapExecute(req)
}

// getOnDemandConcurrencyCapExecute executes the request.
func (a *SyntheticsApi) getOnDemandConcurrencyCapExecute(r apiGetOnDemandConcurrencyCapRequest) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarReturnValue OnDemandConcurrencyCapResponse
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.SyntheticsApi.GetOnDemandConcurrencyCap")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/synthetics/settings/on_demand_concurrency_cap"

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 := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 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 apiSetOnDemandConcurrencyCapRequest struct {
ctx _context.Context
body *OnDemandConcurrencyCapAttributes
}

func (a *SyntheticsApi) buildSetOnDemandConcurrencyCapRequest(ctx _context.Context, body OnDemandConcurrencyCapAttributes) (apiSetOnDemandConcurrencyCapRequest, error) {
req := apiSetOnDemandConcurrencyCapRequest{
ctx: ctx,
body: &body,
}
return req, nil
}

// SetOnDemandConcurrencyCap Save new value for on-demand concurrency cap.
// Save new value for on-demand concurrency cap.
func (a *SyntheticsApi) SetOnDemandConcurrencyCap(ctx _context.Context, body OnDemandConcurrencyCapAttributes) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) {
req, err := a.buildSetOnDemandConcurrencyCapRequest(ctx, body)
if err != nil {
var localVarReturnValue OnDemandConcurrencyCapResponse
return localVarReturnValue, nil, err
}

return a.setOnDemandConcurrencyCapExecute(req)
}

// setOnDemandConcurrencyCapExecute executes the request.
func (a *SyntheticsApi) setOnDemandConcurrencyCapExecute(r apiSetOnDemandConcurrencyCapRequest) (OnDemandConcurrencyCapResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarReturnValue OnDemandConcurrencyCapResponse
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.SyntheticsApi.SetOnDemandConcurrencyCap")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/synthetics/settings/on_demand_concurrency_cap"

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 := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 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
}

// NewSyntheticsApi Returns NewSyntheticsApi.
func NewSyntheticsApi(client *datadog.APIClient) *SyntheticsApi {
return &SyntheticsApi{
Client: client,
}
}
2 changes: 2 additions & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
// - [ServiceDefinitionApi.DeleteServiceDefinition]
// - [ServiceDefinitionApi.GetServiceDefinition]
// - [ServiceDefinitionApi.ListServiceDefinitions]
// - [SyntheticsApi.GetOnDemandConcurrencyCap]
// - [SyntheticsApi.SetOnDemandConcurrencyCap]
// - [UsageMeteringApi.GetCostByOrg]
// - [UsageMeteringApi.GetEstimatedCostByOrg]
// - [UsageMeteringApi.GetHistoricalCostByOrg]
Expand Down
Loading