Skip to content
Open
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
162 changes: 138 additions & 24 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/datadog/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ func NewConfiguration() *Configuration {
"v2.SearchCostRecommendations": false,
"v2.UpdateUnitCost": false,
"v2.CreateQuotas": false,
"v2.DeletePendingQuota": false,
"v2.DeleteQuota": false,
"v2.ListQuotas": false,
"v2.UpdateQuota": false,
Expand Down
95 changes: 93 additions & 2 deletions api/datadogV2/api_usage_metering.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ func (r *CreateQuotasOptionalParameters) WithIncludeDescendants(includeDescendan
}

// CreateQuotas Create or update usage quotas.
// Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated; otherwise, a new quota is created. Requires the `billing_edit` permission.
// Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated.
// Otherwise, a quota is created only when `usage_limit` and `enforced` are provided.
// For the organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period and can
// accompany an immediate limit or update an existing quota by itself.
// Scheduled changes follow `include_descendants` like the other fields. Requires the `billing_edit` permission.
func (a *UsageMeteringApi) CreateQuotas(ctx _context.Context, quotaNamespace string, body UsageQuotasCreateRequest, o ...CreateQuotasOptionalParameters) (UsageQuotasBulkResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
Expand Down Expand Up @@ -145,6 +149,93 @@ func (a *UsageMeteringApi) CreateQuotas(ctx _context.Context, quotaNamespace str
return localVarReturnValue, localVarHTTPResponse, nil
}

// DeletePendingQuota Cancel a scheduled usage quota limit.
// Cancels the limit change scheduled to take effect at the start of the next usage period, leaving the usage quota and its current limit unchanged. Returns `404` when the quota does not exist, has no scheduled change, or its scheduled change has already taken effect; in every case the quota is left unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `billing_edit` permission.
func (a *UsageMeteringApi) DeletePendingQuota(ctx _context.Context, quotaNamespace string, id string) (*_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodDelete
localVarPostBody interface{}
)

operationId := "v2.DeletePendingQuota"
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
if !isOperationEnabled {
return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
}
if isOperationEnabled && a.Client.Cfg.Debug {
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
}

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

localVarPath := localBasePath + "/api/v2/usage/quotas/{quota_namespace}/{id}/pending"
localVarPath = datadog.ReplacePathParameter(localVarPath, "{quota_namespace}", _neturl.PathEscape(datadog.ParameterToString(quotaNamespace, "")))
localVarPath = datadog.ReplacePathParameter(localVarPath, "{id}", _neturl.PathEscape(datadog.ParameterToString(id, "")))

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Accept"] = "*/*"

if a.Client.Cfg.DelegatedTokenConfig != nil {
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
if err != nil {
return nil, err
}
} else {
datadog.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"apiKeyAuth", "DD-API-KEY"},
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
)
}
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}

localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
var v JSONAPIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
return localVarHTTPResponse, newErr
}
if 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
}

// DeleteQuota Delete a usage quota.
// Deletes a usage quota by its opaque identifier. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `billing_edit` permission.
func (a *UsageMeteringApi) DeleteQuota(ctx _context.Context, quotaNamespace string, id string) (*_nethttp.Response, error) {
Expand Down Expand Up @@ -2026,7 +2117,7 @@ func (a *UsageMeteringApi) ListQuotasWithPagination(ctx _context.Context, quotaN
}

// UpdateQuota Update a usage quota.
// Updates the supplied fields on a usage quota and leaves omitted fields unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `billing_edit` permission.
// Updates the supplied fields on a usage quota and leaves omitted fields unchanged. For an organization-wide quota, `pending_usage_limit` schedules a limit for the next usage period. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the `billing_edit` permission.
func (a *UsageMeteringApi) UpdateQuota(ctx _context.Context, quotaNamespace string, id string, body UsageQuotaUpdateRequest) (UsageQuotaResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPatch
Expand Down
1 change: 1 addition & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@
// - [TwilioIntegrationApi.ListTwilioIntegrationAccounts]
// - [TwilioIntegrationApi.UpdateTwilioIntegrationAccount]
// - [UsageMeteringApi.CreateQuotas]
// - [UsageMeteringApi.DeletePendingQuota]
// - [UsageMeteringApi.DeleteQuota]
// - [UsageMeteringApi.GetActiveBillingDimensions]
// - [UsageMeteringApi.GetBillingDimensionMapping]
Expand Down
84 changes: 77 additions & 7 deletions api/datadogV2/model_usage_quota_bulk_result_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// UsageQuotaBulkResultAttributes Attributes of a usage quota bulk write result. On success, all fields except `error` are present. On failure, only `error` is present and the other fields are omitted.
// UsageQuotaBulkResultAttributes Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only `error` is present and the other fields are omitted.
type UsageQuotaBulkResultAttributes struct {
// Whether usage above the limit is actively blocked instead of only tracked or alerted on. Omitted if this item failed to write.
Enforced *bool `json:"enforced,omitempty"`
// An error message describing why this item failed to write. Omitted if this item was written successfully.
Error *string `json:"error,omitempty"`
// The public ID of the organization that owns the quota. Omitted if this item failed to write.
OrgPublicId *string `json:"org_public_id,omitempty"`
// The future UTC month when the scheduled limit takes effect, formatted as `YYYY-MM`, starting at 00:00 UTC on its first day. Present only together with `pending_usage_limit` and omitted when no change is scheduled or this item failed to write.
PendingEffectiveFrom *string `json:"pending_effective_from,omitempty"`
// The usage limit scheduled for the organization-wide quota in the usage units defined by the quota namespace. A value of `0` is valid. At the start of the effective month, this value becomes `usage_limit` and both pending fields are omitted. Omitted when no change is scheduled or this item failed to write.
PendingUsageLimit *float64 `json:"pending_usage_limit,omitempty"`
// A namespace-specific key and value identifying what the quota applies to within an organization. The object contains exactly one entry. A value of `"*"` identifies the default quota applied to entities without a specific quota. This field is omitted for an organization-wide quota.
Scope map[string]string `json:"scope,omitempty"`
// The quota limit in the usage units defined by the quota namespace. May be fractional for quotas configured before public writes required whole units. Omitted if this item failed to write.
Expand Down Expand Up @@ -126,6 +130,62 @@ func (o *UsageQuotaBulkResultAttributes) SetOrgPublicId(v string) {
o.OrgPublicId = &v
}

// GetPendingEffectiveFrom returns the PendingEffectiveFrom field value if set, zero value otherwise.
func (o *UsageQuotaBulkResultAttributes) GetPendingEffectiveFrom() string {
if o == nil || o.PendingEffectiveFrom == nil {
var ret string
return ret
}
return *o.PendingEffectiveFrom
}

// GetPendingEffectiveFromOk returns a tuple with the PendingEffectiveFrom field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UsageQuotaBulkResultAttributes) GetPendingEffectiveFromOk() (*string, bool) {
if o == nil || o.PendingEffectiveFrom == nil {
return nil, false
}
return o.PendingEffectiveFrom, true
}

// HasPendingEffectiveFrom returns a boolean if a field has been set.
func (o *UsageQuotaBulkResultAttributes) HasPendingEffectiveFrom() bool {
return o != nil && o.PendingEffectiveFrom != nil
}

// SetPendingEffectiveFrom gets a reference to the given string and assigns it to the PendingEffectiveFrom field.
func (o *UsageQuotaBulkResultAttributes) SetPendingEffectiveFrom(v string) {
o.PendingEffectiveFrom = &v
}

// GetPendingUsageLimit returns the PendingUsageLimit field value if set, zero value otherwise.
func (o *UsageQuotaBulkResultAttributes) GetPendingUsageLimit() float64 {
if o == nil || o.PendingUsageLimit == nil {
var ret float64
return ret
}
return *o.PendingUsageLimit
}

// GetPendingUsageLimitOk returns a tuple with the PendingUsageLimit field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UsageQuotaBulkResultAttributes) GetPendingUsageLimitOk() (*float64, bool) {
if o == nil || o.PendingUsageLimit == nil {
return nil, false
}
return o.PendingUsageLimit, true
}

// HasPendingUsageLimit returns a boolean if a field has been set.
func (o *UsageQuotaBulkResultAttributes) HasPendingUsageLimit() bool {
return o != nil && o.PendingUsageLimit != nil
}

// SetPendingUsageLimit gets a reference to the given float64 and assigns it to the PendingUsageLimit field.
func (o *UsageQuotaBulkResultAttributes) SetPendingUsageLimit(v float64) {
o.PendingUsageLimit = &v
}

// GetScope returns the Scope field value if set, zero value otherwise.
func (o *UsageQuotaBulkResultAttributes) GetScope() map[string]string {
if o == nil || o.Scope == nil {
Expand Down Expand Up @@ -197,6 +257,12 @@ func (o UsageQuotaBulkResultAttributes) MarshalJSON() ([]byte, error) {
if o.OrgPublicId != nil {
toSerialize["org_public_id"] = o.OrgPublicId
}
if o.PendingEffectiveFrom != nil {
toSerialize["pending_effective_from"] = o.PendingEffectiveFrom
}
if o.PendingUsageLimit != nil {
toSerialize["pending_usage_limit"] = o.PendingUsageLimit
}
if o.Scope != nil {
toSerialize["scope"] = o.Scope
}
Expand All @@ -213,24 +279,28 @@ func (o UsageQuotaBulkResultAttributes) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *UsageQuotaBulkResultAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Enforced *bool `json:"enforced,omitempty"`
Error *string `json:"error,omitempty"`
OrgPublicId *string `json:"org_public_id,omitempty"`
Scope map[string]string `json:"scope,omitempty"`
UsageLimit *float64 `json:"usage_limit,omitempty"`
Enforced *bool `json:"enforced,omitempty"`
Error *string `json:"error,omitempty"`
OrgPublicId *string `json:"org_public_id,omitempty"`
PendingEffectiveFrom *string `json:"pending_effective_from,omitempty"`
PendingUsageLimit *float64 `json:"pending_usage_limit,omitempty"`
Scope map[string]string `json:"scope,omitempty"`
UsageLimit *float64 `json:"usage_limit,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
additionalProperties := make(map[string]interface{})
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"enforced", "error", "org_public_id", "scope", "usage_limit"})
datadog.DeleteKeys(additionalProperties, &[]string{"enforced", "error", "org_public_id", "pending_effective_from", "pending_usage_limit", "scope", "usage_limit"})
} else {
return err
}
o.Enforced = all.Enforced
o.Error = all.Error
o.OrgPublicId = all.OrgPublicId
o.PendingEffectiveFrom = all.PendingEffectiveFrom
o.PendingUsageLimit = all.PendingUsageLimit
o.Scope = all.Scope
o.UsageLimit = all.UsageLimit

Expand Down
2 changes: 1 addition & 1 deletion api/datadogV2/model_usage_quota_bulk_result_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// UsageQuotaBulkResultData The result of writing one usage quota in a bulk create-or-update request.
type UsageQuotaBulkResultData struct {
// Attributes of a usage quota bulk write result. On success, all fields except `error` are present. On failure, only `error` is present and the other fields are omitted.
// Attributes of a usage quota bulk write result. On success, quota fields are present as applicable, and pending fields are present only when a change is scheduled. On failure, only `error` is present and the other fields are omitted.
Attributes UsageQuotaBulkResultAttributes `json:"attributes"`
// An opaque usage quota identifier. Clients must pass this value back verbatim in update and delete requests and must not infer any structure from it.
Id string `json:"id"`
Expand Down
Loading
Loading