From 9cde90b6dfb04ecb7fb1aaa54c38b2c0303d4683 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 5 Jun 2026 06:07:50 +0000 Subject: [PATCH] Regenerate client from commit 223f6e0 of spec repo --- .generator/schemas/v2/openapi.yaml | 329 ++++++++++++++++++ api/datadog/configuration.go | 3 + api/datadogV2/api_rum_rate_limit.go | 283 +++++++++++++++ api/datadogV2/doc.go | 3 + .../model_rum_rate_limit_adaptive_config.go | 101 ++++++ .../model_rum_rate_limit_config_attributes.go | 290 +++++++++++++++ .../model_rum_rate_limit_config_data.go | 180 ++++++++++ .../model_rum_rate_limit_config_response.go | 110 ++++++ .../model_rum_rate_limit_config_type.go | 64 ++++ ...rum_rate_limit_config_update_attributes.go | 188 ++++++++++ ...model_rum_rate_limit_config_update_data.go | 181 ++++++++++ ...el_rum_rate_limit_config_update_request.go | 110 ++++++ .../model_rum_rate_limit_custom_config.go | 243 +++++++++++++ api/datadogV2/model_rum_rate_limit_mode.go | 67 ++++ ...del_rum_rate_limit_quota_reached_action.go | 66 ++++ .../model_rum_rate_limit_scope_type.go | 64 ++++ .../model_rum_rate_limit_window_type.go | 64 ++++ .../DeleteRumRateLimitConfig.go | 26 ++ .../rum-rate-limit/GetRumRateLimitConfig.go | 30 ++ .../UpdateRumRateLimitConfig.go | 49 +++ tests/scenarios/api_mappings.go | 1 + .../features/v2/rum_rate_limit.feature | 93 +++++ tests/scenarios/features/v2/undo.json | 18 + 23 files changed, 2563 insertions(+) create mode 100644 api/datadogV2/api_rum_rate_limit.go create mode 100644 api/datadogV2/model_rum_rate_limit_adaptive_config.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_attributes.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_data.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_response.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_type.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_update_attributes.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_update_data.go create mode 100644 api/datadogV2/model_rum_rate_limit_config_update_request.go create mode 100644 api/datadogV2/model_rum_rate_limit_custom_config.go create mode 100644 api/datadogV2/model_rum_rate_limit_mode.go create mode 100644 api/datadogV2/model_rum_rate_limit_quota_reached_action.go create mode 100644 api/datadogV2/model_rum_rate_limit_scope_type.go create mode 100644 api/datadogV2/model_rum_rate_limit_window_type.go create mode 100644 examples/v2/rum-rate-limit/DeleteRumRateLimitConfig.go create mode 100644 examples/v2/rum-rate-limit/GetRumRateLimitConfig.go create mode 100644 examples/v2/rum-rate-limit/UpdateRumRateLimitConfig.go create mode 100644 tests/scenarios/features/v2/rum_rate_limit.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 74b9de40104..2b49199abf0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1586,6 +1586,23 @@ components: required: true schema: $ref: "#/components/schemas/RumPermanentRetentionFilterID" + RumRateLimitScopeIDParameter: + description: |- + The identifier of the scope the rate limit configuration applies to. + For the `application` scope, this is the RUM application ID. + in: path + name: scope_id + required: true + schema: + example: cd73a516-a481-4af5-8352-9b577465c77b + type: string + RumRateLimitScopeTypeParameter: + description: The type of scope the rate limit configuration applies to. + in: path + name: scope_type + required: true + schema: + $ref: "#/components/schemas/RumRateLimitScopeType" RumRetentionFilterIDParameter: description: Retention filter ID. in: path @@ -74528,6 +74545,179 @@ components: $ref: "#/components/schemas/RumPermanentRetentionFilterData" type: array type: object + RumRateLimitAdaptiveConfig: + description: The configuration used when `mode` is `adaptive`. + properties: + max_retention_rate: + description: The maximum fraction of sessions to retain, in the range `(0, 1]`. + example: 0.5 + exclusiveMinimum: true + format: double + maximum: 1 + minimum: 0 + type: number + required: + - max_retention_rate + type: object + RumRateLimitConfigAttributes: + description: The RUM rate limit configuration properties. + properties: + adaptive: + $ref: "#/components/schemas/RumRateLimitAdaptiveConfig" + custom: + $ref: "#/components/schemas/RumRateLimitCustomConfig" + mode: + $ref: "#/components/schemas/RumRateLimitMode" + org_id: + description: The ID of the organization the rate limit configuration belongs to. + example: 2 + format: int64 + type: integer + updated_at: + description: The date the rate limit configuration was last updated. + example: "2026-03-04T15:37:54.951447Z" + type: string + updated_by: + description: The handle of the user who last updated the rate limit configuration. + example: test@example.com + type: string + required: + - mode + - org_id + type: object + RumRateLimitConfigData: + description: The RUM rate limit configuration object. + properties: + attributes: + $ref: "#/components/schemas/RumRateLimitConfigAttributes" + id: + description: The identifier of the scope the rate limit configuration applies to. + example: cd73a516-a481-4af5-8352-9b577465c77b + type: string + type: + $ref: "#/components/schemas/RumRateLimitConfigType" + required: + - id + - type + - attributes + type: object + RumRateLimitConfigResponse: + description: The RUM rate limit configuration response. + properties: + data: + $ref: "#/components/schemas/RumRateLimitConfigData" + required: + - data + type: object + RumRateLimitConfigType: + default: rum_rate_limit_config + description: The type of the resource, always `rum_rate_limit_config`. + enum: + - rum_rate_limit_config + example: rum_rate_limit_config + type: string + x-enum-varnames: ["RUM_RATE_LIMIT_CONFIG"] + RumRateLimitConfigUpdateAttributes: + description: The RUM rate limit configuration properties to create or update. + properties: + adaptive: + $ref: "#/components/schemas/RumRateLimitAdaptiveConfig" + custom: + $ref: "#/components/schemas/RumRateLimitCustomConfig" + mode: + $ref: "#/components/schemas/RumRateLimitMode" + required: + - mode + type: object + RumRateLimitConfigUpdateData: + description: The RUM rate limit configuration to create or update. + properties: + attributes: + $ref: "#/components/schemas/RumRateLimitConfigUpdateAttributes" + id: + description: |- + The identifier of the scope the rate limit configuration applies to. + Must match `scope_id` in the path. + example: cd73a516-a481-4af5-8352-9b577465c77b + type: string + type: + $ref: "#/components/schemas/RumRateLimitConfigType" + required: + - id + - type + - attributes + type: object + RumRateLimitConfigUpdateRequest: + description: The body of a request to create or update a RUM rate limit configuration. + properties: + data: + $ref: "#/components/schemas/RumRateLimitConfigUpdateData" + required: + - data + type: object + RumRateLimitCustomConfig: + description: The configuration used when `mode` is `custom`. + properties: + daily_reset_time: + description: The time of day when the daily quota resets, in `HH:MM` 24-hour format. + example: "08:00" + pattern: "^([01]\\d|2[0-3]):[0-5]\\d$" + type: string + daily_reset_timezone: + description: The timezone offset used for the daily reset time, in `±HH:MM` format. + example: "+09:00" + pattern: "^[+-](0\\d|1[0-4]):[0-5]\\d$" + type: string + quota_reached_action: + $ref: "#/components/schemas/RumRateLimitQuotaReachedAction" + session_limit: + description: The maximum number of sessions allowed within the window. + example: 1000000 + format: int64 + minimum: 1 + type: integer + window_type: + $ref: "#/components/schemas/RumRateLimitWindowType" + required: + - window_type + - session_limit + - daily_reset_time + - daily_reset_timezone + - quota_reached_action + type: object + RumRateLimitMode: + description: |- + The rate limit mode. `custom` enforces a fixed session limit, while + `adaptive` dynamically adjusts retention. + enum: + - custom + - adaptive + example: custom + type: string + x-enum-varnames: ["CUSTOM", "ADAPTIVE"] + RumRateLimitQuotaReachedAction: + description: The action to take when the session quota is reached. + enum: + - stop + - slowdown + example: stop + type: string + x-enum-varnames: ["STOP", "SLOWDOWN"] + RumRateLimitScopeType: + default: application + description: The type of scope the rate limit configuration applies to. + enum: + - application + example: application + type: string + x-enum-varnames: ["APPLICATION"] + RumRateLimitWindowType: + description: The window type over which the session limit is enforced. + enum: + - daily + example: daily + type: string + x-enum-varnames: ["DAILY"] RumRetentionFilterAttributes: description: The object describing attributes of a RUM retention filter. properties: @@ -153409,6 +153599,142 @@ paths: tags: - Rum Metrics x-codegen-request-body-name: body + /api/v2/rum/config/rate-limit/{scope_type}/{scope_id}: + delete: + description: Delete the RUM rate limit configuration for a given scope. + operationId: DeleteRumRateLimitConfig + parameters: + - $ref: "#/components/parameters/RumRateLimitScopeTypeParameter" + - $ref: "#/components/parameters/RumRateLimitScopeIDParameter" + responses: + "204": + description: No Content + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a RUM rate limit configuration + tags: + - Rum Rate Limit + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + get: + description: Get the RUM rate limit configuration for a given scope. + operationId: GetRumRateLimitConfig + parameters: + - $ref: "#/components/parameters/RumRateLimitScopeTypeParameter" + - $ref: "#/components/parameters/RumRateLimitScopeIDParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + custom: + daily_reset_time: "08:00" + daily_reset_timezone: "+09:00" + quota_reached_action: stop + session_limit: 1000000 + window_type: daily + mode: custom + org_id: 2 + updated_at: "2026-03-04T15:37:54.951447Z" + updated_by: test@example.com + id: cd73a516-a481-4af5-8352-9b577465c77b + type: rum_rate_limit_config + schema: + $ref: "#/components/schemas/RumRateLimitConfigResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a RUM rate limit configuration + tags: + - Rum Rate Limit + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + put: + description: |- + Create or update the RUM rate limit configuration for a given scope. + Returns the rate limit configuration object when the request is successful. + operationId: UpdateRumRateLimitConfig + parameters: + - $ref: "#/components/parameters/RumRateLimitScopeTypeParameter" + - $ref: "#/components/parameters/RumRateLimitScopeIDParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + custom: + daily_reset_time: "08:00" + daily_reset_timezone: "+09:00" + quota_reached_action: stop + session_limit: 1000000 + window_type: daily + mode: custom + id: cd73a516-a481-4af5-8352-9b577465c77b + type: rum_rate_limit_config + schema: + $ref: "#/components/schemas/RumRateLimitConfigUpdateRequest" + description: The definition of the RUM rate limit configuration to create or update. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + custom: + daily_reset_time: "08:00" + daily_reset_timezone: "+09:00" + quota_reached_action: stop + session_limit: 1000000 + window_type: daily + mode: custom + org_id: 2 + updated_at: "2026-03-04T21:52:53.526022Z" + updated_by: test@example.com + id: cd73a516-a481-4af5-8352-9b577465c77b + type: rum_rate_limit_config + schema: + $ref: "#/components/schemas/RumRateLimitConfigResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create or update a RUM rate limit configuration + tags: + - Rum Rate Limit + x-codegen-request-body-name: body + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rum/events: get: description: |- @@ -179358,6 +179684,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/real_user_monitoring/platform/generate_metrics/ name: Rum Metrics + - description: |- + Manage RUM rate limit configurations for your organization's RUM applications. + name: Rum Rate Limit - description: Manage heatmap snapshots for RUM replay sessions. Create, update, delete, and retrieve snapshots to visualize user interactions on specific views. name: Rum Replay Heatmaps - description: Create and manage playlists of RUM replay sessions. Organize, categorize, and share collections of replay sessions for analysis and collaboration. diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 6f18e4ecdb8..846adb3c2ef 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -1045,6 +1045,9 @@ func NewConfiguration() *Configuration { "v2.GetSourcemaps": false, "v2.ListSourcemaps": false, "v2.RestoreSourcemaps": false, + "v2.DeleteRumRateLimitConfig": false, + "v2.GetRumRateLimitConfig": false, + "v2.UpdateRumRateLimitConfig": false, "v2.QueryAggregatedLongTasks": false, "v2.QueryAggregatedSignalsProblems": false, "v2.QueryAggregatedWaterfall": false, diff --git a/api/datadogV2/api_rum_rate_limit.go b/api/datadogV2/api_rum_rate_limit.go new file mode 100644 index 00000000000..e231d62a9c3 --- /dev/null +++ b/api/datadogV2/api_rum_rate_limit.go @@ -0,0 +1,283 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitApi service type +type RumRateLimitApi datadog.Service + +// DeleteRumRateLimitConfig Delete a RUM rate limit configuration. +// Delete the RUM rate limit configuration for a given scope. +func (a *RumRateLimitApi) DeleteRumRateLimitConfig(ctx _context.Context, scopeType RumRateLimitScopeType, scopeId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteRumRateLimitConfig" + 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.RumRateLimitApi.DeleteRumRateLimitConfig") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/rum/config/rate-limit/{scope_type}/{scope_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_type}", _neturl.PathEscape(datadog.ParameterToString(scopeType, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_id}", _neturl.PathEscape(datadog.ParameterToString(scopeId, ""))) + + 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 || 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 +} + +// GetRumRateLimitConfig Get a RUM rate limit configuration. +// Get the RUM rate limit configuration for a given scope. +func (a *RumRateLimitApi) GetRumRateLimitConfig(ctx _context.Context, scopeType RumRateLimitScopeType, scopeId string) (RumRateLimitConfigResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RumRateLimitConfigResponse + ) + + operationId := "v2.GetRumRateLimitConfig" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, 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.RumRateLimitApi.GetRumRateLimitConfig") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/rum/config/rate-limit/{scope_type}/{scope_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_type}", _neturl.PathEscape(datadog.ParameterToString(scopeType, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_id}", _neturl.PathEscape(datadog.ParameterToString(scopeId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, 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 localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpdateRumRateLimitConfig Create or update a RUM rate limit configuration. +// Create or update the RUM rate limit configuration for a given scope. +// Returns the rate limit configuration object when the request is successful. +func (a *RumRateLimitApi) UpdateRumRateLimitConfig(ctx _context.Context, scopeType RumRateLimitScopeType, scopeId string, body RumRateLimitConfigUpdateRequest) (RumRateLimitConfigResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue RumRateLimitConfigResponse + ) + + operationId := "v2.UpdateRumRateLimitConfig" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, 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.RumRateLimitApi.UpdateRumRateLimitConfig") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/rum/config/rate-limit/{scope_type}/{scope_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_type}", _neturl.PathEscape(datadog.ParameterToString(scopeType, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{scope_id}", _neturl.PathEscape(datadog.ParameterToString(scopeId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, 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 localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewRumRateLimitApi Returns NewRumRateLimitApi. +func NewRumRateLimitApi(client *datadog.APIClient) *RumRateLimitApi { + return &RumRateLimitApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 3746a879fe3..4fa1cc1f938 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -853,6 +853,9 @@ // - [RumMetricsApi.GetRumMetric] // - [RumMetricsApi.ListRumMetrics] // - [RumMetricsApi.UpdateRumMetric] +// - [RumRateLimitApi.DeleteRumRateLimitConfig] +// - [RumRateLimitApi.GetRumRateLimitConfig] +// - [RumRateLimitApi.UpdateRumRateLimitConfig] // - [RumReplayHeatmapsApi.CreateReplayHeatmapSnapshot] // - [RumReplayHeatmapsApi.DeleteReplayHeatmapSnapshot] // - [RumReplayHeatmapsApi.ListReplayHeatmapSnapshots] diff --git a/api/datadogV2/model_rum_rate_limit_adaptive_config.go b/api/datadogV2/model_rum_rate_limit_adaptive_config.go new file mode 100644 index 00000000000..d5e4cb3a28a --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_adaptive_config.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitAdaptiveConfig The configuration used when `mode` is `adaptive`. +type RumRateLimitAdaptiveConfig struct { + // The maximum fraction of sessions to retain, in the range `(0, 1]`. + MaxRetentionRate float64 `json:"max_retention_rate"` + // 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{} `json:"-"` +} + +// NewRumRateLimitAdaptiveConfig instantiates a new RumRateLimitAdaptiveConfig 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 NewRumRateLimitAdaptiveConfig(maxRetentionRate float64) *RumRateLimitAdaptiveConfig { + this := RumRateLimitAdaptiveConfig{} + this.MaxRetentionRate = maxRetentionRate + return &this +} + +// NewRumRateLimitAdaptiveConfigWithDefaults instantiates a new RumRateLimitAdaptiveConfig 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 NewRumRateLimitAdaptiveConfigWithDefaults() *RumRateLimitAdaptiveConfig { + this := RumRateLimitAdaptiveConfig{} + return &this +} + +// GetMaxRetentionRate returns the MaxRetentionRate field value. +func (o *RumRateLimitAdaptiveConfig) GetMaxRetentionRate() float64 { + if o == nil { + var ret float64 + return ret + } + return o.MaxRetentionRate +} + +// GetMaxRetentionRateOk returns a tuple with the MaxRetentionRate field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitAdaptiveConfig) GetMaxRetentionRateOk() (*float64, bool) { + if o == nil { + return nil, false + } + return &o.MaxRetentionRate, true +} + +// SetMaxRetentionRate sets field value. +func (o *RumRateLimitAdaptiveConfig) SetMaxRetentionRate(v float64) { + o.MaxRetentionRate = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitAdaptiveConfig) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["max_retention_rate"] = o.MaxRetentionRate + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitAdaptiveConfig) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + MaxRetentionRate *float64 `json:"max_retention_rate"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.MaxRetentionRate == nil { + return fmt.Errorf("required field max_retention_rate missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"max_retention_rate"}) + } else { + return err + } + o.MaxRetentionRate = *all.MaxRetentionRate + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_attributes.go b/api/datadogV2/model_rum_rate_limit_config_attributes.go new file mode 100644 index 00000000000..563af322fd1 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_attributes.go @@ -0,0 +1,290 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigAttributes The RUM rate limit configuration properties. +type RumRateLimitConfigAttributes struct { + // The configuration used when `mode` is `adaptive`. + Adaptive *RumRateLimitAdaptiveConfig `json:"adaptive,omitempty"` + // The configuration used when `mode` is `custom`. + Custom *RumRateLimitCustomConfig `json:"custom,omitempty"` + // The rate limit mode. `custom` enforces a fixed session limit, while + // `adaptive` dynamically adjusts retention. + Mode RumRateLimitMode `json:"mode"` + // The ID of the organization the rate limit configuration belongs to. + OrgId int64 `json:"org_id"` + // The date the rate limit configuration was last updated. + UpdatedAt *string `json:"updated_at,omitempty"` + // The handle of the user who last updated the rate limit configuration. + UpdatedBy *string `json:"updated_by,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{} `json:"-"` +} + +// NewRumRateLimitConfigAttributes instantiates a new RumRateLimitConfigAttributes 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 NewRumRateLimitConfigAttributes(mode RumRateLimitMode, orgId int64) *RumRateLimitConfigAttributes { + this := RumRateLimitConfigAttributes{} + this.Mode = mode + this.OrgId = orgId + return &this +} + +// NewRumRateLimitConfigAttributesWithDefaults instantiates a new RumRateLimitConfigAttributes 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 NewRumRateLimitConfigAttributesWithDefaults() *RumRateLimitConfigAttributes { + this := RumRateLimitConfigAttributes{} + return &this +} + +// GetAdaptive returns the Adaptive field value if set, zero value otherwise. +func (o *RumRateLimitConfigAttributes) GetAdaptive() RumRateLimitAdaptiveConfig { + if o == nil || o.Adaptive == nil { + var ret RumRateLimitAdaptiveConfig + return ret + } + return *o.Adaptive +} + +// GetAdaptiveOk returns a tuple with the Adaptive field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetAdaptiveOk() (*RumRateLimitAdaptiveConfig, bool) { + if o == nil || o.Adaptive == nil { + return nil, false + } + return o.Adaptive, true +} + +// HasAdaptive returns a boolean if a field has been set. +func (o *RumRateLimitConfigAttributes) HasAdaptive() bool { + return o != nil && o.Adaptive != nil +} + +// SetAdaptive gets a reference to the given RumRateLimitAdaptiveConfig and assigns it to the Adaptive field. +func (o *RumRateLimitConfigAttributes) SetAdaptive(v RumRateLimitAdaptiveConfig) { + o.Adaptive = &v +} + +// GetCustom returns the Custom field value if set, zero value otherwise. +func (o *RumRateLimitConfigAttributes) GetCustom() RumRateLimitCustomConfig { + if o == nil || o.Custom == nil { + var ret RumRateLimitCustomConfig + return ret + } + return *o.Custom +} + +// GetCustomOk returns a tuple with the Custom field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetCustomOk() (*RumRateLimitCustomConfig, bool) { + if o == nil || o.Custom == nil { + return nil, false + } + return o.Custom, true +} + +// HasCustom returns a boolean if a field has been set. +func (o *RumRateLimitConfigAttributes) HasCustom() bool { + return o != nil && o.Custom != nil +} + +// SetCustom gets a reference to the given RumRateLimitCustomConfig and assigns it to the Custom field. +func (o *RumRateLimitConfigAttributes) SetCustom(v RumRateLimitCustomConfig) { + o.Custom = &v +} + +// GetMode returns the Mode field value. +func (o *RumRateLimitConfigAttributes) GetMode() RumRateLimitMode { + if o == nil { + var ret RumRateLimitMode + return ret + } + return o.Mode +} + +// GetModeOk returns a tuple with the Mode field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetModeOk() (*RumRateLimitMode, bool) { + if o == nil { + return nil, false + } + return &o.Mode, true +} + +// SetMode sets field value. +func (o *RumRateLimitConfigAttributes) SetMode(v RumRateLimitMode) { + o.Mode = v +} + +// GetOrgId returns the OrgId field value. +func (o *RumRateLimitConfigAttributes) GetOrgId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.OrgId +} + +// GetOrgIdOk returns a tuple with the OrgId field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetOrgIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.OrgId, true +} + +// SetOrgId sets field value. +func (o *RumRateLimitConfigAttributes) SetOrgId(v int64) { + o.OrgId = v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *RumRateLimitConfigAttributes) GetUpdatedAt() string { + if o == nil || o.UpdatedAt == nil { + var ret string + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetUpdatedAtOk() (*string, bool) { + if o == nil || o.UpdatedAt == nil { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *RumRateLimitConfigAttributes) HasUpdatedAt() bool { + return o != nil && o.UpdatedAt != nil +} + +// SetUpdatedAt gets a reference to the given string and assigns it to the UpdatedAt field. +func (o *RumRateLimitConfigAttributes) SetUpdatedAt(v string) { + o.UpdatedAt = &v +} + +// GetUpdatedBy returns the UpdatedBy field value if set, zero value otherwise. +func (o *RumRateLimitConfigAttributes) GetUpdatedBy() string { + if o == nil || o.UpdatedBy == nil { + var ret string + return ret + } + return *o.UpdatedBy +} + +// GetUpdatedByOk returns a tuple with the UpdatedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigAttributes) GetUpdatedByOk() (*string, bool) { + if o == nil || o.UpdatedBy == nil { + return nil, false + } + return o.UpdatedBy, true +} + +// HasUpdatedBy returns a boolean if a field has been set. +func (o *RumRateLimitConfigAttributes) HasUpdatedBy() bool { + return o != nil && o.UpdatedBy != nil +} + +// SetUpdatedBy gets a reference to the given string and assigns it to the UpdatedBy field. +func (o *RumRateLimitConfigAttributes) SetUpdatedBy(v string) { + o.UpdatedBy = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Adaptive != nil { + toSerialize["adaptive"] = o.Adaptive + } + if o.Custom != nil { + toSerialize["custom"] = o.Custom + } + toSerialize["mode"] = o.Mode + toSerialize["org_id"] = o.OrgId + if o.UpdatedAt != nil { + toSerialize["updated_at"] = o.UpdatedAt + } + if o.UpdatedBy != nil { + toSerialize["updated_by"] = o.UpdatedBy + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Adaptive *RumRateLimitAdaptiveConfig `json:"adaptive,omitempty"` + Custom *RumRateLimitCustomConfig `json:"custom,omitempty"` + Mode *RumRateLimitMode `json:"mode"` + OrgId *int64 `json:"org_id"` + UpdatedAt *string `json:"updated_at,omitempty"` + UpdatedBy *string `json:"updated_by,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Mode == nil { + return fmt.Errorf("required field mode missing") + } + if all.OrgId == nil { + return fmt.Errorf("required field org_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"adaptive", "custom", "mode", "org_id", "updated_at", "updated_by"}) + } else { + return err + } + + hasInvalidField := false + if all.Adaptive != nil && all.Adaptive.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Adaptive = all.Adaptive + if all.Custom != nil && all.Custom.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Custom = all.Custom + if !all.Mode.IsValid() { + hasInvalidField = true + } else { + o.Mode = *all.Mode + } + o.OrgId = *all.OrgId + o.UpdatedAt = all.UpdatedAt + o.UpdatedBy = all.UpdatedBy + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_data.go b/api/datadogV2/model_rum_rate_limit_config_data.go new file mode 100644 index 00000000000..bc6aa35efa3 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigData The RUM rate limit configuration object. +type RumRateLimitConfigData struct { + // The RUM rate limit configuration properties. + Attributes RumRateLimitConfigAttributes `json:"attributes"` + // The identifier of the scope the rate limit configuration applies to. + Id string `json:"id"` + // The type of the resource, always `rum_rate_limit_config`. + Type RumRateLimitConfigType `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{} `json:"-"` +} + +// NewRumRateLimitConfigData instantiates a new RumRateLimitConfigData 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 NewRumRateLimitConfigData(attributes RumRateLimitConfigAttributes, id string, typeVar RumRateLimitConfigType) *RumRateLimitConfigData { + this := RumRateLimitConfigData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewRumRateLimitConfigDataWithDefaults instantiates a new RumRateLimitConfigData 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 NewRumRateLimitConfigDataWithDefaults() *RumRateLimitConfigData { + this := RumRateLimitConfigData{} + var typeVar RumRateLimitConfigType = RUMRATELIMITCONFIGTYPE_RUM_RATE_LIMIT_CONFIG + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *RumRateLimitConfigData) GetAttributes() RumRateLimitConfigAttributes { + if o == nil { + var ret RumRateLimitConfigAttributes + 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 *RumRateLimitConfigData) GetAttributesOk() (*RumRateLimitConfigAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *RumRateLimitConfigData) SetAttributes(v RumRateLimitConfigAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *RumRateLimitConfigData) 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 *RumRateLimitConfigData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *RumRateLimitConfigData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *RumRateLimitConfigData) GetType() RumRateLimitConfigType { + if o == nil { + var ret RumRateLimitConfigType + 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 *RumRateLimitConfigData) GetTypeOk() (*RumRateLimitConfigType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *RumRateLimitConfigData) SetType(v RumRateLimitConfigType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RumRateLimitConfigAttributes `json:"attributes"` + Id *string `json:"id"` + Type *RumRateLimitConfigType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_response.go b/api/datadogV2/model_rum_rate_limit_config_response.go new file mode 100644 index 00000000000..a2bbe45c114 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigResponse The RUM rate limit configuration response. +type RumRateLimitConfigResponse struct { + // The RUM rate limit configuration object. + Data RumRateLimitConfigData `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{} `json:"-"` +} + +// NewRumRateLimitConfigResponse instantiates a new RumRateLimitConfigResponse 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 NewRumRateLimitConfigResponse(data RumRateLimitConfigData) *RumRateLimitConfigResponse { + this := RumRateLimitConfigResponse{} + this.Data = data + return &this +} + +// NewRumRateLimitConfigResponseWithDefaults instantiates a new RumRateLimitConfigResponse 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 NewRumRateLimitConfigResponseWithDefaults() *RumRateLimitConfigResponse { + this := RumRateLimitConfigResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *RumRateLimitConfigResponse) GetData() RumRateLimitConfigData { + if o == nil { + var ret RumRateLimitConfigData + 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 *RumRateLimitConfigResponse) GetDataOk() (*RumRateLimitConfigData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *RumRateLimitConfigResponse) SetData(v RumRateLimitConfigData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RumRateLimitConfigData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_type.go b/api/datadogV2/model_rum_rate_limit_config_type.go new file mode 100644 index 00000000000..e4eda678fce --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigType The type of the resource, always `rum_rate_limit_config`. +type RumRateLimitConfigType string + +// List of RumRateLimitConfigType. +const ( + RUMRATELIMITCONFIGTYPE_RUM_RATE_LIMIT_CONFIG RumRateLimitConfigType = "rum_rate_limit_config" +) + +var allowedRumRateLimitConfigTypeEnumValues = []RumRateLimitConfigType{ + RUMRATELIMITCONFIGTYPE_RUM_RATE_LIMIT_CONFIG, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RumRateLimitConfigType) GetAllowedValues() []RumRateLimitConfigType { + return allowedRumRateLimitConfigTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RumRateLimitConfigType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RumRateLimitConfigType(value) + return nil +} + +// NewRumRateLimitConfigTypeFromValue returns a pointer to a valid RumRateLimitConfigType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRumRateLimitConfigTypeFromValue(v string) (*RumRateLimitConfigType, error) { + ev := RumRateLimitConfigType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RumRateLimitConfigType: valid values are %v", v, allowedRumRateLimitConfigTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RumRateLimitConfigType) IsValid() bool { + for _, existing := range allowedRumRateLimitConfigTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RumRateLimitConfigType value. +func (v RumRateLimitConfigType) Ptr() *RumRateLimitConfigType { + return &v +} diff --git a/api/datadogV2/model_rum_rate_limit_config_update_attributes.go b/api/datadogV2/model_rum_rate_limit_config_update_attributes.go new file mode 100644 index 00000000000..553b86ab8c1 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_update_attributes.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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigUpdateAttributes The RUM rate limit configuration properties to create or update. +type RumRateLimitConfigUpdateAttributes struct { + // The configuration used when `mode` is `adaptive`. + Adaptive *RumRateLimitAdaptiveConfig `json:"adaptive,omitempty"` + // The configuration used when `mode` is `custom`. + Custom *RumRateLimitCustomConfig `json:"custom,omitempty"` + // The rate limit mode. `custom` enforces a fixed session limit, while + // `adaptive` dynamically adjusts retention. + Mode RumRateLimitMode `json:"mode"` + // 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{} `json:"-"` +} + +// NewRumRateLimitConfigUpdateAttributes instantiates a new RumRateLimitConfigUpdateAttributes 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 NewRumRateLimitConfigUpdateAttributes(mode RumRateLimitMode) *RumRateLimitConfigUpdateAttributes { + this := RumRateLimitConfigUpdateAttributes{} + this.Mode = mode + return &this +} + +// NewRumRateLimitConfigUpdateAttributesWithDefaults instantiates a new RumRateLimitConfigUpdateAttributes 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 NewRumRateLimitConfigUpdateAttributesWithDefaults() *RumRateLimitConfigUpdateAttributes { + this := RumRateLimitConfigUpdateAttributes{} + return &this +} + +// GetAdaptive returns the Adaptive field value if set, zero value otherwise. +func (o *RumRateLimitConfigUpdateAttributes) GetAdaptive() RumRateLimitAdaptiveConfig { + if o == nil || o.Adaptive == nil { + var ret RumRateLimitAdaptiveConfig + return ret + } + return *o.Adaptive +} + +// GetAdaptiveOk returns a tuple with the Adaptive field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigUpdateAttributes) GetAdaptiveOk() (*RumRateLimitAdaptiveConfig, bool) { + if o == nil || o.Adaptive == nil { + return nil, false + } + return o.Adaptive, true +} + +// HasAdaptive returns a boolean if a field has been set. +func (o *RumRateLimitConfigUpdateAttributes) HasAdaptive() bool { + return o != nil && o.Adaptive != nil +} + +// SetAdaptive gets a reference to the given RumRateLimitAdaptiveConfig and assigns it to the Adaptive field. +func (o *RumRateLimitConfigUpdateAttributes) SetAdaptive(v RumRateLimitAdaptiveConfig) { + o.Adaptive = &v +} + +// GetCustom returns the Custom field value if set, zero value otherwise. +func (o *RumRateLimitConfigUpdateAttributes) GetCustom() RumRateLimitCustomConfig { + if o == nil || o.Custom == nil { + var ret RumRateLimitCustomConfig + return ret + } + return *o.Custom +} + +// GetCustomOk returns a tuple with the Custom field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigUpdateAttributes) GetCustomOk() (*RumRateLimitCustomConfig, bool) { + if o == nil || o.Custom == nil { + return nil, false + } + return o.Custom, true +} + +// HasCustom returns a boolean if a field has been set. +func (o *RumRateLimitConfigUpdateAttributes) HasCustom() bool { + return o != nil && o.Custom != nil +} + +// SetCustom gets a reference to the given RumRateLimitCustomConfig and assigns it to the Custom field. +func (o *RumRateLimitConfigUpdateAttributes) SetCustom(v RumRateLimitCustomConfig) { + o.Custom = &v +} + +// GetMode returns the Mode field value. +func (o *RumRateLimitConfigUpdateAttributes) GetMode() RumRateLimitMode { + if o == nil { + var ret RumRateLimitMode + return ret + } + return o.Mode +} + +// GetModeOk returns a tuple with the Mode field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitConfigUpdateAttributes) GetModeOk() (*RumRateLimitMode, bool) { + if o == nil { + return nil, false + } + return &o.Mode, true +} + +// SetMode sets field value. +func (o *RumRateLimitConfigUpdateAttributes) SetMode(v RumRateLimitMode) { + o.Mode = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Adaptive != nil { + toSerialize["adaptive"] = o.Adaptive + } + if o.Custom != nil { + toSerialize["custom"] = o.Custom + } + toSerialize["mode"] = o.Mode + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Adaptive *RumRateLimitAdaptiveConfig `json:"adaptive,omitempty"` + Custom *RumRateLimitCustomConfig `json:"custom,omitempty"` + Mode *RumRateLimitMode `json:"mode"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Mode == nil { + return fmt.Errorf("required field mode missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"adaptive", "custom", "mode"}) + } else { + return err + } + + hasInvalidField := false + if all.Adaptive != nil && all.Adaptive.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Adaptive = all.Adaptive + if all.Custom != nil && all.Custom.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Custom = all.Custom + if !all.Mode.IsValid() { + hasInvalidField = true + } else { + o.Mode = *all.Mode + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_update_data.go b/api/datadogV2/model_rum_rate_limit_config_update_data.go new file mode 100644 index 00000000000..4d6b3558389 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_update_data.go @@ -0,0 +1,181 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigUpdateData The RUM rate limit configuration to create or update. +type RumRateLimitConfigUpdateData struct { + // The RUM rate limit configuration properties to create or update. + Attributes RumRateLimitConfigUpdateAttributes `json:"attributes"` + // The identifier of the scope the rate limit configuration applies to. + // Must match `scope_id` in the path. + Id string `json:"id"` + // The type of the resource, always `rum_rate_limit_config`. + Type RumRateLimitConfigType `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{} `json:"-"` +} + +// NewRumRateLimitConfigUpdateData instantiates a new RumRateLimitConfigUpdateData 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 NewRumRateLimitConfigUpdateData(attributes RumRateLimitConfigUpdateAttributes, id string, typeVar RumRateLimitConfigType) *RumRateLimitConfigUpdateData { + this := RumRateLimitConfigUpdateData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewRumRateLimitConfigUpdateDataWithDefaults instantiates a new RumRateLimitConfigUpdateData 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 NewRumRateLimitConfigUpdateDataWithDefaults() *RumRateLimitConfigUpdateData { + this := RumRateLimitConfigUpdateData{} + var typeVar RumRateLimitConfigType = RUMRATELIMITCONFIGTYPE_RUM_RATE_LIMIT_CONFIG + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *RumRateLimitConfigUpdateData) GetAttributes() RumRateLimitConfigUpdateAttributes { + if o == nil { + var ret RumRateLimitConfigUpdateAttributes + 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 *RumRateLimitConfigUpdateData) GetAttributesOk() (*RumRateLimitConfigUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *RumRateLimitConfigUpdateData) SetAttributes(v RumRateLimitConfigUpdateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *RumRateLimitConfigUpdateData) 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 *RumRateLimitConfigUpdateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *RumRateLimitConfigUpdateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *RumRateLimitConfigUpdateData) GetType() RumRateLimitConfigType { + if o == nil { + var ret RumRateLimitConfigType + 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 *RumRateLimitConfigUpdateData) GetTypeOk() (*RumRateLimitConfigType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *RumRateLimitConfigUpdateData) SetType(v RumRateLimitConfigType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigUpdateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RumRateLimitConfigUpdateAttributes `json:"attributes"` + Id *string `json:"id"` + Type *RumRateLimitConfigType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_config_update_request.go b/api/datadogV2/model_rum_rate_limit_config_update_request.go new file mode 100644 index 00000000000..120c802d962 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_config_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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitConfigUpdateRequest The body of a request to create or update a RUM rate limit configuration. +type RumRateLimitConfigUpdateRequest struct { + // The RUM rate limit configuration to create or update. + Data RumRateLimitConfigUpdateData `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{} `json:"-"` +} + +// NewRumRateLimitConfigUpdateRequest instantiates a new RumRateLimitConfigUpdateRequest 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 NewRumRateLimitConfigUpdateRequest(data RumRateLimitConfigUpdateData) *RumRateLimitConfigUpdateRequest { + this := RumRateLimitConfigUpdateRequest{} + this.Data = data + return &this +} + +// NewRumRateLimitConfigUpdateRequestWithDefaults instantiates a new RumRateLimitConfigUpdateRequest 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 NewRumRateLimitConfigUpdateRequestWithDefaults() *RumRateLimitConfigUpdateRequest { + this := RumRateLimitConfigUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *RumRateLimitConfigUpdateRequest) GetData() RumRateLimitConfigUpdateData { + if o == nil { + var ret RumRateLimitConfigUpdateData + 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 *RumRateLimitConfigUpdateRequest) GetDataOk() (*RumRateLimitConfigUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *RumRateLimitConfigUpdateRequest) SetData(v RumRateLimitConfigUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitConfigUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitConfigUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RumRateLimitConfigUpdateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_custom_config.go b/api/datadogV2/model_rum_rate_limit_custom_config.go new file mode 100644 index 00000000000..214454d7981 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_custom_config.go @@ -0,0 +1,243 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitCustomConfig The configuration used when `mode` is `custom`. +type RumRateLimitCustomConfig struct { + // The time of day when the daily quota resets, in `HH:MM` 24-hour format. + DailyResetTime string `json:"daily_reset_time"` + // The timezone offset used for the daily reset time, in `±HH:MM` format. + DailyResetTimezone string `json:"daily_reset_timezone"` + // The action to take when the session quota is reached. + QuotaReachedAction RumRateLimitQuotaReachedAction `json:"quota_reached_action"` + // The maximum number of sessions allowed within the window. + SessionLimit int64 `json:"session_limit"` + // The window type over which the session limit is enforced. + WindowType RumRateLimitWindowType `json:"window_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{} `json:"-"` +} + +// NewRumRateLimitCustomConfig instantiates a new RumRateLimitCustomConfig 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 NewRumRateLimitCustomConfig(dailyResetTime string, dailyResetTimezone string, quotaReachedAction RumRateLimitQuotaReachedAction, sessionLimit int64, windowType RumRateLimitWindowType) *RumRateLimitCustomConfig { + this := RumRateLimitCustomConfig{} + this.DailyResetTime = dailyResetTime + this.DailyResetTimezone = dailyResetTimezone + this.QuotaReachedAction = quotaReachedAction + this.SessionLimit = sessionLimit + this.WindowType = windowType + return &this +} + +// NewRumRateLimitCustomConfigWithDefaults instantiates a new RumRateLimitCustomConfig 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 NewRumRateLimitCustomConfigWithDefaults() *RumRateLimitCustomConfig { + this := RumRateLimitCustomConfig{} + return &this +} + +// GetDailyResetTime returns the DailyResetTime field value. +func (o *RumRateLimitCustomConfig) GetDailyResetTime() string { + if o == nil { + var ret string + return ret + } + return o.DailyResetTime +} + +// GetDailyResetTimeOk returns a tuple with the DailyResetTime field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitCustomConfig) GetDailyResetTimeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DailyResetTime, true +} + +// SetDailyResetTime sets field value. +func (o *RumRateLimitCustomConfig) SetDailyResetTime(v string) { + o.DailyResetTime = v +} + +// GetDailyResetTimezone returns the DailyResetTimezone field value. +func (o *RumRateLimitCustomConfig) GetDailyResetTimezone() string { + if o == nil { + var ret string + return ret + } + return o.DailyResetTimezone +} + +// GetDailyResetTimezoneOk returns a tuple with the DailyResetTimezone field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitCustomConfig) GetDailyResetTimezoneOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DailyResetTimezone, true +} + +// SetDailyResetTimezone sets field value. +func (o *RumRateLimitCustomConfig) SetDailyResetTimezone(v string) { + o.DailyResetTimezone = v +} + +// GetQuotaReachedAction returns the QuotaReachedAction field value. +func (o *RumRateLimitCustomConfig) GetQuotaReachedAction() RumRateLimitQuotaReachedAction { + if o == nil { + var ret RumRateLimitQuotaReachedAction + return ret + } + return o.QuotaReachedAction +} + +// GetQuotaReachedActionOk returns a tuple with the QuotaReachedAction field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitCustomConfig) GetQuotaReachedActionOk() (*RumRateLimitQuotaReachedAction, bool) { + if o == nil { + return nil, false + } + return &o.QuotaReachedAction, true +} + +// SetQuotaReachedAction sets field value. +func (o *RumRateLimitCustomConfig) SetQuotaReachedAction(v RumRateLimitQuotaReachedAction) { + o.QuotaReachedAction = v +} + +// GetSessionLimit returns the SessionLimit field value. +func (o *RumRateLimitCustomConfig) GetSessionLimit() int64 { + if o == nil { + var ret int64 + return ret + } + return o.SessionLimit +} + +// GetSessionLimitOk returns a tuple with the SessionLimit field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitCustomConfig) GetSessionLimitOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.SessionLimit, true +} + +// SetSessionLimit sets field value. +func (o *RumRateLimitCustomConfig) SetSessionLimit(v int64) { + o.SessionLimit = v +} + +// GetWindowType returns the WindowType field value. +func (o *RumRateLimitCustomConfig) GetWindowType() RumRateLimitWindowType { + if o == nil { + var ret RumRateLimitWindowType + return ret + } + return o.WindowType +} + +// GetWindowTypeOk returns a tuple with the WindowType field value +// and a boolean to check if the value has been set. +func (o *RumRateLimitCustomConfig) GetWindowTypeOk() (*RumRateLimitWindowType, bool) { + if o == nil { + return nil, false + } + return &o.WindowType, true +} + +// SetWindowType sets field value. +func (o *RumRateLimitCustomConfig) SetWindowType(v RumRateLimitWindowType) { + o.WindowType = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RumRateLimitCustomConfig) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["daily_reset_time"] = o.DailyResetTime + toSerialize["daily_reset_timezone"] = o.DailyResetTimezone + toSerialize["quota_reached_action"] = o.QuotaReachedAction + toSerialize["session_limit"] = o.SessionLimit + toSerialize["window_type"] = o.WindowType + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RumRateLimitCustomConfig) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DailyResetTime *string `json:"daily_reset_time"` + DailyResetTimezone *string `json:"daily_reset_timezone"` + QuotaReachedAction *RumRateLimitQuotaReachedAction `json:"quota_reached_action"` + SessionLimit *int64 `json:"session_limit"` + WindowType *RumRateLimitWindowType `json:"window_type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.DailyResetTime == nil { + return fmt.Errorf("required field daily_reset_time missing") + } + if all.DailyResetTimezone == nil { + return fmt.Errorf("required field daily_reset_timezone missing") + } + if all.QuotaReachedAction == nil { + return fmt.Errorf("required field quota_reached_action missing") + } + if all.SessionLimit == nil { + return fmt.Errorf("required field session_limit missing") + } + if all.WindowType == nil { + return fmt.Errorf("required field window_type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"daily_reset_time", "daily_reset_timezone", "quota_reached_action", "session_limit", "window_type"}) + } else { + return err + } + + hasInvalidField := false + o.DailyResetTime = *all.DailyResetTime + o.DailyResetTimezone = *all.DailyResetTimezone + if !all.QuotaReachedAction.IsValid() { + hasInvalidField = true + } else { + o.QuotaReachedAction = *all.QuotaReachedAction + } + o.SessionLimit = *all.SessionLimit + if !all.WindowType.IsValid() { + hasInvalidField = true + } else { + o.WindowType = *all.WindowType + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_rum_rate_limit_mode.go b/api/datadogV2/model_rum_rate_limit_mode.go new file mode 100644 index 00000000000..f640843cc02 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_mode.go @@ -0,0 +1,67 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitMode The rate limit mode. `custom` enforces a fixed session limit, while +// `adaptive` dynamically adjusts retention. +type RumRateLimitMode string + +// List of RumRateLimitMode. +const ( + RUMRATELIMITMODE_CUSTOM RumRateLimitMode = "custom" + RUMRATELIMITMODE_ADAPTIVE RumRateLimitMode = "adaptive" +) + +var allowedRumRateLimitModeEnumValues = []RumRateLimitMode{ + RUMRATELIMITMODE_CUSTOM, + RUMRATELIMITMODE_ADAPTIVE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RumRateLimitMode) GetAllowedValues() []RumRateLimitMode { + return allowedRumRateLimitModeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RumRateLimitMode) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RumRateLimitMode(value) + return nil +} + +// NewRumRateLimitModeFromValue returns a pointer to a valid RumRateLimitMode +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRumRateLimitModeFromValue(v string) (*RumRateLimitMode, error) { + ev := RumRateLimitMode(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RumRateLimitMode: valid values are %v", v, allowedRumRateLimitModeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RumRateLimitMode) IsValid() bool { + for _, existing := range allowedRumRateLimitModeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RumRateLimitMode value. +func (v RumRateLimitMode) Ptr() *RumRateLimitMode { + return &v +} diff --git a/api/datadogV2/model_rum_rate_limit_quota_reached_action.go b/api/datadogV2/model_rum_rate_limit_quota_reached_action.go new file mode 100644 index 00000000000..faa9b05a7a1 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_quota_reached_action.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitQuotaReachedAction The action to take when the session quota is reached. +type RumRateLimitQuotaReachedAction string + +// List of RumRateLimitQuotaReachedAction. +const ( + RUMRATELIMITQUOTAREACHEDACTION_STOP RumRateLimitQuotaReachedAction = "stop" + RUMRATELIMITQUOTAREACHEDACTION_SLOWDOWN RumRateLimitQuotaReachedAction = "slowdown" +) + +var allowedRumRateLimitQuotaReachedActionEnumValues = []RumRateLimitQuotaReachedAction{ + RUMRATELIMITQUOTAREACHEDACTION_STOP, + RUMRATELIMITQUOTAREACHEDACTION_SLOWDOWN, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RumRateLimitQuotaReachedAction) GetAllowedValues() []RumRateLimitQuotaReachedAction { + return allowedRumRateLimitQuotaReachedActionEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RumRateLimitQuotaReachedAction) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RumRateLimitQuotaReachedAction(value) + return nil +} + +// NewRumRateLimitQuotaReachedActionFromValue returns a pointer to a valid RumRateLimitQuotaReachedAction +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRumRateLimitQuotaReachedActionFromValue(v string) (*RumRateLimitQuotaReachedAction, error) { + ev := RumRateLimitQuotaReachedAction(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RumRateLimitQuotaReachedAction: valid values are %v", v, allowedRumRateLimitQuotaReachedActionEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RumRateLimitQuotaReachedAction) IsValid() bool { + for _, existing := range allowedRumRateLimitQuotaReachedActionEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RumRateLimitQuotaReachedAction value. +func (v RumRateLimitQuotaReachedAction) Ptr() *RumRateLimitQuotaReachedAction { + return &v +} diff --git a/api/datadogV2/model_rum_rate_limit_scope_type.go b/api/datadogV2/model_rum_rate_limit_scope_type.go new file mode 100644 index 00000000000..69a3b7a1934 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_scope_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitScopeType The type of scope the rate limit configuration applies to. +type RumRateLimitScopeType string + +// List of RumRateLimitScopeType. +const ( + RUMRATELIMITSCOPETYPE_APPLICATION RumRateLimitScopeType = "application" +) + +var allowedRumRateLimitScopeTypeEnumValues = []RumRateLimitScopeType{ + RUMRATELIMITSCOPETYPE_APPLICATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RumRateLimitScopeType) GetAllowedValues() []RumRateLimitScopeType { + return allowedRumRateLimitScopeTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RumRateLimitScopeType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RumRateLimitScopeType(value) + return nil +} + +// NewRumRateLimitScopeTypeFromValue returns a pointer to a valid RumRateLimitScopeType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRumRateLimitScopeTypeFromValue(v string) (*RumRateLimitScopeType, error) { + ev := RumRateLimitScopeType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RumRateLimitScopeType: valid values are %v", v, allowedRumRateLimitScopeTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RumRateLimitScopeType) IsValid() bool { + for _, existing := range allowedRumRateLimitScopeTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RumRateLimitScopeType value. +func (v RumRateLimitScopeType) Ptr() *RumRateLimitScopeType { + return &v +} diff --git a/api/datadogV2/model_rum_rate_limit_window_type.go b/api/datadogV2/model_rum_rate_limit_window_type.go new file mode 100644 index 00000000000..3723dd1f7b2 --- /dev/null +++ b/api/datadogV2/model_rum_rate_limit_window_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RumRateLimitWindowType The window type over which the session limit is enforced. +type RumRateLimitWindowType string + +// List of RumRateLimitWindowType. +const ( + RUMRATELIMITWINDOWTYPE_DAILY RumRateLimitWindowType = "daily" +) + +var allowedRumRateLimitWindowTypeEnumValues = []RumRateLimitWindowType{ + RUMRATELIMITWINDOWTYPE_DAILY, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *RumRateLimitWindowType) GetAllowedValues() []RumRateLimitWindowType { + return allowedRumRateLimitWindowTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *RumRateLimitWindowType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = RumRateLimitWindowType(value) + return nil +} + +// NewRumRateLimitWindowTypeFromValue returns a pointer to a valid RumRateLimitWindowType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewRumRateLimitWindowTypeFromValue(v string) (*RumRateLimitWindowType, error) { + ev := RumRateLimitWindowType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for RumRateLimitWindowType: valid values are %v", v, allowedRumRateLimitWindowTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v RumRateLimitWindowType) IsValid() bool { + for _, existing := range allowedRumRateLimitWindowTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to RumRateLimitWindowType value. +func (v RumRateLimitWindowType) Ptr() *RumRateLimitWindowType { + return &v +} diff --git a/examples/v2/rum-rate-limit/DeleteRumRateLimitConfig.go b/examples/v2/rum-rate-limit/DeleteRumRateLimitConfig.go new file mode 100644 index 00000000000..71dd3f700d4 --- /dev/null +++ b/examples/v2/rum-rate-limit/DeleteRumRateLimitConfig.go @@ -0,0 +1,26 @@ +// Delete a RUM rate limit configuration returns "No Content" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteRumRateLimitConfig", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewRumRateLimitApi(apiClient) + r, err := api.DeleteRumRateLimitConfig(ctx, datadogV2.RUMRATELIMITSCOPETYPE_APPLICATION, "cd73a516-a481-4af5-8352-9b577465c77b") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `RumRateLimitApi.DeleteRumRateLimitConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/rum-rate-limit/GetRumRateLimitConfig.go b/examples/v2/rum-rate-limit/GetRumRateLimitConfig.go new file mode 100644 index 00000000000..81cb3196e16 --- /dev/null +++ b/examples/v2/rum-rate-limit/GetRumRateLimitConfig.go @@ -0,0 +1,30 @@ +// Get a RUM rate limit configuration 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() + configuration.SetUnstableOperationEnabled("v2.GetRumRateLimitConfig", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewRumRateLimitApi(apiClient) + resp, r, err := api.GetRumRateLimitConfig(ctx, datadogV2.RUMRATELIMITSCOPETYPE_APPLICATION, "cd73a516-a481-4af5-8352-9b577465c77b") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `RumRateLimitApi.GetRumRateLimitConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `RumRateLimitApi.GetRumRateLimitConfig`:\n%s\n", responseContent) +} diff --git a/examples/v2/rum-rate-limit/UpdateRumRateLimitConfig.go b/examples/v2/rum-rate-limit/UpdateRumRateLimitConfig.go new file mode 100644 index 00000000000..c55e3f950e6 --- /dev/null +++ b/examples/v2/rum-rate-limit/UpdateRumRateLimitConfig.go @@ -0,0 +1,49 @@ +// Create or update a RUM rate limit configuration 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.RumRateLimitConfigUpdateRequest{ + Data: datadogV2.RumRateLimitConfigUpdateData{ + Attributes: datadogV2.RumRateLimitConfigUpdateAttributes{ + Adaptive: &datadogV2.RumRateLimitAdaptiveConfig{ + MaxRetentionRate: 0.5, + }, + Custom: &datadogV2.RumRateLimitCustomConfig{ + DailyResetTime: "08:00", + DailyResetTimezone: "+09:00", + QuotaReachedAction: datadogV2.RUMRATELIMITQUOTAREACHEDACTION_STOP, + SessionLimit: 1000000, + WindowType: datadogV2.RUMRATELIMITWINDOWTYPE_DAILY, + }, + Mode: datadogV2.RUMRATELIMITMODE_CUSTOM, + }, + Id: "cd73a516-a481-4af5-8352-9b577465c77b", + Type: datadogV2.RUMRATELIMITCONFIGTYPE_RUM_RATE_LIMIT_CONFIG, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateRumRateLimitConfig", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewRumRateLimitApi(apiClient) + resp, r, err := api.UpdateRumRateLimitConfig(ctx, datadogV2.RUMRATELIMITSCOPETYPE_APPLICATION, "cd73a516-a481-4af5-8352-9b577465c77b", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `RumRateLimitApi.UpdateRumRateLimitConfig`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `RumRateLimitApi.UpdateRumRateLimitConfig`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 2fac3efcda0..b3cd3bbbd91 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -145,6 +145,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "RUMRetentionFiltersHardcodedApi": reflect.ValueOf(datadogV2.NewRUMRetentionFiltersHardcodedApi), "RumRetentionFiltersApi": reflect.ValueOf(datadogV2.NewRumRetentionFiltersApi), "RumMetricsApi": reflect.ValueOf(datadogV2.NewRumMetricsApi), + "RumRateLimitApi": reflect.ValueOf(datadogV2.NewRumRateLimitApi), "RUMInsightsApi": reflect.ValueOf(datadogV2.NewRUMInsightsApi), "RumReplayPlaylistsApi": reflect.ValueOf(datadogV2.NewRumReplayPlaylistsApi), "RumReplaySessionsApi": reflect.ValueOf(datadogV2.NewRumReplaySessionsApi), diff --git a/tests/scenarios/features/v2/rum_rate_limit.feature b/tests/scenarios/features/v2/rum_rate_limit.feature new file mode 100644 index 00000000000..90869ed1782 --- /dev/null +++ b/tests/scenarios/features/v2/rum_rate_limit.feature @@ -0,0 +1,93 @@ +@endpoint(rum-rate-limit) @endpoint(rum-rate-limit-v2) +Feature: Rum Rate Limit + Manage RUM rate limit configurations for your organization's RUM + applications. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "RumRateLimit" API + + @generated @skip @team:DataDog/rum-backend + Scenario: Create or update a RUM rate limit configuration returns "Bad Request" response + Given operation "UpdateRumRateLimitConfig" enabled + And new "UpdateRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"adaptive": {"max_retention_rate": 0.5}, "custom": {"daily_reset_time": "08:00", "daily_reset_timezone": "+09:00", "quota_reached_action": "stop", "session_limit": 1000000, "window_type": "daily"}, "mode": "custom"}, "id": "cd73a516-a481-4af5-8352-9b577465c77b", "type": "rum_rate_limit_config"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/rum-backend + Scenario: Create or update a RUM rate limit configuration returns "Not Found" response + Given operation "UpdateRumRateLimitConfig" enabled + And new "UpdateRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"adaptive": {"max_retention_rate": 0.5}, "custom": {"daily_reset_time": "08:00", "daily_reset_timezone": "+09:00", "quota_reached_action": "stop", "session_limit": 1000000, "window_type": "daily"}, "mode": "custom"}, "id": "cd73a516-a481-4af5-8352-9b577465c77b", "type": "rum_rate_limit_config"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/rum-backend + Scenario: Create or update a RUM rate limit configuration returns "OK" response + Given operation "UpdateRumRateLimitConfig" enabled + And new "UpdateRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"adaptive": {"max_retention_rate": 0.5}, "custom": {"daily_reset_time": "08:00", "daily_reset_timezone": "+09:00", "quota_reached_action": "stop", "session_limit": 1000000, "window_type": "daily"}, "mode": "custom"}, "id": "cd73a516-a481-4af5-8352-9b577465c77b", "type": "rum_rate_limit_config"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/rum-backend + Scenario: Delete a RUM rate limit configuration returns "Bad Request" response + Given operation "DeleteRumRateLimitConfig" enabled + And new "DeleteRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/rum-backend + Scenario: Delete a RUM rate limit configuration returns "No Content" response + Given operation "DeleteRumRateLimitConfig" enabled + And new "DeleteRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/rum-backend + Scenario: Delete a RUM rate limit configuration returns "Not Found" response + Given operation "DeleteRumRateLimitConfig" enabled + And new "DeleteRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/rum-backend + Scenario: Get a RUM rate limit configuration returns "Bad Request" response + Given operation "GetRumRateLimitConfig" enabled + And new "GetRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/rum-backend + Scenario: Get a RUM rate limit configuration returns "Not Found" response + Given operation "GetRumRateLimitConfig" enabled + And new "GetRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/rum-backend + Scenario: Get a RUM rate limit configuration returns "OK" response + Given operation "GetRumRateLimitConfig" enabled + And new "GetRumRateLimitConfig" request + And request contains "scope_type" parameter from "REPLACE.ME" + And request contains "scope_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index bf8c214ecee..86948cc32b7 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -6181,6 +6181,24 @@ "type": "idempotent" } }, + "DeleteRumRateLimitConfig": { + "tag": "Rum Rate Limit", + "undo": { + "type": "idempotent" + } + }, + "GetRumRateLimitConfig": { + "tag": "Rum Rate Limit", + "undo": { + "type": "safe" + } + }, + "UpdateRumRateLimitConfig": { + "tag": "Rum Rate Limit", + "undo": { + "type": "idempotent" + } + }, "ListRUMEvents": { "tag": "RUM", "undo": {