From 61612c32f25b0d9d85429fc6e4742892239dc521 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 28 May 2026 15:07:06 +0000 Subject: [PATCH] Regenerate client from commit 597f461 of spec repo --- .generator/schemas/v2/openapi.yaml | 863 ++++++++++++++++++ api/datadog/configuration.go | 4 + api/datadogV2/api_cloud_cost_management.go | 351 +++++++ api/datadogV2/api_o_auth2_client_public.go | 392 ++++++++ api/datadogV2/doc.go | 8 + .../model_cost_tag_description_response.go | 110 +++ ...del_cost_tag_description_upsert_request.go | 110 +++ ...ost_tag_description_upsert_request_data.go | 183 ++++ ...cription_upsert_request_data_attributes.go | 136 +++ ..._generate_cost_tag_description_response.go | 110 +++ .../model_generated_cost_tag_description.go | 180 ++++ ...nerated_cost_tag_description_attributes.go | 101 ++ ...del_generated_cost_tag_description_type.go | 64 ++ .../model_o_auth_client_registration_error.go | 133 +++ ...l_o_auth_client_registration_grant_type.go | 66 ++ ...odel_o_auth_client_registration_request.go | 449 +++++++++ ...del_o_auth_client_registration_response.go | 263 ++++++ ..._auth_client_registration_response_type.go | 64 ++ api/datadogV2/model_o_auth_oidc_scope.go | 70 ++ .../model_o_auth_scopes_restriction.go | 183 ++++ ...odel_o_auth_scopes_restriction_response.go | 110 +++ ..._scopes_restriction_response_attributes.go | 138 +++ ...o_auth_scopes_restriction_response_data.go | 182 ++++ .../model_o_auth_scopes_restriction_type.go | 64 ++ ...l_upsert_o_auth_scopes_restriction_data.go | 151 +++ ...auth_scopes_restriction_data_attributes.go | 138 +++ ...psert_o_auth_scopes_restriction_request.go | 110 +++ ...l_upsert_o_auth_scopes_restriction_type.go | 64 ++ .../DeleteCostTagDescriptionByKey.go | 25 + .../GenerateCostTagDescriptionByKey.go | 29 + .../GetCostTagDescriptionByKey.go | 29 + .../UpsertCostTagDescriptionByKey.go | 35 + .../DeleteScopesRestriction.go | 27 + .../GetScopesRestriction.go | 31 + .../RegisterOAuthClient.go | 50 + .../UpsertScopesRestriction.go | 46 + tests/scenarios/api_mappings.go | 1 + .../features/v2/cloud_cost_management.feature | 65 ++ .../features/v2/oauth2_client_public.feature | 100 ++ tests/scenarios/features/v2/undo.json | 48 + 40 files changed, 5283 insertions(+) create mode 100644 api/datadogV2/api_o_auth2_client_public.go create mode 100644 api/datadogV2/model_cost_tag_description_response.go create mode 100644 api/datadogV2/model_cost_tag_description_upsert_request.go create mode 100644 api/datadogV2/model_cost_tag_description_upsert_request_data.go create mode 100644 api/datadogV2/model_cost_tag_description_upsert_request_data_attributes.go create mode 100644 api/datadogV2/model_generate_cost_tag_description_response.go create mode 100644 api/datadogV2/model_generated_cost_tag_description.go create mode 100644 api/datadogV2/model_generated_cost_tag_description_attributes.go create mode 100644 api/datadogV2/model_generated_cost_tag_description_type.go create mode 100644 api/datadogV2/model_o_auth_client_registration_error.go create mode 100644 api/datadogV2/model_o_auth_client_registration_grant_type.go create mode 100644 api/datadogV2/model_o_auth_client_registration_request.go create mode 100644 api/datadogV2/model_o_auth_client_registration_response.go create mode 100644 api/datadogV2/model_o_auth_client_registration_response_type.go create mode 100644 api/datadogV2/model_o_auth_oidc_scope.go create mode 100644 api/datadogV2/model_o_auth_scopes_restriction.go create mode 100644 api/datadogV2/model_o_auth_scopes_restriction_response.go create mode 100644 api/datadogV2/model_o_auth_scopes_restriction_response_attributes.go create mode 100644 api/datadogV2/model_o_auth_scopes_restriction_response_data.go create mode 100644 api/datadogV2/model_o_auth_scopes_restriction_type.go create mode 100644 api/datadogV2/model_upsert_o_auth_scopes_restriction_data.go create mode 100644 api/datadogV2/model_upsert_o_auth_scopes_restriction_data_attributes.go create mode 100644 api/datadogV2/model_upsert_o_auth_scopes_restriction_request.go create mode 100644 api/datadogV2/model_upsert_o_auth_scopes_restriction_type.go create mode 100644 examples/v2/cloud-cost-management/DeleteCostTagDescriptionByKey.go create mode 100644 examples/v2/cloud-cost-management/GenerateCostTagDescriptionByKey.go create mode 100644 examples/v2/cloud-cost-management/GetCostTagDescriptionByKey.go create mode 100644 examples/v2/cloud-cost-management/UpsertCostTagDescriptionByKey.go create mode 100644 examples/v2/oauth2-client-public/DeleteScopesRestriction.go create mode 100644 examples/v2/oauth2-client-public/GetScopesRestriction.go create mode 100644 examples/v2/oauth2-client-public/RegisterOAuthClient.go create mode 100644 examples/v2/oauth2-client-public/UpsertScopesRestriction.go create mode 100644 tests/scenarios/features/v2/oauth2_client_public.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index dede702aea7..bc16917af1e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1034,6 +1034,15 @@ components: required: true schema: type: string + OAuthClientUUIDPathParameter: + description: UUID of the OAuth2 client. + in: path + name: client_uuid + required: true + schema: + example: fafa8e1c-36a5-11f0-a83d-da7ad0900001 + format: uuid + type: string OnDemandTaskId: description: The UUID of the task. example: "6d09294c-9ad9-42fd-a759-a0c1599b4828" @@ -19553,6 +19562,25 @@ components: - tag_key - updated_at type: object + CostTagDescriptionResponse: + description: Single Cloud Cost Management tag key description returned by the get-by-key endpoint. + example: + data: + attributes: + cloud: aws + created_at: "2026-01-01T12:00:00Z" + description: AWS account that owns this cost. + source: human + tag_key: account_id + updated_at: "2026-01-01T12:00:00Z" + id: account_id + type: cost_tag_description + properties: + data: + $ref: "#/components/schemas/CostTagDescription" + required: + - data + type: object CostTagDescriptionSource: description: Origin of the description. `human` indicates the description was written by a user, `ai_generated` was produced by AI, and `datadog` is a default supplied by Datadog. enum: @@ -19574,6 +19602,50 @@ components: type: string x-enum-varnames: - COST_TAG_DESCRIPTION + CostTagDescriptionUpsertRequest: + description: Request body for creating or updating a Cloud Cost Management tag key description. + example: + data: + attributes: + cloud: aws + description: AWS account that owns this cost. + id: account_id + type: cost_tag_description + properties: + data: + $ref: "#/components/schemas/CostTagDescriptionUpsertRequestData" + required: + - data + type: object + CostTagDescriptionUpsertRequestData: + description: Resource envelope carrying the tag key description being upserted. The `id` is informational; the authoritative tag key is taken from the URL path. + properties: + attributes: + $ref: "#/components/schemas/CostTagDescriptionUpsertRequestDataAttributes" + id: + description: Identifier of the tag key the description applies to. Matches the `tag_key` path parameter. + example: account_id + type: string + type: + $ref: "#/components/schemas/CostTagDescriptionType" + required: + - attributes + - type + type: object + CostTagDescriptionUpsertRequestDataAttributes: + description: Mutable attributes set when creating or updating a Cloud Cost Management tag key description. + properties: + cloud: + description: Cloud provider this description applies to (for example, `aws`). Omit to set the cross-cloud default for the tag key. + example: aws + type: string + description: + description: The human-readable description for the tag key. + example: AWS account that owns this cost. + type: string + required: + - description + type: object CostTagDescriptionsResponse: description: List of Cloud Cost Management tag key descriptions for the organization, optionally filtered to a single cloud provider. example: @@ -35598,6 +35670,55 @@ components: required: - type type: object + GenerateCostTagDescriptionResponse: + description: Response wrapping an AI-generated Cloud Cost Management tag key description. + example: + data: + attributes: + description: AWS account that owns this cost. + id: account_id + type: cost_generated_tag_description + properties: + data: + $ref: "#/components/schemas/GeneratedCostTagDescription" + required: + - data + type: object + GeneratedCostTagDescription: + description: AI-generated Cloud Cost Management tag key description returned by the generate endpoint. The result is returned to the client but is not persisted by this endpoint. + properties: + attributes: + $ref: "#/components/schemas/GeneratedCostTagDescriptionAttributes" + id: + description: The tag key the AI description was generated for. + example: account_id + type: string + type: + $ref: "#/components/schemas/GeneratedCostTagDescriptionType" + required: + - attributes + - id + - type + type: object + GeneratedCostTagDescriptionAttributes: + description: Attributes of an AI-generated Cloud Cost Management tag key description. + properties: + description: + description: The AI-generated description for the tag key. + example: AWS account that owns this cost. + type: string + required: + - description + type: object + GeneratedCostTagDescriptionType: + default: cost_generated_tag_description + description: Type of the AI-generated Cloud Cost Management tag description resource. + enum: + - cost_generated_tag_description + example: cost_generated_tag_description + type: string + x-enum-varnames: + - COST_GENERATED_TAG_DESCRIPTION GetActionConnectionResponse: description: The response for found connection properties: @@ -54649,6 +54770,256 @@ components: - id - type type: object + OAuthClientRegistrationError: + description: Error payload returned by OAuth2 dynamic client registration as defined by RFC 7591. + properties: + error: + description: Single ASCII error code per RFC 7591, such as `invalid_request` or `invalid_client_metadata`. + example: invalid_client_metadata + type: string + error_description: + description: Human-readable description of the error. + example: redirect URI is not well-formed + type: string + required: + - error + - error_description + type: object + OAuthClientRegistrationGrantType: + description: OAuth 2.0 grant type that a registered client may use. + enum: + - authorization_code + - refresh_token + example: authorization_code + type: string + x-enum-varnames: + - AUTHORIZATION_CODE + - REFRESH_TOKEN + OAuthClientRegistrationRequest: + description: Request payload for OAuth2 dynamic client registration as defined by RFC 7591. + properties: + client_name: + description: Human-readable name of the client. Control characters are rejected. + example: Example MCP Client + maxLength: 1000 + type: string + client_uri: + description: URL of the home page of the client. + example: https://example.com + maxLength: 1000 + type: string + grant_types: + description: |- + OAuth 2.0 grant types the client may use. + Defaults to `authorization_code` and `refresh_token` when omitted. + example: + - authorization_code + - refresh_token + items: + $ref: "#/components/schemas/OAuthClientRegistrationGrantType" + type: array + jwks_uri: + description: URL referencing the client's JSON Web Key Set. + example: https://example.com/.well-known/jwks.json + maxLength: 1000 + type: string + logo_uri: + description: URL referencing a logo for the client. + example: https://example.com/logo.png + maxLength: 1000 + type: string + policy_uri: + description: URL pointing to the client's privacy policy. + example: https://example.com/privacy + maxLength: 1000 + type: string + redirect_uris: + description: Array of redirection URI strings used by the client in redirect-based flows. + example: + - https://example.com/oauth/callback + items: + description: Redirection URI registered for the client. + example: https://example.com/oauth/callback + maxLength: 1000 + type: string + type: array + response_types: + description: OAuth 2.0 response types the client may use. Only `code` is supported. + example: + - code + items: + $ref: "#/components/schemas/OAuthClientRegistrationResponseType" + type: array + scope: + description: Space-separated list of scope values the client may request. + example: openid profile + maxLength: 1000 + type: string + token_endpoint_auth_method: + description: Requested authentication method for the token endpoint. Only `none` is supported. + example: none + maxLength: 20 + type: string + tos_uri: + description: URL pointing to the client's terms of service. + example: https://example.com/tos + maxLength: 1000 + type: string + required: + - client_name + - redirect_uris + type: object + OAuthClientRegistrationResponse: + description: Response payload for a successful OAuth2 dynamic client registration as defined by RFC 7591. + properties: + client_id: + description: Unique identifier assigned to the registered client. + example: 72b68208-36a6-11f0-b21b-da7ad0900002 + format: uuid + type: string + client_name: + description: Human-readable name of the client. + example: Example MCP Client + type: string + grant_types: + description: OAuth 2.0 grant types registered for the client. + example: + - authorization_code + - refresh_token + items: + $ref: "#/components/schemas/OAuthClientRegistrationGrantType" + type: array + redirect_uris: + description: Redirection URIs registered for the client. + example: + - https://example.com/oauth/callback + items: + description: Redirection URI registered for the client. + example: https://example.com/oauth/callback + type: string + type: array + response_types: + description: OAuth 2.0 response types registered for the client. + example: + - code + items: + $ref: "#/components/schemas/OAuthClientRegistrationResponseType" + type: array + token_endpoint_auth_method: + description: Authentication method registered for the token endpoint. Always `none`. + example: none + type: string + required: + - client_id + - client_name + - redirect_uris + - token_endpoint_auth_method + - grant_types + - response_types + type: object + OAuthClientRegistrationResponseType: + description: OAuth 2.0 response type that a registered client may use. + enum: + - code + example: code + type: string + x-enum-varnames: + - CODE + OAuthOidcScope: + description: OIDC scope a client may be restricted to. + enum: + - openid + - profile + - email + - offline_access + example: openid + type: string + x-enum-varnames: + - OPENID + - PROFILE + - EMAIL + - OFFLINE_ACCESS + OAuthScopesRestriction: + description: Allowlist of OIDC and permission scopes enforced for the OAuth2 client. + nullable: true + properties: + oidc_scopes: + description: OIDC scopes the client is restricted to. + example: + - openid + - email + items: + $ref: "#/components/schemas/OAuthOidcScope" + type: array + permission_scopes: + description: Datadog permission scopes the client is restricted to. + example: + - dashboards_read + - metrics_read + items: + description: Datadog permission scope name. + example: dashboards_read + type: string + type: array + required: + - oidc_scopes + - permission_scopes + type: object + OAuthScopesRestrictionResponse: + description: Response payload describing the scopes restriction of an OAuth2 client. + properties: + data: + $ref: "#/components/schemas/OAuthScopesRestrictionResponseData" + required: + - data + type: object + OAuthScopesRestrictionResponseAttributes: + description: Attributes of an OAuth2 client scopes restriction. + properties: + required_permission_scopes: + description: |- + Permission scopes automatically required for this client (for example, mobile-app permission scopes). + Returns `null` when no scopes are required. + example: + - mobile_app_access + items: + description: Datadog permission scope name. + example: mobile_app_access + type: string + nullable: true + type: array + scopes_restriction: + $ref: "#/components/schemas/OAuthScopesRestriction" + required: + - scopes_restriction + - required_permission_scopes + type: object + OAuthScopesRestrictionResponseData: + description: Data object of an OAuth2 client scopes restriction response. + properties: + attributes: + $ref: "#/components/schemas/OAuthScopesRestrictionResponseAttributes" + id: + description: UUID of the OAuth2 client this restriction applies to. + example: fafa8e1c-36a5-11f0-a83d-da7ad0900001 + format: uuid + type: string + type: + $ref: "#/components/schemas/OAuthScopesRestrictionType" + required: + - id + - type + - attributes + type: object + OAuthScopesRestrictionType: + default: scopes_restriction + description: JSON:API resource type for an OAuth2 client scopes restriction. + enum: + - scopes_restriction + example: scopes_restriction + type: string + x-enum-varnames: + - SCOPES_RESTRICTION OCIConfig: description: OCI config. properties: @@ -92269,6 +92640,57 @@ components: - id - attributes type: object + UpsertOAuthScopesRestrictionData: + description: Data object of an upsert OAuth2 scopes restriction request. + properties: + attributes: + $ref: "#/components/schemas/UpsertOAuthScopesRestrictionDataAttributes" + type: + $ref: "#/components/schemas/UpsertOAuthScopesRestrictionType" + required: + - type + type: object + UpsertOAuthScopesRestrictionDataAttributes: + description: Attributes of an upsert OAuth2 scopes restriction request. + properties: + oidc_scopes: + description: OIDC scopes the client is allowed to request. + example: + - openid + - email + items: + $ref: "#/components/schemas/OAuthOidcScope" + type: array + permission_scopes: + description: |- + Datadog permission scopes the client is allowed to request. + Each value must be a valid permission name. + example: + - dashboards_read + - metrics_read + items: + description: Datadog permission scope name. + example: dashboards_read + type: string + type: array + type: object + UpsertOAuthScopesRestrictionRequest: + description: Request payload for creating or updating the scopes restriction of an OAuth2 client. + properties: + data: + $ref: "#/components/schemas/UpsertOAuthScopesRestrictionData" + required: + - data + type: object + UpsertOAuthScopesRestrictionType: + default: upsert_scopes_restriction + description: JSON:API resource type for an upsert OAuth2 client scopes restriction request. + enum: + - upsert_scopes_restriction + example: upsert_scopes_restriction + type: string + x-enum-varnames: + - UPSERT_SCOPES_RESTRICTION Urgency: description: Specifies the level of urgency for a routing rule (low, high, or dynamic). enum: @@ -110944,6 +111366,226 @@ paths: operator: OR permissions: - cloud_cost_management_read + /api/v2/cost/tag_descriptions/{tag_key}: + delete: + description: Delete a Cloud Cost Management tag key description. When `cloud` is omitted, deletes every description for the tag key, falling back to Datadog's global default when available. When `cloud` is provided, deletes only the description scoped to that cloud provider. + operationId: DeleteCostTagDescriptionByKey + parameters: + - description: The tag key whose description is being deleted. + in: path + name: tag_key + required: true + schema: + type: string + - description: Cloud provider to scope the deletion to (for example, `aws`). Omit to delete every description for the tag key. + in: query + name: cloud + required: false + schema: + type: string + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_write + summary: Delete a Cloud Cost Management tag description + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_write + get: + description: Get the Cloud Cost Management description for a single tag key. Use `filter[cloud]` to scope the lookup to a specific cloud provider; when omitted, the response resolves the description in fallback order (cloud-specific organization override, then cloudless organization default, then Datadog's global default). + operationId: GetCostTagDescriptionByKey + parameters: + - description: The tag key whose description is being fetched. + in: path + name: tag_key + required: true + schema: + type: string + - description: Cloud provider to scope the lookup to (for example, `aws`). Omit to use the resolved fallback. + in: query + name: filter[cloud] + required: false + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + cloud: aws + created_at: "2026-01-01T12:00:00Z" + description: AWS account that owns this cost. + source: human + tag_key: account_id + updated_at: "2026-01-01T12:00:00Z" + id: account_id + type: cost_tag_description + schema: + $ref: "#/components/schemas/CostTagDescriptionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Get a Cloud Cost Management tag description + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read + put: + description: Create or update a Cloud Cost Management tag key description. The new description and optional cloud scoping are supplied in the request body. Omit `cloud` to set a cross-cloud default for the tag key. + operationId: UpsertCostTagDescriptionByKey + parameters: + - description: The tag key whose description is being upserted. + in: path + name: tag_key + required: true + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + cloud: aws + description: AWS account that owns this cost. + id: account_id + type: cost_tag_description + schema: + $ref: "#/components/schemas/CostTagDescriptionUpsertRequest" + required: true + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_write + summary: Upsert a Cloud Cost Management tag description + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_write + /api/v2/cost/tag_descriptions/{tag_key}/generate: + get: + description: Use AI to draft a Cloud Cost Management tag key description based on associated cost data. The generated description is returned in the response and is not persisted by this endpoint; follow up with `UpsertCostTagDescriptionByKey` to save it. + operationId: GenerateCostTagDescriptionByKey + parameters: + - description: The tag key to generate an AI description for. + in: path + name: tag_key + required: true + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + description: AWS account that owns this cost. + id: account_id + type: cost_generated_tag_description + schema: + $ref: "#/components/schemas/GenerateCostTagDescriptionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - cloud_cost_management_read + summary: Generate a Cloud Cost Management tag description + tags: + - Cloud Cost Management + "x-permission": + operator: OR + permissions: + - cloud_cost_management_read /api/v2/cost/tag_keys: get: description: List Cloud Cost Management tag keys. @@ -134428,6 +135070,223 @@ paths: summary: Get all aggregated DNS traffic tags: - Cloud Network Monitoring + /api/v2/oauth2/clients/{client_uuid}/scopes_restriction: + delete: + description: Delete the scopes restriction configured for the OAuth2 client. + operationId: DeleteScopesRestriction + parameters: + - $ref: "#/components/parameters/OAuthClientUUIDPathParameter" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete an OAuth2 client scopes restriction + tags: + - OAuth2 Client Public + x-permission: + operator: OR + permissions: + - org_authorized_apps_write + 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 scopes restriction configured for the OAuth2 client. + operationId: GetScopesRestriction + parameters: + - $ref: "#/components/parameters/OAuthClientUUIDPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + required_permission_scopes: + scopes_restriction: + oidc_scopes: + - openid + - email + permission_scopes: + - dashboards_read + - metrics_read + id: fafa8e1c-36a5-11f0-a83d-da7ad0900001 + type: scopes_restriction + schema: + $ref: "#/components/schemas/OAuthScopesRestrictionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get an OAuth2 client scopes restriction + tags: + - OAuth2 Client Public + x-permission: + operator: OR + permissions: + - org_authorized_apps_read + 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/). + post: + description: Create or update the scopes restriction configured for the OAuth2 client. + operationId: UpsertScopesRestriction + parameters: + - $ref: "#/components/parameters/OAuthClientUUIDPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + oidc_scopes: + - openid + - email + permission_scopes: + - dashboards_read + - metrics_read + type: upsert_scopes_restriction + schema: + $ref: "#/components/schemas/UpsertOAuthScopesRestrictionRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + required_permission_scopes: + scopes_restriction: + oidc_scopes: + - openid + - email + permission_scopes: + - dashboards_read + - metrics_read + id: fafa8e1c-36a5-11f0-a83d-da7ad0900001 + type: scopes_restriction + schema: + $ref: "#/components/schemas/OAuthScopesRestrictionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Upsert an OAuth2 client scopes restriction + tags: + - OAuth2 Client Public + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - org_authorized_apps_write + 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/oauth2/register: + post: + description: Register an OAuth2 client using the Dynamic Client Registration protocol defined in RFC 7591. + operationId: RegisterOAuthClient + requestBody: + content: + application/json: + examples: + default: + value: + client_name: Example MCP Client + grant_types: + - authorization_code + - refresh_token + redirect_uris: + - https://example.com/oauth/callback + response_types: + - code + token_endpoint_auth_method: none + schema: + $ref: "#/components/schemas/OAuthClientRegistrationRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + client_id: 72b68208-36a6-11f0-b21b-da7ad0900002 + client_name: Example MCP Client + grant_types: + - authorization_code + - refresh_token + redirect_uris: + - https://example.com/oauth/callback + response_types: + - code + token_endpoint_auth_method: none + schema: + $ref: "#/components/schemas/OAuthClientRegistrationResponse" + description: Created + "400": + content: + application/json: + examples: + default: + value: + error: invalid_client_metadata + error_description: redirect URI is not well-formed + schema: + $ref: "#/components/schemas/OAuthClientRegistrationError" + description: Bad Request + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: [] + summary: Register an OAuth2 client + tags: + - OAuth2 Client Public + 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/obs-pipelines/pipelines: get: description: Retrieve a list of pipelines. @@ -167842,6 +168701,10 @@ tags: - description: |- The Network Device Monitoring API allows you to fetch devices and interfaces and their attributes. See the [Network Device Monitoring page](https://docs.datadoghq.com/network_monitoring/) for more information. name: Network Device Monitoring + - description: |- + Configure OAuth2 clients for Datadog. + Supports RFC 7591 Dynamic Client Registration and management of OAuth2 client scopes restrictions. + name: OAuth2 Client Public - description: Auto-generated tag OCI Integration name: OCI Integration - description: |- diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index c5073c05c82..248dac5739f 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -985,6 +985,10 @@ func NewConfiguration() *Configuration { "v2.UpdateMonitorUserTemplate": false, "v2.ValidateExistingMonitorUserTemplate": false, "v2.ValidateMonitorUserTemplate": false, + "v2.DeleteScopesRestriction": false, + "v2.GetScopesRestriction": false, + "v2.RegisterOAuthClient": false, + "v2.UpsertScopesRestriction": false, "v2.BulkUpdateOrgGroupMemberships": false, "v2.CreateOrgGroup": false, "v2.CreateOrgGroupPolicy": false, diff --git a/api/datadogV2/api_cloud_cost_management.go b/api/datadogV2/api_cloud_cost_management.go index b712a436d7f..2845e90b49e 100644 --- a/api/datadogV2/api_cloud_cost_management.go +++ b/api/datadogV2/api_cloud_cost_management.go @@ -702,6 +702,102 @@ func (a *CloudCostManagementApi) DeleteCostGCPUsageCostConfig(ctx _context.Conte return localVarHTTPResponse, nil } +// DeleteCostTagDescriptionByKeyOptionalParameters holds optional parameters for DeleteCostTagDescriptionByKey. +type DeleteCostTagDescriptionByKeyOptionalParameters struct { + Cloud *string +} + +// NewDeleteCostTagDescriptionByKeyOptionalParameters creates an empty struct for parameters. +func NewDeleteCostTagDescriptionByKeyOptionalParameters() *DeleteCostTagDescriptionByKeyOptionalParameters { + this := DeleteCostTagDescriptionByKeyOptionalParameters{} + return &this +} + +// WithCloud sets the corresponding parameter name and returns the struct. +func (r *DeleteCostTagDescriptionByKeyOptionalParameters) WithCloud(cloud string) *DeleteCostTagDescriptionByKeyOptionalParameters { + r.Cloud = &cloud + return r +} + +// DeleteCostTagDescriptionByKey Delete a Cloud Cost Management tag description. +// Delete a Cloud Cost Management tag key description. When `cloud` is omitted, deletes every description for the tag key, falling back to Datadog's global default when available. When `cloud` is provided, deletes only the description scoped to that cloud provider. +func (a *CloudCostManagementApi) DeleteCostTagDescriptionByKey(ctx _context.Context, tagKey string, o ...DeleteCostTagDescriptionByKeyOptionalParameters) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + optionalParams DeleteCostTagDescriptionByKeyOptionalParameters + ) + + if len(o) > 1 { + return nil, datadog.ReportError("only one argument of type DeleteCostTagDescriptionByKeyOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CloudCostManagementApi.DeleteCostTagDescriptionByKey") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cost/tag_descriptions/{tag_key}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{tag_key}", _neturl.PathEscape(datadog.ParameterToString(tagKey, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Cloud != nil { + localVarQueryParams.Add("cloud", datadog.ParameterToString(*optionalParams.Cloud, "")) + } + 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 == 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 +} + // DeleteCustomAllocationRule Delete custom allocation rule. // Delete a custom allocation rule - Delete an existing custom allocation rule by its ID func (a *CloudCostManagementApi) DeleteCustomAllocationRule(ctx _context.Context, ruleId int64) (*_nethttp.Response, error) { @@ -906,6 +1002,84 @@ func (a *CloudCostManagementApi) DeleteTagPipelinesRuleset(ctx _context.Context, return localVarHTTPResponse, nil } +// GenerateCostTagDescriptionByKey Generate a Cloud Cost Management tag description. +// Use AI to draft a Cloud Cost Management tag key description based on associated cost data. The generated description is returned in the response and is not persisted by this endpoint; follow up with `UpsertCostTagDescriptionByKey` to save it. +func (a *CloudCostManagementApi) GenerateCostTagDescriptionByKey(ctx _context.Context, tagKey string) (GenerateCostTagDescriptionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GenerateCostTagDescriptionResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CloudCostManagementApi.GenerateCostTagDescriptionByKey") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cost/tag_descriptions/{tag_key}/generate" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{tag_key}", _neturl.PathEscape(datadog.ParameterToString(tagKey, ""))) + + 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 == 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 +} + // GetBudget Get budget. // Get a budget func (a *CloudCostManagementApi) GetBudget(ctx _context.Context, budgetId string) (BudgetWithEntries, *_nethttp.Response, error) { @@ -2351,6 +2525,112 @@ func (a *CloudCostManagementApi) GetCostGCPUsageCostConfig(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// GetCostTagDescriptionByKeyOptionalParameters holds optional parameters for GetCostTagDescriptionByKey. +type GetCostTagDescriptionByKeyOptionalParameters struct { + FilterCloud *string +} + +// NewGetCostTagDescriptionByKeyOptionalParameters creates an empty struct for parameters. +func NewGetCostTagDescriptionByKeyOptionalParameters() *GetCostTagDescriptionByKeyOptionalParameters { + this := GetCostTagDescriptionByKeyOptionalParameters{} + return &this +} + +// WithFilterCloud sets the corresponding parameter name and returns the struct. +func (r *GetCostTagDescriptionByKeyOptionalParameters) WithFilterCloud(filterCloud string) *GetCostTagDescriptionByKeyOptionalParameters { + r.FilterCloud = &filterCloud + return r +} + +// GetCostTagDescriptionByKey Get a Cloud Cost Management tag description. +// Get the Cloud Cost Management description for a single tag key. Use `filter[cloud]` to scope the lookup to a specific cloud provider; when omitted, the response resolves the description in fallback order (cloud-specific organization override, then cloudless organization default, then Datadog's global default). +func (a *CloudCostManagementApi) GetCostTagDescriptionByKey(ctx _context.Context, tagKey string, o ...GetCostTagDescriptionByKeyOptionalParameters) (CostTagDescriptionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue CostTagDescriptionResponse + optionalParams GetCostTagDescriptionByKeyOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetCostTagDescriptionByKeyOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CloudCostManagementApi.GetCostTagDescriptionByKey") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cost/tag_descriptions/{tag_key}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{tag_key}", _neturl.PathEscape(datadog.ParameterToString(tagKey, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.FilterCloud != nil { + localVarQueryParams.Add("filter[cloud]", datadog.ParameterToString(*optionalParams.FilterCloud, "")) + } + 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 +} + // GetCostTagKeyOptionalParameters holds optional parameters for GetCostTagKey. type GetCostTagKeyOptionalParameters struct { FilterMetric *string @@ -5712,6 +5992,77 @@ func (a *CloudCostManagementApi) UpsertBudget(ctx _context.Context, body BudgetW return localVarReturnValue, localVarHTTPResponse, nil } +// UpsertCostTagDescriptionByKey Upsert a Cloud Cost Management tag description. +// Create or update a Cloud Cost Management tag key description. The new description and optional cloud scoping are supplied in the request body. Omit `cloud` to set a cross-cloud default for the tag key. +func (a *CloudCostManagementApi) UpsertCostTagDescriptionByKey(ctx _context.Context, tagKey string, body CostTagDescriptionUpsertRequest) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CloudCostManagementApi.UpsertCostTagDescriptionByKey") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/cost/tag_descriptions/{tag_key}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{tag_key}", _neturl.PathEscape(datadog.ParameterToString(tagKey, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + 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 == 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 +} + // ValidateBudget Validate budget. // Validate a budget configuration without creating or modifying it func (a *CloudCostManagementApi) ValidateBudget(ctx _context.Context, body BudgetValidationRequest) (BudgetValidationResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/api_o_auth2_client_public.go b/api/datadogV2/api_o_auth2_client_public.go new file mode 100644 index 00000000000..6d377934a5b --- /dev/null +++ b/api/datadogV2/api_o_auth2_client_public.go @@ -0,0 +1,392 @@ +// 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" + "github.com/google/uuid" +) + +// OAuth2ClientPublicApi service type +type OAuth2ClientPublicApi datadog.Service + +// DeleteScopesRestriction Delete an OAuth2 client scopes restriction. +// Delete the scopes restriction configured for the OAuth2 client. +func (a *OAuth2ClientPublicApi) DeleteScopesRestriction(ctx _context.Context, clientUuid uuid.UUID) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteScopesRestriction" + 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.OAuth2ClientPublicApi.DeleteScopesRestriction") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/oauth2/clients/{client_uuid}/scopes_restriction" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{client_uuid}", _neturl.PathEscape(datadog.ParameterToString(clientUuid, ""))) + + 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 == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetScopesRestriction Get an OAuth2 client scopes restriction. +// Get the scopes restriction configured for the OAuth2 client. +func (a *OAuth2ClientPublicApi) GetScopesRestriction(ctx _context.Context, clientUuid uuid.UUID) (OAuthScopesRestrictionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue OAuthScopesRestrictionResponse + ) + + operationId := "v2.GetScopesRestriction" + 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.OAuth2ClientPublicApi.GetScopesRestriction") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/oauth2/clients/{client_uuid}/scopes_restriction" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{client_uuid}", _neturl.PathEscape(datadog.ParameterToString(clientUuid, ""))) + + 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 == 404 { + var v JSONAPIErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// RegisterOAuthClient Register an OAuth2 client. +// Register an OAuth2 client using the Dynamic Client Registration protocol defined in RFC 7591. +func (a *OAuth2ClientPublicApi) RegisterOAuthClient(ctx _context.Context, body OAuthClientRegistrationRequest) (OAuthClientRegistrationResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue OAuthClientRegistrationResponse + ) + + operationId := "v2.RegisterOAuthClient" + 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.OAuth2ClientPublicApi.RegisterOAuthClient") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/oauth2/register" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + 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 { + var v OAuthClientRegistrationError + 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 + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpsertScopesRestriction Upsert an OAuth2 client scopes restriction. +// Create or update the scopes restriction configured for the OAuth2 client. +func (a *OAuth2ClientPublicApi) UpsertScopesRestriction(ctx _context.Context, clientUuid uuid.UUID, body UpsertOAuthScopesRestrictionRequest) (OAuthScopesRestrictionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue OAuthScopesRestrictionResponse + ) + + operationId := "v2.UpsertScopesRestriction" + 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.OAuth2ClientPublicApi.UpsertScopesRestriction") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/oauth2/clients/{client_uuid}/scopes_restriction" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{client_uuid}", _neturl.PathEscape(datadog.ParameterToString(clientUuid, ""))) + + 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 == 404 { + var v JSONAPIErrorResponse + 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 + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewOAuth2ClientPublicApi Returns NewOAuth2ClientPublicApi. +func NewOAuth2ClientPublicApi(client *datadog.APIClient) *OAuth2ClientPublicApi { + return &OAuth2ClientPublicApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index d5202a50d98..a3cf9a815cf 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -238,9 +238,11 @@ // - [CloudCostManagementApi.DeleteCostAWSCURConfig] // - [CloudCostManagementApi.DeleteCostAzureUCConfig] // - [CloudCostManagementApi.DeleteCostGCPUsageCostConfig] +// - [CloudCostManagementApi.DeleteCostTagDescriptionByKey] // - [CloudCostManagementApi.DeleteCustomAllocationRule] // - [CloudCostManagementApi.DeleteCustomCostsFile] // - [CloudCostManagementApi.DeleteTagPipelinesRuleset] +// - [CloudCostManagementApi.GenerateCostTagDescriptionByKey] // - [CloudCostManagementApi.GetBudget] // - [CloudCostManagementApi.GetCommitmentsCommitmentList] // - [CloudCostManagementApi.GetCommitmentsCoverageScalar] @@ -254,6 +256,7 @@ // - [CloudCostManagementApi.GetCostAnomaly] // - [CloudCostManagementApi.GetCostAzureUCConfig] // - [CloudCostManagementApi.GetCostGCPUsageCostConfig] +// - [CloudCostManagementApi.GetCostTagDescriptionByKey] // - [CloudCostManagementApi.GetCostTagKey] // - [CloudCostManagementApi.GetCostTagMetadataCurrency] // - [CloudCostManagementApi.GetCustomAllocationRule] @@ -288,6 +291,7 @@ // - [CloudCostManagementApi.UpdateTagPipelinesRuleset] // - [CloudCostManagementApi.UploadCustomCostsFile] // - [CloudCostManagementApi.UpsertBudget] +// - [CloudCostManagementApi.UpsertCostTagDescriptionByKey] // - [CloudCostManagementApi.ValidateBudget] // - [CloudCostManagementApi.ValidateCsvBudget] // - [CloudCostManagementApi.ValidateQuery] @@ -673,6 +677,10 @@ // - [NetworkDeviceMonitoringApi.ListInterfaceUserTags] // - [NetworkDeviceMonitoringApi.UpdateDeviceUserTags] // - [NetworkDeviceMonitoringApi.UpdateInterfaceUserTags] +// - [OAuth2ClientPublicApi.DeleteScopesRestriction] +// - [OAuth2ClientPublicApi.GetScopesRestriction] +// - [OAuth2ClientPublicApi.RegisterOAuthClient] +// - [OAuth2ClientPublicApi.UpsertScopesRestriction] // - [OCIIntegrationApi.CreateTenancyConfig] // - [OCIIntegrationApi.DeleteTenancyConfig] // - [OCIIntegrationApi.GetTenancyConfig] diff --git a/api/datadogV2/model_cost_tag_description_response.go b/api/datadogV2/model_cost_tag_description_response.go new file mode 100644 index 00000000000..721dea8f394 --- /dev/null +++ b/api/datadogV2/model_cost_tag_description_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" +) + +// CostTagDescriptionResponse Single Cloud Cost Management tag key description returned by the get-by-key endpoint. +type CostTagDescriptionResponse struct { + // A Cloud Cost Management tag key description, either cross-cloud or scoped to a single cloud provider. + Data CostTagDescription `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:"-"` +} + +// NewCostTagDescriptionResponse instantiates a new CostTagDescriptionResponse 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 NewCostTagDescriptionResponse(data CostTagDescription) *CostTagDescriptionResponse { + this := CostTagDescriptionResponse{} + this.Data = data + return &this +} + +// NewCostTagDescriptionResponseWithDefaults instantiates a new CostTagDescriptionResponse 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 NewCostTagDescriptionResponseWithDefaults() *CostTagDescriptionResponse { + this := CostTagDescriptionResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *CostTagDescriptionResponse) GetData() CostTagDescription { + if o == nil { + var ret CostTagDescription + 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 *CostTagDescriptionResponse) GetDataOk() (*CostTagDescription, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CostTagDescriptionResponse) SetData(v CostTagDescription) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CostTagDescriptionResponse) 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 *CostTagDescriptionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CostTagDescription `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_cost_tag_description_upsert_request.go b/api/datadogV2/model_cost_tag_description_upsert_request.go new file mode 100644 index 00000000000..8a1d0058267 --- /dev/null +++ b/api/datadogV2/model_cost_tag_description_upsert_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" +) + +// CostTagDescriptionUpsertRequest Request body for creating or updating a Cloud Cost Management tag key description. +type CostTagDescriptionUpsertRequest struct { + // Resource envelope carrying the tag key description being upserted. The `id` is informational; the authoritative tag key is taken from the URL path. + Data CostTagDescriptionUpsertRequestData `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:"-"` +} + +// NewCostTagDescriptionUpsertRequest instantiates a new CostTagDescriptionUpsertRequest 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 NewCostTagDescriptionUpsertRequest(data CostTagDescriptionUpsertRequestData) *CostTagDescriptionUpsertRequest { + this := CostTagDescriptionUpsertRequest{} + this.Data = data + return &this +} + +// NewCostTagDescriptionUpsertRequestWithDefaults instantiates a new CostTagDescriptionUpsertRequest 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 NewCostTagDescriptionUpsertRequestWithDefaults() *CostTagDescriptionUpsertRequest { + this := CostTagDescriptionUpsertRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *CostTagDescriptionUpsertRequest) GetData() CostTagDescriptionUpsertRequestData { + if o == nil { + var ret CostTagDescriptionUpsertRequestData + 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 *CostTagDescriptionUpsertRequest) GetDataOk() (*CostTagDescriptionUpsertRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CostTagDescriptionUpsertRequest) SetData(v CostTagDescriptionUpsertRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CostTagDescriptionUpsertRequest) 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 *CostTagDescriptionUpsertRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CostTagDescriptionUpsertRequestData `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_cost_tag_description_upsert_request_data.go b/api/datadogV2/model_cost_tag_description_upsert_request_data.go new file mode 100644 index 00000000000..20a3ed4e674 --- /dev/null +++ b/api/datadogV2/model_cost_tag_description_upsert_request_data.go @@ -0,0 +1,183 @@ +// 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" +) + +// CostTagDescriptionUpsertRequestData Resource envelope carrying the tag key description being upserted. The `id` is informational; the authoritative tag key is taken from the URL path. +type CostTagDescriptionUpsertRequestData struct { + // Mutable attributes set when creating or updating a Cloud Cost Management tag key description. + Attributes CostTagDescriptionUpsertRequestDataAttributes `json:"attributes"` + // Identifier of the tag key the description applies to. Matches the `tag_key` path parameter. + Id *string `json:"id,omitempty"` + // Type of the Cloud Cost Management tag description resource. + Type CostTagDescriptionType `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:"-"` +} + +// NewCostTagDescriptionUpsertRequestData instantiates a new CostTagDescriptionUpsertRequestData 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 NewCostTagDescriptionUpsertRequestData(attributes CostTagDescriptionUpsertRequestDataAttributes, typeVar CostTagDescriptionType) *CostTagDescriptionUpsertRequestData { + this := CostTagDescriptionUpsertRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewCostTagDescriptionUpsertRequestDataWithDefaults instantiates a new CostTagDescriptionUpsertRequestData 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 NewCostTagDescriptionUpsertRequestDataWithDefaults() *CostTagDescriptionUpsertRequestData { + this := CostTagDescriptionUpsertRequestData{} + var typeVar CostTagDescriptionType = COSTTAGDESCRIPTIONTYPE_COST_TAG_DESCRIPTION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *CostTagDescriptionUpsertRequestData) GetAttributes() CostTagDescriptionUpsertRequestDataAttributes { + if o == nil { + var ret CostTagDescriptionUpsertRequestDataAttributes + 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 *CostTagDescriptionUpsertRequestData) GetAttributesOk() (*CostTagDescriptionUpsertRequestDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *CostTagDescriptionUpsertRequestData) SetAttributes(v CostTagDescriptionUpsertRequestDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *CostTagDescriptionUpsertRequestData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CostTagDescriptionUpsertRequestData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *CostTagDescriptionUpsertRequestData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *CostTagDescriptionUpsertRequestData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value. +func (o *CostTagDescriptionUpsertRequestData) GetType() CostTagDescriptionType { + if o == nil { + var ret CostTagDescriptionType + 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 *CostTagDescriptionUpsertRequestData) GetTypeOk() (*CostTagDescriptionType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CostTagDescriptionUpsertRequestData) SetType(v CostTagDescriptionType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CostTagDescriptionUpsertRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + 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 *CostTagDescriptionUpsertRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CostTagDescriptionUpsertRequestDataAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *CostTagDescriptionType `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.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_cost_tag_description_upsert_request_data_attributes.go b/api/datadogV2/model_cost_tag_description_upsert_request_data_attributes.go new file mode 100644 index 00000000000..42733817110 --- /dev/null +++ b/api/datadogV2/model_cost_tag_description_upsert_request_data_attributes.go @@ -0,0 +1,136 @@ +// 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" +) + +// CostTagDescriptionUpsertRequestDataAttributes Mutable attributes set when creating or updating a Cloud Cost Management tag key description. +type CostTagDescriptionUpsertRequestDataAttributes struct { + // Cloud provider this description applies to (for example, `aws`). Omit to set the cross-cloud default for the tag key. + Cloud *string `json:"cloud,omitempty"` + // The human-readable description for the tag key. + Description string `json:"description"` + // 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:"-"` +} + +// NewCostTagDescriptionUpsertRequestDataAttributes instantiates a new CostTagDescriptionUpsertRequestDataAttributes 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 NewCostTagDescriptionUpsertRequestDataAttributes(description string) *CostTagDescriptionUpsertRequestDataAttributes { + this := CostTagDescriptionUpsertRequestDataAttributes{} + this.Description = description + return &this +} + +// NewCostTagDescriptionUpsertRequestDataAttributesWithDefaults instantiates a new CostTagDescriptionUpsertRequestDataAttributes 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 NewCostTagDescriptionUpsertRequestDataAttributesWithDefaults() *CostTagDescriptionUpsertRequestDataAttributes { + this := CostTagDescriptionUpsertRequestDataAttributes{} + return &this +} + +// GetCloud returns the Cloud field value if set, zero value otherwise. +func (o *CostTagDescriptionUpsertRequestDataAttributes) GetCloud() string { + if o == nil || o.Cloud == nil { + var ret string + return ret + } + return *o.Cloud +} + +// GetCloudOk returns a tuple with the Cloud field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CostTagDescriptionUpsertRequestDataAttributes) GetCloudOk() (*string, bool) { + if o == nil || o.Cloud == nil { + return nil, false + } + return o.Cloud, true +} + +// HasCloud returns a boolean if a field has been set. +func (o *CostTagDescriptionUpsertRequestDataAttributes) HasCloud() bool { + return o != nil && o.Cloud != nil +} + +// SetCloud gets a reference to the given string and assigns it to the Cloud field. +func (o *CostTagDescriptionUpsertRequestDataAttributes) SetCloud(v string) { + o.Cloud = &v +} + +// GetDescription returns the Description field value. +func (o *CostTagDescriptionUpsertRequestDataAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *CostTagDescriptionUpsertRequestDataAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *CostTagDescriptionUpsertRequestDataAttributes) SetDescription(v string) { + o.Description = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CostTagDescriptionUpsertRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Cloud != nil { + toSerialize["cloud"] = o.Cloud + } + toSerialize["description"] = o.Description + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CostTagDescriptionUpsertRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Cloud *string `json:"cloud,omitempty"` + Description *string `json:"description"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"cloud", "description"}) + } else { + return err + } + o.Cloud = all.Cloud + o.Description = *all.Description + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_generate_cost_tag_description_response.go b/api/datadogV2/model_generate_cost_tag_description_response.go new file mode 100644 index 00000000000..8f404b3db52 --- /dev/null +++ b/api/datadogV2/model_generate_cost_tag_description_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" +) + +// GenerateCostTagDescriptionResponse Response wrapping an AI-generated Cloud Cost Management tag key description. +type GenerateCostTagDescriptionResponse struct { + // AI-generated Cloud Cost Management tag key description returned by the generate endpoint. The result is returned to the client but is not persisted by this endpoint. + Data GeneratedCostTagDescription `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:"-"` +} + +// NewGenerateCostTagDescriptionResponse instantiates a new GenerateCostTagDescriptionResponse 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 NewGenerateCostTagDescriptionResponse(data GeneratedCostTagDescription) *GenerateCostTagDescriptionResponse { + this := GenerateCostTagDescriptionResponse{} + this.Data = data + return &this +} + +// NewGenerateCostTagDescriptionResponseWithDefaults instantiates a new GenerateCostTagDescriptionResponse 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 NewGenerateCostTagDescriptionResponseWithDefaults() *GenerateCostTagDescriptionResponse { + this := GenerateCostTagDescriptionResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GenerateCostTagDescriptionResponse) GetData() GeneratedCostTagDescription { + if o == nil { + var ret GeneratedCostTagDescription + 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 *GenerateCostTagDescriptionResponse) GetDataOk() (*GeneratedCostTagDescription, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GenerateCostTagDescriptionResponse) SetData(v GeneratedCostTagDescription) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GenerateCostTagDescriptionResponse) 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 *GenerateCostTagDescriptionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GeneratedCostTagDescription `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_generated_cost_tag_description.go b/api/datadogV2/model_generated_cost_tag_description.go new file mode 100644 index 00000000000..a3bf4717bf2 --- /dev/null +++ b/api/datadogV2/model_generated_cost_tag_description.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" +) + +// GeneratedCostTagDescription AI-generated Cloud Cost Management tag key description returned by the generate endpoint. The result is returned to the client but is not persisted by this endpoint. +type GeneratedCostTagDescription struct { + // Attributes of an AI-generated Cloud Cost Management tag key description. + Attributes GeneratedCostTagDescriptionAttributes `json:"attributes"` + // The tag key the AI description was generated for. + Id string `json:"id"` + // Type of the AI-generated Cloud Cost Management tag description resource. + Type GeneratedCostTagDescriptionType `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:"-"` +} + +// NewGeneratedCostTagDescription instantiates a new GeneratedCostTagDescription 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 NewGeneratedCostTagDescription(attributes GeneratedCostTagDescriptionAttributes, id string, typeVar GeneratedCostTagDescriptionType) *GeneratedCostTagDescription { + this := GeneratedCostTagDescription{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewGeneratedCostTagDescriptionWithDefaults instantiates a new GeneratedCostTagDescription 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 NewGeneratedCostTagDescriptionWithDefaults() *GeneratedCostTagDescription { + this := GeneratedCostTagDescription{} + var typeVar GeneratedCostTagDescriptionType = GENERATEDCOSTTAGDESCRIPTIONTYPE_COST_GENERATED_TAG_DESCRIPTION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *GeneratedCostTagDescription) GetAttributes() GeneratedCostTagDescriptionAttributes { + if o == nil { + var ret GeneratedCostTagDescriptionAttributes + 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 *GeneratedCostTagDescription) GetAttributesOk() (*GeneratedCostTagDescriptionAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *GeneratedCostTagDescription) SetAttributes(v GeneratedCostTagDescriptionAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *GeneratedCostTagDescription) 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 *GeneratedCostTagDescription) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *GeneratedCostTagDescription) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *GeneratedCostTagDescription) GetType() GeneratedCostTagDescriptionType { + if o == nil { + var ret GeneratedCostTagDescriptionType + 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 *GeneratedCostTagDescription) GetTypeOk() (*GeneratedCostTagDescriptionType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GeneratedCostTagDescription) SetType(v GeneratedCostTagDescriptionType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GeneratedCostTagDescription) 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 *GeneratedCostTagDescription) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GeneratedCostTagDescriptionAttributes `json:"attributes"` + Id *string `json:"id"` + Type *GeneratedCostTagDescriptionType `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_generated_cost_tag_description_attributes.go b/api/datadogV2/model_generated_cost_tag_description_attributes.go new file mode 100644 index 00000000000..bf779e02f67 --- /dev/null +++ b/api/datadogV2/model_generated_cost_tag_description_attributes.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" +) + +// GeneratedCostTagDescriptionAttributes Attributes of an AI-generated Cloud Cost Management tag key description. +type GeneratedCostTagDescriptionAttributes struct { + // The AI-generated description for the tag key. + Description string `json:"description"` + // 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:"-"` +} + +// NewGeneratedCostTagDescriptionAttributes instantiates a new GeneratedCostTagDescriptionAttributes 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 NewGeneratedCostTagDescriptionAttributes(description string) *GeneratedCostTagDescriptionAttributes { + this := GeneratedCostTagDescriptionAttributes{} + this.Description = description + return &this +} + +// NewGeneratedCostTagDescriptionAttributesWithDefaults instantiates a new GeneratedCostTagDescriptionAttributes 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 NewGeneratedCostTagDescriptionAttributesWithDefaults() *GeneratedCostTagDescriptionAttributes { + this := GeneratedCostTagDescriptionAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *GeneratedCostTagDescriptionAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *GeneratedCostTagDescriptionAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *GeneratedCostTagDescriptionAttributes) SetDescription(v string) { + o.Description = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GeneratedCostTagDescriptionAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["description"] = o.Description + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GeneratedCostTagDescriptionAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description"}) + } else { + return err + } + o.Description = *all.Description + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_generated_cost_tag_description_type.go b/api/datadogV2/model_generated_cost_tag_description_type.go new file mode 100644 index 00000000000..a53e4cb3fd3 --- /dev/null +++ b/api/datadogV2/model_generated_cost_tag_description_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" +) + +// GeneratedCostTagDescriptionType Type of the AI-generated Cloud Cost Management tag description resource. +type GeneratedCostTagDescriptionType string + +// List of GeneratedCostTagDescriptionType. +const ( + GENERATEDCOSTTAGDESCRIPTIONTYPE_COST_GENERATED_TAG_DESCRIPTION GeneratedCostTagDescriptionType = "cost_generated_tag_description" +) + +var allowedGeneratedCostTagDescriptionTypeEnumValues = []GeneratedCostTagDescriptionType{ + GENERATEDCOSTTAGDESCRIPTIONTYPE_COST_GENERATED_TAG_DESCRIPTION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GeneratedCostTagDescriptionType) GetAllowedValues() []GeneratedCostTagDescriptionType { + return allowedGeneratedCostTagDescriptionTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GeneratedCostTagDescriptionType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GeneratedCostTagDescriptionType(value) + return nil +} + +// NewGeneratedCostTagDescriptionTypeFromValue returns a pointer to a valid GeneratedCostTagDescriptionType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGeneratedCostTagDescriptionTypeFromValue(v string) (*GeneratedCostTagDescriptionType, error) { + ev := GeneratedCostTagDescriptionType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GeneratedCostTagDescriptionType: valid values are %v", v, allowedGeneratedCostTagDescriptionTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GeneratedCostTagDescriptionType) IsValid() bool { + for _, existing := range allowedGeneratedCostTagDescriptionTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GeneratedCostTagDescriptionType value. +func (v GeneratedCostTagDescriptionType) Ptr() *GeneratedCostTagDescriptionType { + return &v +} diff --git a/api/datadogV2/model_o_auth_client_registration_error.go b/api/datadogV2/model_o_auth_client_registration_error.go new file mode 100644 index 00000000000..dd1a6e109c4 --- /dev/null +++ b/api/datadogV2/model_o_auth_client_registration_error.go @@ -0,0 +1,133 @@ +// 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" +) + +// OAuthClientRegistrationError Error payload returned by OAuth2 dynamic client registration as defined by RFC 7591. +type OAuthClientRegistrationError struct { + // Single ASCII error code per RFC 7591, such as `invalid_request` or `invalid_client_metadata`. + Error string `json:"error"` + // Human-readable description of the error. + ErrorDescription string `json:"error_description"` + // 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:"-"` +} + +// NewOAuthClientRegistrationError instantiates a new OAuthClientRegistrationError 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 NewOAuthClientRegistrationError(error string, errorDescription string) *OAuthClientRegistrationError { + this := OAuthClientRegistrationError{} + this.Error = error + this.ErrorDescription = errorDescription + return &this +} + +// NewOAuthClientRegistrationErrorWithDefaults instantiates a new OAuthClientRegistrationError 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 NewOAuthClientRegistrationErrorWithDefaults() *OAuthClientRegistrationError { + this := OAuthClientRegistrationError{} + return &this +} + +// GetError returns the Error field value. +func (o *OAuthClientRegistrationError) GetError() string { + if o == nil { + var ret string + return ret + } + return o.Error +} + +// GetErrorOk returns a tuple with the Error field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationError) GetErrorOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Error, true +} + +// SetError sets field value. +func (o *OAuthClientRegistrationError) SetError(v string) { + o.Error = v +} + +// GetErrorDescription returns the ErrorDescription field value. +func (o *OAuthClientRegistrationError) GetErrorDescription() string { + if o == nil { + var ret string + return ret + } + return o.ErrorDescription +} + +// GetErrorDescriptionOk returns a tuple with the ErrorDescription field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationError) GetErrorDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ErrorDescription, true +} + +// SetErrorDescription sets field value. +func (o *OAuthClientRegistrationError) SetErrorDescription(v string) { + o.ErrorDescription = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthClientRegistrationError) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["error"] = o.Error + toSerialize["error_description"] = o.ErrorDescription + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OAuthClientRegistrationError) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Error *string `json:"error"` + ErrorDescription *string `json:"error_description"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Error == nil { + return fmt.Errorf("required field error missing") + } + if all.ErrorDescription == nil { + return fmt.Errorf("required field error_description missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"error", "error_description"}) + } else { + return err + } + o.Error = *all.Error + o.ErrorDescription = *all.ErrorDescription + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_o_auth_client_registration_grant_type.go b/api/datadogV2/model_o_auth_client_registration_grant_type.go new file mode 100644 index 00000000000..ae7a9828ee3 --- /dev/null +++ b/api/datadogV2/model_o_auth_client_registration_grant_type.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" +) + +// OAuthClientRegistrationGrantType OAuth 2.0 grant type that a registered client may use. +type OAuthClientRegistrationGrantType string + +// List of OAuthClientRegistrationGrantType. +const ( + OAUTHCLIENTREGISTRATIONGRANTTYPE_AUTHORIZATION_CODE OAuthClientRegistrationGrantType = "authorization_code" + OAUTHCLIENTREGISTRATIONGRANTTYPE_REFRESH_TOKEN OAuthClientRegistrationGrantType = "refresh_token" +) + +var allowedOAuthClientRegistrationGrantTypeEnumValues = []OAuthClientRegistrationGrantType{ + OAUTHCLIENTREGISTRATIONGRANTTYPE_AUTHORIZATION_CODE, + OAUTHCLIENTREGISTRATIONGRANTTYPE_REFRESH_TOKEN, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OAuthClientRegistrationGrantType) GetAllowedValues() []OAuthClientRegistrationGrantType { + return allowedOAuthClientRegistrationGrantTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OAuthClientRegistrationGrantType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OAuthClientRegistrationGrantType(value) + return nil +} + +// NewOAuthClientRegistrationGrantTypeFromValue returns a pointer to a valid OAuthClientRegistrationGrantType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOAuthClientRegistrationGrantTypeFromValue(v string) (*OAuthClientRegistrationGrantType, error) { + ev := OAuthClientRegistrationGrantType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OAuthClientRegistrationGrantType: valid values are %v", v, allowedOAuthClientRegistrationGrantTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OAuthClientRegistrationGrantType) IsValid() bool { + for _, existing := range allowedOAuthClientRegistrationGrantTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OAuthClientRegistrationGrantType value. +func (v OAuthClientRegistrationGrantType) Ptr() *OAuthClientRegistrationGrantType { + return &v +} diff --git a/api/datadogV2/model_o_auth_client_registration_request.go b/api/datadogV2/model_o_auth_client_registration_request.go new file mode 100644 index 00000000000..a53aa2627cd --- /dev/null +++ b/api/datadogV2/model_o_auth_client_registration_request.go @@ -0,0 +1,449 @@ +// 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" +) + +// OAuthClientRegistrationRequest Request payload for OAuth2 dynamic client registration as defined by RFC 7591. +type OAuthClientRegistrationRequest struct { + // Human-readable name of the client. Control characters are rejected. + ClientName string `json:"client_name"` + // URL of the home page of the client. + ClientUri *string `json:"client_uri,omitempty"` + // OAuth 2.0 grant types the client may use. + // Defaults to `authorization_code` and `refresh_token` when omitted. + GrantTypes []OAuthClientRegistrationGrantType `json:"grant_types,omitempty"` + // URL referencing the client's JSON Web Key Set. + JwksUri *string `json:"jwks_uri,omitempty"` + // URL referencing a logo for the client. + LogoUri *string `json:"logo_uri,omitempty"` + // URL pointing to the client's privacy policy. + PolicyUri *string `json:"policy_uri,omitempty"` + // Array of redirection URI strings used by the client in redirect-based flows. + RedirectUris []string `json:"redirect_uris"` + // OAuth 2.0 response types the client may use. Only `code` is supported. + ResponseTypes []OAuthClientRegistrationResponseType `json:"response_types,omitempty"` + // Space-separated list of scope values the client may request. + Scope *string `json:"scope,omitempty"` + // Requested authentication method for the token endpoint. Only `none` is supported. + TokenEndpointAuthMethod *string `json:"token_endpoint_auth_method,omitempty"` + // URL pointing to the client's terms of service. + TosUri *string `json:"tos_uri,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:"-"` +} + +// NewOAuthClientRegistrationRequest instantiates a new OAuthClientRegistrationRequest 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 NewOAuthClientRegistrationRequest(clientName string, redirectUris []string) *OAuthClientRegistrationRequest { + this := OAuthClientRegistrationRequest{} + this.ClientName = clientName + this.RedirectUris = redirectUris + return &this +} + +// NewOAuthClientRegistrationRequestWithDefaults instantiates a new OAuthClientRegistrationRequest 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 NewOAuthClientRegistrationRequestWithDefaults() *OAuthClientRegistrationRequest { + this := OAuthClientRegistrationRequest{} + return &this +} + +// GetClientName returns the ClientName field value. +func (o *OAuthClientRegistrationRequest) GetClientName() string { + if o == nil { + var ret string + return ret + } + return o.ClientName +} + +// GetClientNameOk returns a tuple with the ClientName field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetClientNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClientName, true +} + +// SetClientName sets field value. +func (o *OAuthClientRegistrationRequest) SetClientName(v string) { + o.ClientName = v +} + +// GetClientUri returns the ClientUri field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetClientUri() string { + if o == nil || o.ClientUri == nil { + var ret string + return ret + } + return *o.ClientUri +} + +// GetClientUriOk returns a tuple with the ClientUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetClientUriOk() (*string, bool) { + if o == nil || o.ClientUri == nil { + return nil, false + } + return o.ClientUri, true +} + +// HasClientUri returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasClientUri() bool { + return o != nil && o.ClientUri != nil +} + +// SetClientUri gets a reference to the given string and assigns it to the ClientUri field. +func (o *OAuthClientRegistrationRequest) SetClientUri(v string) { + o.ClientUri = &v +} + +// GetGrantTypes returns the GrantTypes field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetGrantTypes() []OAuthClientRegistrationGrantType { + if o == nil || o.GrantTypes == nil { + var ret []OAuthClientRegistrationGrantType + return ret + } + return o.GrantTypes +} + +// GetGrantTypesOk returns a tuple with the GrantTypes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetGrantTypesOk() (*[]OAuthClientRegistrationGrantType, bool) { + if o == nil || o.GrantTypes == nil { + return nil, false + } + return &o.GrantTypes, true +} + +// HasGrantTypes returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasGrantTypes() bool { + return o != nil && o.GrantTypes != nil +} + +// SetGrantTypes gets a reference to the given []OAuthClientRegistrationGrantType and assigns it to the GrantTypes field. +func (o *OAuthClientRegistrationRequest) SetGrantTypes(v []OAuthClientRegistrationGrantType) { + o.GrantTypes = v +} + +// GetJwksUri returns the JwksUri field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetJwksUri() string { + if o == nil || o.JwksUri == nil { + var ret string + return ret + } + return *o.JwksUri +} + +// GetJwksUriOk returns a tuple with the JwksUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetJwksUriOk() (*string, bool) { + if o == nil || o.JwksUri == nil { + return nil, false + } + return o.JwksUri, true +} + +// HasJwksUri returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasJwksUri() bool { + return o != nil && o.JwksUri != nil +} + +// SetJwksUri gets a reference to the given string and assigns it to the JwksUri field. +func (o *OAuthClientRegistrationRequest) SetJwksUri(v string) { + o.JwksUri = &v +} + +// GetLogoUri returns the LogoUri field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetLogoUri() string { + if o == nil || o.LogoUri == nil { + var ret string + return ret + } + return *o.LogoUri +} + +// GetLogoUriOk returns a tuple with the LogoUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetLogoUriOk() (*string, bool) { + if o == nil || o.LogoUri == nil { + return nil, false + } + return o.LogoUri, true +} + +// HasLogoUri returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasLogoUri() bool { + return o != nil && o.LogoUri != nil +} + +// SetLogoUri gets a reference to the given string and assigns it to the LogoUri field. +func (o *OAuthClientRegistrationRequest) SetLogoUri(v string) { + o.LogoUri = &v +} + +// GetPolicyUri returns the PolicyUri field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetPolicyUri() string { + if o == nil || o.PolicyUri == nil { + var ret string + return ret + } + return *o.PolicyUri +} + +// GetPolicyUriOk returns a tuple with the PolicyUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetPolicyUriOk() (*string, bool) { + if o == nil || o.PolicyUri == nil { + return nil, false + } + return o.PolicyUri, true +} + +// HasPolicyUri returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasPolicyUri() bool { + return o != nil && o.PolicyUri != nil +} + +// SetPolicyUri gets a reference to the given string and assigns it to the PolicyUri field. +func (o *OAuthClientRegistrationRequest) SetPolicyUri(v string) { + o.PolicyUri = &v +} + +// GetRedirectUris returns the RedirectUris field value. +func (o *OAuthClientRegistrationRequest) GetRedirectUris() []string { + if o == nil { + var ret []string + return ret + } + return o.RedirectUris +} + +// GetRedirectUrisOk returns a tuple with the RedirectUris field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetRedirectUrisOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.RedirectUris, true +} + +// SetRedirectUris sets field value. +func (o *OAuthClientRegistrationRequest) SetRedirectUris(v []string) { + o.RedirectUris = v +} + +// GetResponseTypes returns the ResponseTypes field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetResponseTypes() []OAuthClientRegistrationResponseType { + if o == nil || o.ResponseTypes == nil { + var ret []OAuthClientRegistrationResponseType + return ret + } + return o.ResponseTypes +} + +// GetResponseTypesOk returns a tuple with the ResponseTypes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetResponseTypesOk() (*[]OAuthClientRegistrationResponseType, bool) { + if o == nil || o.ResponseTypes == nil { + return nil, false + } + return &o.ResponseTypes, true +} + +// HasResponseTypes returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasResponseTypes() bool { + return o != nil && o.ResponseTypes != nil +} + +// SetResponseTypes gets a reference to the given []OAuthClientRegistrationResponseType and assigns it to the ResponseTypes field. +func (o *OAuthClientRegistrationRequest) SetResponseTypes(v []OAuthClientRegistrationResponseType) { + o.ResponseTypes = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetScope() string { + if o == nil || o.Scope == nil { + var ret string + return ret + } + return *o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetScopeOk() (*string, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given string and assigns it to the Scope field. +func (o *OAuthClientRegistrationRequest) SetScope(v string) { + o.Scope = &v +} + +// GetTokenEndpointAuthMethod returns the TokenEndpointAuthMethod field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetTokenEndpointAuthMethod() string { + if o == nil || o.TokenEndpointAuthMethod == nil { + var ret string + return ret + } + return *o.TokenEndpointAuthMethod +} + +// GetTokenEndpointAuthMethodOk returns a tuple with the TokenEndpointAuthMethod field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetTokenEndpointAuthMethodOk() (*string, bool) { + if o == nil || o.TokenEndpointAuthMethod == nil { + return nil, false + } + return o.TokenEndpointAuthMethod, true +} + +// HasTokenEndpointAuthMethod returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasTokenEndpointAuthMethod() bool { + return o != nil && o.TokenEndpointAuthMethod != nil +} + +// SetTokenEndpointAuthMethod gets a reference to the given string and assigns it to the TokenEndpointAuthMethod field. +func (o *OAuthClientRegistrationRequest) SetTokenEndpointAuthMethod(v string) { + o.TokenEndpointAuthMethod = &v +} + +// GetTosUri returns the TosUri field value if set, zero value otherwise. +func (o *OAuthClientRegistrationRequest) GetTosUri() string { + if o == nil || o.TosUri == nil { + var ret string + return ret + } + return *o.TosUri +} + +// GetTosUriOk returns a tuple with the TosUri field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationRequest) GetTosUriOk() (*string, bool) { + if o == nil || o.TosUri == nil { + return nil, false + } + return o.TosUri, true +} + +// HasTosUri returns a boolean if a field has been set. +func (o *OAuthClientRegistrationRequest) HasTosUri() bool { + return o != nil && o.TosUri != nil +} + +// SetTosUri gets a reference to the given string and assigns it to the TosUri field. +func (o *OAuthClientRegistrationRequest) SetTosUri(v string) { + o.TosUri = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthClientRegistrationRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["client_name"] = o.ClientName + if o.ClientUri != nil { + toSerialize["client_uri"] = o.ClientUri + } + if o.GrantTypes != nil { + toSerialize["grant_types"] = o.GrantTypes + } + if o.JwksUri != nil { + toSerialize["jwks_uri"] = o.JwksUri + } + if o.LogoUri != nil { + toSerialize["logo_uri"] = o.LogoUri + } + if o.PolicyUri != nil { + toSerialize["policy_uri"] = o.PolicyUri + } + toSerialize["redirect_uris"] = o.RedirectUris + if o.ResponseTypes != nil { + toSerialize["response_types"] = o.ResponseTypes + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + if o.TokenEndpointAuthMethod != nil { + toSerialize["token_endpoint_auth_method"] = o.TokenEndpointAuthMethod + } + if o.TosUri != nil { + toSerialize["tos_uri"] = o.TosUri + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OAuthClientRegistrationRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ClientName *string `json:"client_name"` + ClientUri *string `json:"client_uri,omitempty"` + GrantTypes []OAuthClientRegistrationGrantType `json:"grant_types,omitempty"` + JwksUri *string `json:"jwks_uri,omitempty"` + LogoUri *string `json:"logo_uri,omitempty"` + PolicyUri *string `json:"policy_uri,omitempty"` + RedirectUris *[]string `json:"redirect_uris"` + ResponseTypes []OAuthClientRegistrationResponseType `json:"response_types,omitempty"` + Scope *string `json:"scope,omitempty"` + TokenEndpointAuthMethod *string `json:"token_endpoint_auth_method,omitempty"` + TosUri *string `json:"tos_uri,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ClientName == nil { + return fmt.Errorf("required field client_name missing") + } + if all.RedirectUris == nil { + return fmt.Errorf("required field redirect_uris missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"client_name", "client_uri", "grant_types", "jwks_uri", "logo_uri", "policy_uri", "redirect_uris", "response_types", "scope", "token_endpoint_auth_method", "tos_uri"}) + } else { + return err + } + o.ClientName = *all.ClientName + o.ClientUri = all.ClientUri + o.GrantTypes = all.GrantTypes + o.JwksUri = all.JwksUri + o.LogoUri = all.LogoUri + o.PolicyUri = all.PolicyUri + o.RedirectUris = *all.RedirectUris + o.ResponseTypes = all.ResponseTypes + o.Scope = all.Scope + o.TokenEndpointAuthMethod = all.TokenEndpointAuthMethod + o.TosUri = all.TosUri + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_o_auth_client_registration_response.go b/api/datadogV2/model_o_auth_client_registration_response.go new file mode 100644 index 00000000000..92dd0ae81a2 --- /dev/null +++ b/api/datadogV2/model_o_auth_client_registration_response.go @@ -0,0 +1,263 @@ +// 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/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OAuthClientRegistrationResponse Response payload for a successful OAuth2 dynamic client registration as defined by RFC 7591. +type OAuthClientRegistrationResponse struct { + // Unique identifier assigned to the registered client. + ClientId uuid.UUID `json:"client_id"` + // Human-readable name of the client. + ClientName string `json:"client_name"` + // OAuth 2.0 grant types registered for the client. + GrantTypes []OAuthClientRegistrationGrantType `json:"grant_types"` + // Redirection URIs registered for the client. + RedirectUris []string `json:"redirect_uris"` + // OAuth 2.0 response types registered for the client. + ResponseTypes []OAuthClientRegistrationResponseType `json:"response_types"` + // Authentication method registered for the token endpoint. Always `none`. + TokenEndpointAuthMethod string `json:"token_endpoint_auth_method"` + // 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:"-"` +} + +// NewOAuthClientRegistrationResponse instantiates a new OAuthClientRegistrationResponse 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 NewOAuthClientRegistrationResponse(clientId uuid.UUID, clientName string, grantTypes []OAuthClientRegistrationGrantType, redirectUris []string, responseTypes []OAuthClientRegistrationResponseType, tokenEndpointAuthMethod string) *OAuthClientRegistrationResponse { + this := OAuthClientRegistrationResponse{} + this.ClientId = clientId + this.ClientName = clientName + this.GrantTypes = grantTypes + this.RedirectUris = redirectUris + this.ResponseTypes = responseTypes + this.TokenEndpointAuthMethod = tokenEndpointAuthMethod + return &this +} + +// NewOAuthClientRegistrationResponseWithDefaults instantiates a new OAuthClientRegistrationResponse 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 NewOAuthClientRegistrationResponseWithDefaults() *OAuthClientRegistrationResponse { + this := OAuthClientRegistrationResponse{} + return &this +} + +// GetClientId returns the ClientId field value. +func (o *OAuthClientRegistrationResponse) GetClientId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.ClientId +} + +// GetClientIdOk returns a tuple with the ClientId field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetClientIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.ClientId, true +} + +// SetClientId sets field value. +func (o *OAuthClientRegistrationResponse) SetClientId(v uuid.UUID) { + o.ClientId = v +} + +// GetClientName returns the ClientName field value. +func (o *OAuthClientRegistrationResponse) GetClientName() string { + if o == nil { + var ret string + return ret + } + return o.ClientName +} + +// GetClientNameOk returns a tuple with the ClientName field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetClientNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ClientName, true +} + +// SetClientName sets field value. +func (o *OAuthClientRegistrationResponse) SetClientName(v string) { + o.ClientName = v +} + +// GetGrantTypes returns the GrantTypes field value. +func (o *OAuthClientRegistrationResponse) GetGrantTypes() []OAuthClientRegistrationGrantType { + if o == nil { + var ret []OAuthClientRegistrationGrantType + return ret + } + return o.GrantTypes +} + +// GetGrantTypesOk returns a tuple with the GrantTypes field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetGrantTypesOk() (*[]OAuthClientRegistrationGrantType, bool) { + if o == nil { + return nil, false + } + return &o.GrantTypes, true +} + +// SetGrantTypes sets field value. +func (o *OAuthClientRegistrationResponse) SetGrantTypes(v []OAuthClientRegistrationGrantType) { + o.GrantTypes = v +} + +// GetRedirectUris returns the RedirectUris field value. +func (o *OAuthClientRegistrationResponse) GetRedirectUris() []string { + if o == nil { + var ret []string + return ret + } + return o.RedirectUris +} + +// GetRedirectUrisOk returns a tuple with the RedirectUris field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetRedirectUrisOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.RedirectUris, true +} + +// SetRedirectUris sets field value. +func (o *OAuthClientRegistrationResponse) SetRedirectUris(v []string) { + o.RedirectUris = v +} + +// GetResponseTypes returns the ResponseTypes field value. +func (o *OAuthClientRegistrationResponse) GetResponseTypes() []OAuthClientRegistrationResponseType { + if o == nil { + var ret []OAuthClientRegistrationResponseType + return ret + } + return o.ResponseTypes +} + +// GetResponseTypesOk returns a tuple with the ResponseTypes field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetResponseTypesOk() (*[]OAuthClientRegistrationResponseType, bool) { + if o == nil { + return nil, false + } + return &o.ResponseTypes, true +} + +// SetResponseTypes sets field value. +func (o *OAuthClientRegistrationResponse) SetResponseTypes(v []OAuthClientRegistrationResponseType) { + o.ResponseTypes = v +} + +// GetTokenEndpointAuthMethod returns the TokenEndpointAuthMethod field value. +func (o *OAuthClientRegistrationResponse) GetTokenEndpointAuthMethod() string { + if o == nil { + var ret string + return ret + } + return o.TokenEndpointAuthMethod +} + +// GetTokenEndpointAuthMethodOk returns a tuple with the TokenEndpointAuthMethod field value +// and a boolean to check if the value has been set. +func (o *OAuthClientRegistrationResponse) GetTokenEndpointAuthMethodOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.TokenEndpointAuthMethod, true +} + +// SetTokenEndpointAuthMethod sets field value. +func (o *OAuthClientRegistrationResponse) SetTokenEndpointAuthMethod(v string) { + o.TokenEndpointAuthMethod = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthClientRegistrationResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["client_id"] = o.ClientId + toSerialize["client_name"] = o.ClientName + toSerialize["grant_types"] = o.GrantTypes + toSerialize["redirect_uris"] = o.RedirectUris + toSerialize["response_types"] = o.ResponseTypes + toSerialize["token_endpoint_auth_method"] = o.TokenEndpointAuthMethod + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OAuthClientRegistrationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ClientId *uuid.UUID `json:"client_id"` + ClientName *string `json:"client_name"` + GrantTypes *[]OAuthClientRegistrationGrantType `json:"grant_types"` + RedirectUris *[]string `json:"redirect_uris"` + ResponseTypes *[]OAuthClientRegistrationResponseType `json:"response_types"` + TokenEndpointAuthMethod *string `json:"token_endpoint_auth_method"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ClientId == nil { + return fmt.Errorf("required field client_id missing") + } + if all.ClientName == nil { + return fmt.Errorf("required field client_name missing") + } + if all.GrantTypes == nil { + return fmt.Errorf("required field grant_types missing") + } + if all.RedirectUris == nil { + return fmt.Errorf("required field redirect_uris missing") + } + if all.ResponseTypes == nil { + return fmt.Errorf("required field response_types missing") + } + if all.TokenEndpointAuthMethod == nil { + return fmt.Errorf("required field token_endpoint_auth_method missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"client_id", "client_name", "grant_types", "redirect_uris", "response_types", "token_endpoint_auth_method"}) + } else { + return err + } + o.ClientId = *all.ClientId + o.ClientName = *all.ClientName + o.GrantTypes = *all.GrantTypes + o.RedirectUris = *all.RedirectUris + o.ResponseTypes = *all.ResponseTypes + o.TokenEndpointAuthMethod = *all.TokenEndpointAuthMethod + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_o_auth_client_registration_response_type.go b/api/datadogV2/model_o_auth_client_registration_response_type.go new file mode 100644 index 00000000000..41e83386abc --- /dev/null +++ b/api/datadogV2/model_o_auth_client_registration_response_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" +) + +// OAuthClientRegistrationResponseType OAuth 2.0 response type that a registered client may use. +type OAuthClientRegistrationResponseType string + +// List of OAuthClientRegistrationResponseType. +const ( + OAUTHCLIENTREGISTRATIONRESPONSETYPE_CODE OAuthClientRegistrationResponseType = "code" +) + +var allowedOAuthClientRegistrationResponseTypeEnumValues = []OAuthClientRegistrationResponseType{ + OAUTHCLIENTREGISTRATIONRESPONSETYPE_CODE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OAuthClientRegistrationResponseType) GetAllowedValues() []OAuthClientRegistrationResponseType { + return allowedOAuthClientRegistrationResponseTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OAuthClientRegistrationResponseType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OAuthClientRegistrationResponseType(value) + return nil +} + +// NewOAuthClientRegistrationResponseTypeFromValue returns a pointer to a valid OAuthClientRegistrationResponseType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOAuthClientRegistrationResponseTypeFromValue(v string) (*OAuthClientRegistrationResponseType, error) { + ev := OAuthClientRegistrationResponseType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OAuthClientRegistrationResponseType: valid values are %v", v, allowedOAuthClientRegistrationResponseTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OAuthClientRegistrationResponseType) IsValid() bool { + for _, existing := range allowedOAuthClientRegistrationResponseTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OAuthClientRegistrationResponseType value. +func (v OAuthClientRegistrationResponseType) Ptr() *OAuthClientRegistrationResponseType { + return &v +} diff --git a/api/datadogV2/model_o_auth_oidc_scope.go b/api/datadogV2/model_o_auth_oidc_scope.go new file mode 100644 index 00000000000..44dd91c3d0e --- /dev/null +++ b/api/datadogV2/model_o_auth_oidc_scope.go @@ -0,0 +1,70 @@ +// 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" +) + +// OAuthOidcScope OIDC scope a client may be restricted to. +type OAuthOidcScope string + +// List of OAuthOidcScope. +const ( + OAUTHOIDCSCOPE_OPENID OAuthOidcScope = "openid" + OAUTHOIDCSCOPE_PROFILE OAuthOidcScope = "profile" + OAUTHOIDCSCOPE_EMAIL OAuthOidcScope = "email" + OAUTHOIDCSCOPE_OFFLINE_ACCESS OAuthOidcScope = "offline_access" +) + +var allowedOAuthOidcScopeEnumValues = []OAuthOidcScope{ + OAUTHOIDCSCOPE_OPENID, + OAUTHOIDCSCOPE_PROFILE, + OAUTHOIDCSCOPE_EMAIL, + OAUTHOIDCSCOPE_OFFLINE_ACCESS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OAuthOidcScope) GetAllowedValues() []OAuthOidcScope { + return allowedOAuthOidcScopeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OAuthOidcScope) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OAuthOidcScope(value) + return nil +} + +// NewOAuthOidcScopeFromValue returns a pointer to a valid OAuthOidcScope +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOAuthOidcScopeFromValue(v string) (*OAuthOidcScope, error) { + ev := OAuthOidcScope(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OAuthOidcScope: valid values are %v", v, allowedOAuthOidcScopeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OAuthOidcScope) IsValid() bool { + for _, existing := range allowedOAuthOidcScopeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OAuthOidcScope value. +func (v OAuthOidcScope) Ptr() *OAuthOidcScope { + return &v +} diff --git a/api/datadogV2/model_o_auth_scopes_restriction.go b/api/datadogV2/model_o_auth_scopes_restriction.go new file mode 100644 index 00000000000..1b5f8820c11 --- /dev/null +++ b/api/datadogV2/model_o_auth_scopes_restriction.go @@ -0,0 +1,183 @@ +// 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" +) + +// OAuthScopesRestriction Allowlist of OIDC and permission scopes enforced for the OAuth2 client. +type OAuthScopesRestriction struct { + // OIDC scopes the client is restricted to. + OidcScopes []OAuthOidcScope `json:"oidc_scopes"` + // Datadog permission scopes the client is restricted to. + PermissionScopes []string `json:"permission_scopes"` + // 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:"-"` +} + +// NewOAuthScopesRestriction instantiates a new OAuthScopesRestriction 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 NewOAuthScopesRestriction(oidcScopes []OAuthOidcScope, permissionScopes []string) *OAuthScopesRestriction { + this := OAuthScopesRestriction{} + this.OidcScopes = oidcScopes + this.PermissionScopes = permissionScopes + return &this +} + +// NewOAuthScopesRestrictionWithDefaults instantiates a new OAuthScopesRestriction 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 NewOAuthScopesRestrictionWithDefaults() *OAuthScopesRestriction { + this := OAuthScopesRestriction{} + return &this +} + +// GetOidcScopes returns the OidcScopes field value. +func (o *OAuthScopesRestriction) GetOidcScopes() []OAuthOidcScope { + if o == nil { + var ret []OAuthOidcScope + return ret + } + return o.OidcScopes +} + +// GetOidcScopesOk returns a tuple with the OidcScopes field value +// and a boolean to check if the value has been set. +func (o *OAuthScopesRestriction) GetOidcScopesOk() (*[]OAuthOidcScope, bool) { + if o == nil { + return nil, false + } + return &o.OidcScopes, true +} + +// SetOidcScopes sets field value. +func (o *OAuthScopesRestriction) SetOidcScopes(v []OAuthOidcScope) { + o.OidcScopes = v +} + +// GetPermissionScopes returns the PermissionScopes field value. +func (o *OAuthScopesRestriction) GetPermissionScopes() []string { + if o == nil { + var ret []string + return ret + } + return o.PermissionScopes +} + +// GetPermissionScopesOk returns a tuple with the PermissionScopes field value +// and a boolean to check if the value has been set. +func (o *OAuthScopesRestriction) GetPermissionScopesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.PermissionScopes, true +} + +// SetPermissionScopes sets field value. +func (o *OAuthScopesRestriction) SetPermissionScopes(v []string) { + o.PermissionScopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthScopesRestriction) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["oidc_scopes"] = o.OidcScopes + toSerialize["permission_scopes"] = o.PermissionScopes + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OAuthScopesRestriction) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + OidcScopes *[]OAuthOidcScope `json:"oidc_scopes"` + PermissionScopes *[]string `json:"permission_scopes"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.OidcScopes == nil { + return fmt.Errorf("required field oidc_scopes missing") + } + if all.PermissionScopes == nil { + return fmt.Errorf("required field permission_scopes missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"oidc_scopes", "permission_scopes"}) + } else { + return err + } + o.OidcScopes = *all.OidcScopes + o.PermissionScopes = *all.PermissionScopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} + +// NullableOAuthScopesRestriction handles when a null is used for OAuthScopesRestriction. +type NullableOAuthScopesRestriction struct { + value *OAuthScopesRestriction + isSet bool +} + +// Get returns the associated value. +func (v NullableOAuthScopesRestriction) Get() *OAuthScopesRestriction { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableOAuthScopesRestriction) Set(val *OAuthScopesRestriction) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableOAuthScopesRestriction) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableOAuthScopesRestriction) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableOAuthScopesRestriction initializes the struct as if Set has been called. +func NewNullableOAuthScopesRestriction(val *OAuthScopesRestriction) *NullableOAuthScopesRestriction { + return &NullableOAuthScopesRestriction{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableOAuthScopesRestriction) MarshalJSON() ([]byte, error) { + return datadog.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableOAuthScopesRestriction) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return datadog.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_o_auth_scopes_restriction_response.go b/api/datadogV2/model_o_auth_scopes_restriction_response.go new file mode 100644 index 00000000000..3147c163ccd --- /dev/null +++ b/api/datadogV2/model_o_auth_scopes_restriction_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" +) + +// OAuthScopesRestrictionResponse Response payload describing the scopes restriction of an OAuth2 client. +type OAuthScopesRestrictionResponse struct { + // Data object of an OAuth2 client scopes restriction response. + Data OAuthScopesRestrictionResponseData `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:"-"` +} + +// NewOAuthScopesRestrictionResponse instantiates a new OAuthScopesRestrictionResponse 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 NewOAuthScopesRestrictionResponse(data OAuthScopesRestrictionResponseData) *OAuthScopesRestrictionResponse { + this := OAuthScopesRestrictionResponse{} + this.Data = data + return &this +} + +// NewOAuthScopesRestrictionResponseWithDefaults instantiates a new OAuthScopesRestrictionResponse 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 NewOAuthScopesRestrictionResponseWithDefaults() *OAuthScopesRestrictionResponse { + this := OAuthScopesRestrictionResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *OAuthScopesRestrictionResponse) GetData() OAuthScopesRestrictionResponseData { + if o == nil { + var ret OAuthScopesRestrictionResponseData + 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 *OAuthScopesRestrictionResponse) GetDataOk() (*OAuthScopesRestrictionResponseData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *OAuthScopesRestrictionResponse) SetData(v OAuthScopesRestrictionResponseData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthScopesRestrictionResponse) 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 *OAuthScopesRestrictionResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *OAuthScopesRestrictionResponseData `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_o_auth_scopes_restriction_response_attributes.go b/api/datadogV2/model_o_auth_scopes_restriction_response_attributes.go new file mode 100644 index 00000000000..6537fc248b3 --- /dev/null +++ b/api/datadogV2/model_o_auth_scopes_restriction_response_attributes.go @@ -0,0 +1,138 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OAuthScopesRestrictionResponseAttributes Attributes of an OAuth2 client scopes restriction. +type OAuthScopesRestrictionResponseAttributes struct { + // Permission scopes automatically required for this client (for example, mobile-app permission scopes). + // Returns `null` when no scopes are required. + RequiredPermissionScopes datadog.NullableList[string] `json:"required_permission_scopes"` + // Allowlist of OIDC and permission scopes enforced for the OAuth2 client. + ScopesRestriction NullableOAuthScopesRestriction `json:"scopes_restriction"` + // 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:"-"` +} + +// NewOAuthScopesRestrictionResponseAttributes instantiates a new OAuthScopesRestrictionResponseAttributes 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 NewOAuthScopesRestrictionResponseAttributes(requiredPermissionScopes datadog.NullableList[string], scopesRestriction NullableOAuthScopesRestriction) *OAuthScopesRestrictionResponseAttributes { + this := OAuthScopesRestrictionResponseAttributes{} + this.RequiredPermissionScopes = requiredPermissionScopes + this.ScopesRestriction = scopesRestriction + return &this +} + +// NewOAuthScopesRestrictionResponseAttributesWithDefaults instantiates a new OAuthScopesRestrictionResponseAttributes 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 NewOAuthScopesRestrictionResponseAttributesWithDefaults() *OAuthScopesRestrictionResponseAttributes { + this := OAuthScopesRestrictionResponseAttributes{} + return &this +} + +// GetRequiredPermissionScopes returns the RequiredPermissionScopes field value. +// If the value is explicit nil, the zero value for []string will be returned. +func (o *OAuthScopesRestrictionResponseAttributes) GetRequiredPermissionScopes() []string { + if o == nil || o.RequiredPermissionScopes.Get() == nil { + var ret []string + return ret + } + return *o.RequiredPermissionScopes.Get() +} + +// GetRequiredPermissionScopesOk returns a tuple with the RequiredPermissionScopes field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *OAuthScopesRestrictionResponseAttributes) GetRequiredPermissionScopesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return o.RequiredPermissionScopes.Get(), o.RequiredPermissionScopes.IsSet() +} + +// SetRequiredPermissionScopes sets field value. +func (o *OAuthScopesRestrictionResponseAttributes) SetRequiredPermissionScopes(v []string) { + o.RequiredPermissionScopes.Set(&v) +} + +// GetScopesRestriction returns the ScopesRestriction field value. +// If the value is explicit nil, the zero value for OAuthScopesRestriction will be returned. +func (o *OAuthScopesRestrictionResponseAttributes) GetScopesRestriction() OAuthScopesRestriction { + if o == nil || o.ScopesRestriction.Get() == nil { + var ret OAuthScopesRestriction + return ret + } + return *o.ScopesRestriction.Get() +} + +// GetScopesRestrictionOk returns a tuple with the ScopesRestriction field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *OAuthScopesRestrictionResponseAttributes) GetScopesRestrictionOk() (*OAuthScopesRestriction, bool) { + if o == nil { + return nil, false + } + return o.ScopesRestriction.Get(), o.ScopesRestriction.IsSet() +} + +// SetScopesRestriction sets field value. +func (o *OAuthScopesRestrictionResponseAttributes) SetScopesRestriction(v OAuthScopesRestriction) { + o.ScopesRestriction.Set(&v) +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthScopesRestrictionResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["required_permission_scopes"] = o.RequiredPermissionScopes.Get() + toSerialize["scopes_restriction"] = o.ScopesRestriction.Get() + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *OAuthScopesRestrictionResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RequiredPermissionScopes datadog.NullableList[string] `json:"required_permission_scopes"` + ScopesRestriction NullableOAuthScopesRestriction `json:"scopes_restriction"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if !all.RequiredPermissionScopes.IsSet() { + return fmt.Errorf("required field required_permission_scopes missing") + } + if !all.ScopesRestriction.IsSet() { + return fmt.Errorf("required field scopes_restriction missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"required_permission_scopes", "scopes_restriction"}) + } else { + return err + } + o.RequiredPermissionScopes = all.RequiredPermissionScopes + o.ScopesRestriction = all.ScopesRestriction + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_o_auth_scopes_restriction_response_data.go b/api/datadogV2/model_o_auth_scopes_restriction_response_data.go new file mode 100644 index 00000000000..9bdb0f3b130 --- /dev/null +++ b/api/datadogV2/model_o_auth_scopes_restriction_response_data.go @@ -0,0 +1,182 @@ +// 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/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// OAuthScopesRestrictionResponseData Data object of an OAuth2 client scopes restriction response. +type OAuthScopesRestrictionResponseData struct { + // Attributes of an OAuth2 client scopes restriction. + Attributes OAuthScopesRestrictionResponseAttributes `json:"attributes"` + // UUID of the OAuth2 client this restriction applies to. + Id uuid.UUID `json:"id"` + // JSON:API resource type for an OAuth2 client scopes restriction. + Type OAuthScopesRestrictionType `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:"-"` +} + +// NewOAuthScopesRestrictionResponseData instantiates a new OAuthScopesRestrictionResponseData 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 NewOAuthScopesRestrictionResponseData(attributes OAuthScopesRestrictionResponseAttributes, id uuid.UUID, typeVar OAuthScopesRestrictionType) *OAuthScopesRestrictionResponseData { + this := OAuthScopesRestrictionResponseData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewOAuthScopesRestrictionResponseDataWithDefaults instantiates a new OAuthScopesRestrictionResponseData 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 NewOAuthScopesRestrictionResponseDataWithDefaults() *OAuthScopesRestrictionResponseData { + this := OAuthScopesRestrictionResponseData{} + var typeVar OAuthScopesRestrictionType = OAUTHSCOPESRESTRICTIONTYPE_SCOPES_RESTRICTION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *OAuthScopesRestrictionResponseData) GetAttributes() OAuthScopesRestrictionResponseAttributes { + if o == nil { + var ret OAuthScopesRestrictionResponseAttributes + 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 *OAuthScopesRestrictionResponseData) GetAttributesOk() (*OAuthScopesRestrictionResponseAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *OAuthScopesRestrictionResponseData) SetAttributes(v OAuthScopesRestrictionResponseAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *OAuthScopesRestrictionResponseData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + 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 *OAuthScopesRestrictionResponseData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *OAuthScopesRestrictionResponseData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *OAuthScopesRestrictionResponseData) GetType() OAuthScopesRestrictionType { + if o == nil { + var ret OAuthScopesRestrictionType + 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 *OAuthScopesRestrictionResponseData) GetTypeOk() (*OAuthScopesRestrictionType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *OAuthScopesRestrictionResponseData) SetType(v OAuthScopesRestrictionType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o OAuthScopesRestrictionResponseData) 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 *OAuthScopesRestrictionResponseData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *OAuthScopesRestrictionResponseAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *OAuthScopesRestrictionType `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_o_auth_scopes_restriction_type.go b/api/datadogV2/model_o_auth_scopes_restriction_type.go new file mode 100644 index 00000000000..cc4c1c04c21 --- /dev/null +++ b/api/datadogV2/model_o_auth_scopes_restriction_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" +) + +// OAuthScopesRestrictionType JSON:API resource type for an OAuth2 client scopes restriction. +type OAuthScopesRestrictionType string + +// List of OAuthScopesRestrictionType. +const ( + OAUTHSCOPESRESTRICTIONTYPE_SCOPES_RESTRICTION OAuthScopesRestrictionType = "scopes_restriction" +) + +var allowedOAuthScopesRestrictionTypeEnumValues = []OAuthScopesRestrictionType{ + OAUTHSCOPESRESTRICTIONTYPE_SCOPES_RESTRICTION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *OAuthScopesRestrictionType) GetAllowedValues() []OAuthScopesRestrictionType { + return allowedOAuthScopesRestrictionTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *OAuthScopesRestrictionType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = OAuthScopesRestrictionType(value) + return nil +} + +// NewOAuthScopesRestrictionTypeFromValue returns a pointer to a valid OAuthScopesRestrictionType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewOAuthScopesRestrictionTypeFromValue(v string) (*OAuthScopesRestrictionType, error) { + ev := OAuthScopesRestrictionType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for OAuthScopesRestrictionType: valid values are %v", v, allowedOAuthScopesRestrictionTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v OAuthScopesRestrictionType) IsValid() bool { + for _, existing := range allowedOAuthScopesRestrictionTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to OAuthScopesRestrictionType value. +func (v OAuthScopesRestrictionType) Ptr() *OAuthScopesRestrictionType { + return &v +} diff --git a/api/datadogV2/model_upsert_o_auth_scopes_restriction_data.go b/api/datadogV2/model_upsert_o_auth_scopes_restriction_data.go new file mode 100644 index 00000000000..73a6b38d04a --- /dev/null +++ b/api/datadogV2/model_upsert_o_auth_scopes_restriction_data.go @@ -0,0 +1,151 @@ +// 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" +) + +// UpsertOAuthScopesRestrictionData Data object of an upsert OAuth2 scopes restriction request. +type UpsertOAuthScopesRestrictionData struct { + // Attributes of an upsert OAuth2 scopes restriction request. + Attributes *UpsertOAuthScopesRestrictionDataAttributes `json:"attributes,omitempty"` + // JSON:API resource type for an upsert OAuth2 client scopes restriction request. + Type UpsertOAuthScopesRestrictionType `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:"-"` +} + +// NewUpsertOAuthScopesRestrictionData instantiates a new UpsertOAuthScopesRestrictionData 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 NewUpsertOAuthScopesRestrictionData(typeVar UpsertOAuthScopesRestrictionType) *UpsertOAuthScopesRestrictionData { + this := UpsertOAuthScopesRestrictionData{} + this.Type = typeVar + return &this +} + +// NewUpsertOAuthScopesRestrictionDataWithDefaults instantiates a new UpsertOAuthScopesRestrictionData 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 NewUpsertOAuthScopesRestrictionDataWithDefaults() *UpsertOAuthScopesRestrictionData { + this := UpsertOAuthScopesRestrictionData{} + var typeVar UpsertOAuthScopesRestrictionType = UPSERTOAUTHSCOPESRESTRICTIONTYPE_UPSERT_SCOPES_RESTRICTION + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *UpsertOAuthScopesRestrictionData) GetAttributes() UpsertOAuthScopesRestrictionDataAttributes { + if o == nil || o.Attributes == nil { + var ret UpsertOAuthScopesRestrictionDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertOAuthScopesRestrictionData) GetAttributesOk() (*UpsertOAuthScopesRestrictionDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *UpsertOAuthScopesRestrictionData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given UpsertOAuthScopesRestrictionDataAttributes and assigns it to the Attributes field. +func (o *UpsertOAuthScopesRestrictionData) SetAttributes(v UpsertOAuthScopesRestrictionDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *UpsertOAuthScopesRestrictionData) GetType() UpsertOAuthScopesRestrictionType { + if o == nil { + var ret UpsertOAuthScopesRestrictionType + 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 *UpsertOAuthScopesRestrictionData) GetTypeOk() (*UpsertOAuthScopesRestrictionType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *UpsertOAuthScopesRestrictionData) SetType(v UpsertOAuthScopesRestrictionType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpsertOAuthScopesRestrictionData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *UpsertOAuthScopesRestrictionData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *UpsertOAuthScopesRestrictionDataAttributes `json:"attributes,omitempty"` + Type *UpsertOAuthScopesRestrictionType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + 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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + 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_upsert_o_auth_scopes_restriction_data_attributes.go b/api/datadogV2/model_upsert_o_auth_scopes_restriction_data_attributes.go new file mode 100644 index 00000000000..61577f7036d --- /dev/null +++ b/api/datadogV2/model_upsert_o_auth_scopes_restriction_data_attributes.go @@ -0,0 +1,138 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// UpsertOAuthScopesRestrictionDataAttributes Attributes of an upsert OAuth2 scopes restriction request. +type UpsertOAuthScopesRestrictionDataAttributes struct { + // OIDC scopes the client is allowed to request. + OidcScopes []OAuthOidcScope `json:"oidc_scopes,omitempty"` + // Datadog permission scopes the client is allowed to request. + // Each value must be a valid permission name. + PermissionScopes []string `json:"permission_scopes,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:"-"` +} + +// NewUpsertOAuthScopesRestrictionDataAttributes instantiates a new UpsertOAuthScopesRestrictionDataAttributes 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 NewUpsertOAuthScopesRestrictionDataAttributes() *UpsertOAuthScopesRestrictionDataAttributes { + this := UpsertOAuthScopesRestrictionDataAttributes{} + return &this +} + +// NewUpsertOAuthScopesRestrictionDataAttributesWithDefaults instantiates a new UpsertOAuthScopesRestrictionDataAttributes 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 NewUpsertOAuthScopesRestrictionDataAttributesWithDefaults() *UpsertOAuthScopesRestrictionDataAttributes { + this := UpsertOAuthScopesRestrictionDataAttributes{} + return &this +} + +// GetOidcScopes returns the OidcScopes field value if set, zero value otherwise. +func (o *UpsertOAuthScopesRestrictionDataAttributes) GetOidcScopes() []OAuthOidcScope { + if o == nil || o.OidcScopes == nil { + var ret []OAuthOidcScope + return ret + } + return o.OidcScopes +} + +// GetOidcScopesOk returns a tuple with the OidcScopes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertOAuthScopesRestrictionDataAttributes) GetOidcScopesOk() (*[]OAuthOidcScope, bool) { + if o == nil || o.OidcScopes == nil { + return nil, false + } + return &o.OidcScopes, true +} + +// HasOidcScopes returns a boolean if a field has been set. +func (o *UpsertOAuthScopesRestrictionDataAttributes) HasOidcScopes() bool { + return o != nil && o.OidcScopes != nil +} + +// SetOidcScopes gets a reference to the given []OAuthOidcScope and assigns it to the OidcScopes field. +func (o *UpsertOAuthScopesRestrictionDataAttributes) SetOidcScopes(v []OAuthOidcScope) { + o.OidcScopes = v +} + +// GetPermissionScopes returns the PermissionScopes field value if set, zero value otherwise. +func (o *UpsertOAuthScopesRestrictionDataAttributes) GetPermissionScopes() []string { + if o == nil || o.PermissionScopes == nil { + var ret []string + return ret + } + return o.PermissionScopes +} + +// GetPermissionScopesOk returns a tuple with the PermissionScopes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *UpsertOAuthScopesRestrictionDataAttributes) GetPermissionScopesOk() (*[]string, bool) { + if o == nil || o.PermissionScopes == nil { + return nil, false + } + return &o.PermissionScopes, true +} + +// HasPermissionScopes returns a boolean if a field has been set. +func (o *UpsertOAuthScopesRestrictionDataAttributes) HasPermissionScopes() bool { + return o != nil && o.PermissionScopes != nil +} + +// SetPermissionScopes gets a reference to the given []string and assigns it to the PermissionScopes field. +func (o *UpsertOAuthScopesRestrictionDataAttributes) SetPermissionScopes(v []string) { + o.PermissionScopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpsertOAuthScopesRestrictionDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.OidcScopes != nil { + toSerialize["oidc_scopes"] = o.OidcScopes + } + if o.PermissionScopes != nil { + toSerialize["permission_scopes"] = o.PermissionScopes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *UpsertOAuthScopesRestrictionDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + OidcScopes []OAuthOidcScope `json:"oidc_scopes,omitempty"` + PermissionScopes []string `json:"permission_scopes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"oidc_scopes", "permission_scopes"}) + } else { + return err + } + o.OidcScopes = all.OidcScopes + o.PermissionScopes = all.PermissionScopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_upsert_o_auth_scopes_restriction_request.go b/api/datadogV2/model_upsert_o_auth_scopes_restriction_request.go new file mode 100644 index 00000000000..dddb9097aa6 --- /dev/null +++ b/api/datadogV2/model_upsert_o_auth_scopes_restriction_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" +) + +// UpsertOAuthScopesRestrictionRequest Request payload for creating or updating the scopes restriction of an OAuth2 client. +type UpsertOAuthScopesRestrictionRequest struct { + // Data object of an upsert OAuth2 scopes restriction request. + Data UpsertOAuthScopesRestrictionData `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:"-"` +} + +// NewUpsertOAuthScopesRestrictionRequest instantiates a new UpsertOAuthScopesRestrictionRequest 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 NewUpsertOAuthScopesRestrictionRequest(data UpsertOAuthScopesRestrictionData) *UpsertOAuthScopesRestrictionRequest { + this := UpsertOAuthScopesRestrictionRequest{} + this.Data = data + return &this +} + +// NewUpsertOAuthScopesRestrictionRequestWithDefaults instantiates a new UpsertOAuthScopesRestrictionRequest 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 NewUpsertOAuthScopesRestrictionRequestWithDefaults() *UpsertOAuthScopesRestrictionRequest { + this := UpsertOAuthScopesRestrictionRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *UpsertOAuthScopesRestrictionRequest) GetData() UpsertOAuthScopesRestrictionData { + if o == nil { + var ret UpsertOAuthScopesRestrictionData + 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 *UpsertOAuthScopesRestrictionRequest) GetDataOk() (*UpsertOAuthScopesRestrictionData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *UpsertOAuthScopesRestrictionRequest) SetData(v UpsertOAuthScopesRestrictionData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o UpsertOAuthScopesRestrictionRequest) 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 *UpsertOAuthScopesRestrictionRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *UpsertOAuthScopesRestrictionData `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_upsert_o_auth_scopes_restriction_type.go b/api/datadogV2/model_upsert_o_auth_scopes_restriction_type.go new file mode 100644 index 00000000000..85fdeb82622 --- /dev/null +++ b/api/datadogV2/model_upsert_o_auth_scopes_restriction_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" +) + +// UpsertOAuthScopesRestrictionType JSON:API resource type for an upsert OAuth2 client scopes restriction request. +type UpsertOAuthScopesRestrictionType string + +// List of UpsertOAuthScopesRestrictionType. +const ( + UPSERTOAUTHSCOPESRESTRICTIONTYPE_UPSERT_SCOPES_RESTRICTION UpsertOAuthScopesRestrictionType = "upsert_scopes_restriction" +) + +var allowedUpsertOAuthScopesRestrictionTypeEnumValues = []UpsertOAuthScopesRestrictionType{ + UPSERTOAUTHSCOPESRESTRICTIONTYPE_UPSERT_SCOPES_RESTRICTION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *UpsertOAuthScopesRestrictionType) GetAllowedValues() []UpsertOAuthScopesRestrictionType { + return allowedUpsertOAuthScopesRestrictionTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *UpsertOAuthScopesRestrictionType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = UpsertOAuthScopesRestrictionType(value) + return nil +} + +// NewUpsertOAuthScopesRestrictionTypeFromValue returns a pointer to a valid UpsertOAuthScopesRestrictionType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewUpsertOAuthScopesRestrictionTypeFromValue(v string) (*UpsertOAuthScopesRestrictionType, error) { + ev := UpsertOAuthScopesRestrictionType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for UpsertOAuthScopesRestrictionType: valid values are %v", v, allowedUpsertOAuthScopesRestrictionTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v UpsertOAuthScopesRestrictionType) IsValid() bool { + for _, existing := range allowedUpsertOAuthScopesRestrictionTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to UpsertOAuthScopesRestrictionType value. +func (v UpsertOAuthScopesRestrictionType) Ptr() *UpsertOAuthScopesRestrictionType { + return &v +} diff --git a/examples/v2/cloud-cost-management/DeleteCostTagDescriptionByKey.go b/examples/v2/cloud-cost-management/DeleteCostTagDescriptionByKey.go new file mode 100644 index 00000000000..fba5616d3f5 --- /dev/null +++ b/examples/v2/cloud-cost-management/DeleteCostTagDescriptionByKey.go @@ -0,0 +1,25 @@ +// Delete a Cloud Cost Management tag description 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCloudCostManagementApi(apiClient) + r, err := api.DeleteCostTagDescriptionByKey(ctx, "tag_key", *datadogV2.NewDeleteCostTagDescriptionByKeyOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.DeleteCostTagDescriptionByKey`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/cloud-cost-management/GenerateCostTagDescriptionByKey.go b/examples/v2/cloud-cost-management/GenerateCostTagDescriptionByKey.go new file mode 100644 index 00000000000..c0233af9935 --- /dev/null +++ b/examples/v2/cloud-cost-management/GenerateCostTagDescriptionByKey.go @@ -0,0 +1,29 @@ +// Generate a Cloud Cost Management tag description returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCloudCostManagementApi(apiClient) + resp, r, err := api.GenerateCostTagDescriptionByKey(ctx, "tag_key") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.GenerateCostTagDescriptionByKey`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CloudCostManagementApi.GenerateCostTagDescriptionByKey`:\n%s\n", responseContent) +} diff --git a/examples/v2/cloud-cost-management/GetCostTagDescriptionByKey.go b/examples/v2/cloud-cost-management/GetCostTagDescriptionByKey.go new file mode 100644 index 00000000000..8468b6a46b2 --- /dev/null +++ b/examples/v2/cloud-cost-management/GetCostTagDescriptionByKey.go @@ -0,0 +1,29 @@ +// Get a Cloud Cost Management tag description returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCloudCostManagementApi(apiClient) + resp, r, err := api.GetCostTagDescriptionByKey(ctx, "tag_key", *datadogV2.NewGetCostTagDescriptionByKeyOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.GetCostTagDescriptionByKey`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `CloudCostManagementApi.GetCostTagDescriptionByKey`:\n%s\n", responseContent) +} diff --git a/examples/v2/cloud-cost-management/UpsertCostTagDescriptionByKey.go b/examples/v2/cloud-cost-management/UpsertCostTagDescriptionByKey.go new file mode 100644 index 00000000000..6fd354489ec --- /dev/null +++ b/examples/v2/cloud-cost-management/UpsertCostTagDescriptionByKey.go @@ -0,0 +1,35 @@ +// Upsert a Cloud Cost Management tag description 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() { + body := datadogV2.CostTagDescriptionUpsertRequest{ + Data: datadogV2.CostTagDescriptionUpsertRequestData{ + Attributes: datadogV2.CostTagDescriptionUpsertRequestDataAttributes{ + Cloud: datadog.PtrString("aws"), + Description: "AWS account that owns this cost.", + }, + Id: datadog.PtrString("account_id"), + Type: datadogV2.COSTTAGDESCRIPTIONTYPE_COST_TAG_DESCRIPTION, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewCloudCostManagementApi(apiClient) + r, err := api.UpsertCostTagDescriptionByKey(ctx, "tag_key", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `CloudCostManagementApi.UpsertCostTagDescriptionByKey`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/oauth2-client-public/DeleteScopesRestriction.go b/examples/v2/oauth2-client-public/DeleteScopesRestriction.go new file mode 100644 index 00000000000..3b357e66f15 --- /dev/null +++ b/examples/v2/oauth2-client-public/DeleteScopesRestriction.go @@ -0,0 +1,27 @@ +// Delete an OAuth2 client scopes restriction 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" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteScopesRestriction", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOAuth2ClientPublicApi(apiClient) + r, err := api.DeleteScopesRestriction(ctx, uuid.MustParse("fafa8e1c-36a5-11f0-a83d-da7ad0900001")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OAuth2ClientPublicApi.DeleteScopesRestriction`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/oauth2-client-public/GetScopesRestriction.go b/examples/v2/oauth2-client-public/GetScopesRestriction.go new file mode 100644 index 00000000000..b02e047af8a --- /dev/null +++ b/examples/v2/oauth2-client-public/GetScopesRestriction.go @@ -0,0 +1,31 @@ +// Get an OAuth2 client scopes restriction 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" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetScopesRestriction", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOAuth2ClientPublicApi(apiClient) + resp, r, err := api.GetScopesRestriction(ctx, uuid.MustParse("fafa8e1c-36a5-11f0-a83d-da7ad0900001")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OAuth2ClientPublicApi.GetScopesRestriction`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OAuth2ClientPublicApi.GetScopesRestriction`:\n%s\n", responseContent) +} diff --git a/examples/v2/oauth2-client-public/RegisterOAuthClient.go b/examples/v2/oauth2-client-public/RegisterOAuthClient.go new file mode 100644 index 00000000000..cf22c8c590e --- /dev/null +++ b/examples/v2/oauth2-client-public/RegisterOAuthClient.go @@ -0,0 +1,50 @@ +// Register an OAuth2 client returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.OAuthClientRegistrationRequest{ + ClientName: "Example MCP Client", + ClientUri: datadog.PtrString("https://example.com"), + GrantTypes: []datadogV2.OAuthClientRegistrationGrantType{ + datadogV2.OAUTHCLIENTREGISTRATIONGRANTTYPE_AUTHORIZATION_CODE, + datadogV2.OAUTHCLIENTREGISTRATIONGRANTTYPE_REFRESH_TOKEN, + }, + JwksUri: datadog.PtrString("https://example.com/.well-known/jwks.json"), + LogoUri: datadog.PtrString("https://example.com/logo.png"), + PolicyUri: datadog.PtrString("https://example.com/privacy"), + RedirectUris: []string{ + "https://example.com/oauth/callback", + }, + ResponseTypes: []datadogV2.OAuthClientRegistrationResponseType{ + datadogV2.OAUTHCLIENTREGISTRATIONRESPONSETYPE_CODE, + }, + Scope: datadog.PtrString("openid profile"), + TokenEndpointAuthMethod: datadog.PtrString("none"), + TosUri: datadog.PtrString("https://example.com/tos"), + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RegisterOAuthClient", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOAuth2ClientPublicApi(apiClient) + resp, r, err := api.RegisterOAuthClient(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OAuth2ClientPublicApi.RegisterOAuthClient`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OAuth2ClientPublicApi.RegisterOAuthClient`:\n%s\n", responseContent) +} diff --git a/examples/v2/oauth2-client-public/UpsertScopesRestriction.go b/examples/v2/oauth2-client-public/UpsertScopesRestriction.go new file mode 100644 index 00000000000..e22c80b0570 --- /dev/null +++ b/examples/v2/oauth2-client-public/UpsertScopesRestriction.go @@ -0,0 +1,46 @@ +// Upsert an OAuth2 client scopes restriction 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" + "github.com/google/uuid" +) + +func main() { + body := datadogV2.UpsertOAuthScopesRestrictionRequest{ + Data: datadogV2.UpsertOAuthScopesRestrictionData{ + Attributes: &datadogV2.UpsertOAuthScopesRestrictionDataAttributes{ + OidcScopes: []datadogV2.OAuthOidcScope{ + datadogV2.OAUTHOIDCSCOPE_OPENID, + datadogV2.OAUTHOIDCSCOPE_EMAIL, + }, + PermissionScopes: []string{ + "dashboards_read", + "metrics_read", + }, + }, + Type: datadogV2.UPSERTOAUTHSCOPESRESTRICTIONTYPE_UPSERT_SCOPES_RESTRICTION, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpsertScopesRestriction", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewOAuth2ClientPublicApi(apiClient) + resp, r, err := api.UpsertScopesRestriction(ctx, uuid.MustParse("fafa8e1c-36a5-11f0-a83d-da7ad0900001"), body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `OAuth2ClientPublicApi.UpsertScopesRestriction`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `OAuth2ClientPublicApi.UpsertScopesRestriction`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 192e39283e9..36190817b9d 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -118,6 +118,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "MonitorsApi": reflect.ValueOf(datadogV2.NewMonitorsApi), "NetworkDeviceMonitoringApi": reflect.ValueOf(datadogV2.NewNetworkDeviceMonitoringApi), "CloudNetworkMonitoringApi": reflect.ValueOf(datadogV2.NewCloudNetworkMonitoringApi), + "OAuth2ClientPublicApi": reflect.ValueOf(datadogV2.NewOAuth2ClientPublicApi), "ObservabilityPipelinesApi": reflect.ValueOf(datadogV2.NewObservabilityPipelinesApi), "OnCallApi": reflect.ValueOf(datadogV2.NewOnCallApi), "OnCallPagingApi": reflect.ValueOf(datadogV2.NewOnCallPagingApi), diff --git a/tests/scenarios/features/v2/cloud_cost_management.feature b/tests/scenarios/features/v2/cloud_cost_management.feature index b41928f4cb9..535fe88d7c7 100644 --- a/tests/scenarios/features/v2/cloud_cost_management.feature +++ b/tests/scenarios/features/v2/cloud_cost_management.feature @@ -190,6 +190,20 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Delete a Cloud Cost Management tag description returns "Bad Request" response + Given new "DeleteCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Delete a Cloud Cost Management tag description returns "No Content" response + Given new "DeleteCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + @team:DataDog/cloud-cost-management Scenario: Delete a budget returns "Bad Request" response Given new "DeleteBudget" request @@ -218,6 +232,20 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Generate a Cloud Cost Management tag description returns "Bad Request" response + Given new "GenerateCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Generate a Cloud Cost Management tag description returns "OK" response + Given new "GenerateCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @replay-only @team:DataDog/cloud-cost-management Scenario: Get Custom Costs File returns "OK" response Given new "GetCustomCostsFile" request @@ -250,6 +278,27 @@ Feature: Cloud Cost Management And the response "data.type" is equal to "gcp_uc_config" And the response "data.attributes.account_id" is equal to "123456_ABCDEF_123ABC" + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag description returns "Bad Request" response + Given new "GetCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag description returns "Not Found" response + Given new "GetCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Get a Cloud Cost Management tag description returns "OK" response + Given new "GetCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/cloud-cost-management Scenario: Get a Cloud Cost Management tag key returns "Bad Request" response Given new "GetCostTagKey" request @@ -873,6 +922,22 @@ Feature: Cloud Cost Management When the request is sent Then the response status is 400 Bad Request + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Upsert a Cloud Cost Management tag description returns "Bad Request" response + Given new "UpsertCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"cloud": "aws", "description": "AWS account that owns this cost."}, "id": "account_id", "type": "cost_tag_description"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/cloud-cost-management + Scenario: Upsert a Cloud Cost Management tag description returns "No Content" response + Given new "UpsertCostTagDescriptionByKey" request + And request contains "tag_key" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"cloud": "aws", "description": "AWS account that owns this cost."}, "id": "account_id", "type": "cost_tag_description"}} + When the request is sent + Then the response status is 204 No Content + @generated @skip @team:DataDog/cloud-cost-management Scenario: Validate CSV budget returns "OK" response Given new "ValidateCsvBudget" request diff --git a/tests/scenarios/features/v2/oauth2_client_public.feature b/tests/scenarios/features/v2/oauth2_client_public.feature new file mode 100644 index 00000000000..a5c7d195efa --- /dev/null +++ b/tests/scenarios/features/v2/oauth2_client_public.feature @@ -0,0 +1,100 @@ +@endpoint(oauth2-client-public) @endpoint(oauth2-client-public-v2) +Feature: OAuth2 Client Public + Configure OAuth2 clients for Datadog. Supports RFC 7591 Dynamic Client + Registration and management of OAuth2 client scopes restrictions. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "OAuth2ClientPublic" API + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an OAuth2 client scopes restriction returns "Bad Request" response + Given operation "DeleteScopesRestriction" enabled + And new "DeleteScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an OAuth2 client scopes restriction returns "No Content" response + Given operation "DeleteScopesRestriction" enabled + And new "DeleteScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an OAuth2 client scopes restriction returns "Not Found" response + Given operation "DeleteScopesRestriction" enabled + And new "DeleteScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an OAuth2 client scopes restriction returns "Bad Request" response + Given operation "GetScopesRestriction" enabled + And new "GetScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an OAuth2 client scopes restriction returns "Not Found" response + Given operation "GetScopesRestriction" enabled + And new "GetScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an OAuth2 client scopes restriction returns "OK" response + Given operation "GetScopesRestriction" enabled + And new "GetScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Register an OAuth2 client returns "Bad Request" response + Given operation "RegisterOAuthClient" enabled + And new "RegisterOAuthClient" request + And body with value {"client_name": "Example MCP Client", "client_uri": "https://example.com", "grant_types": ["authorization_code", "refresh_token"], "jwks_uri": "https://example.com/.well-known/jwks.json", "logo_uri": "https://example.com/logo.png", "policy_uri": "https://example.com/privacy", "redirect_uris": ["https://example.com/oauth/callback"], "response_types": ["code"], "scope": "openid profile", "token_endpoint_auth_method": "none", "tos_uri": "https://example.com/tos"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Register an OAuth2 client returns "Created" response + Given operation "RegisterOAuthClient" enabled + And new "RegisterOAuthClient" request + And body with value {"client_name": "Example MCP Client", "client_uri": "https://example.com", "grant_types": ["authorization_code", "refresh_token"], "jwks_uri": "https://example.com/.well-known/jwks.json", "logo_uri": "https://example.com/logo.png", "policy_uri": "https://example.com/privacy", "redirect_uris": ["https://example.com/oauth/callback"], "response_types": ["code"], "scope": "openid profile", "token_endpoint_auth_method": "none", "tos_uri": "https://example.com/tos"} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Upsert an OAuth2 client scopes restriction returns "Bad Request" response + Given operation "UpsertScopesRestriction" enabled + And new "UpsertScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"oidc_scopes": ["openid", "email"], "permission_scopes": ["dashboards_read", "metrics_read"]}, "type": "upsert_scopes_restriction"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Upsert an OAuth2 client scopes restriction returns "Not Found" response + Given operation "UpsertScopesRestriction" enabled + And new "UpsertScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"oidc_scopes": ["openid", "email"], "permission_scopes": ["dashboards_read", "metrics_read"]}, "type": "upsert_scopes_restriction"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Upsert an OAuth2 client scopes restriction returns "OK" response + Given operation "UpsertScopesRestriction" enabled + And new "UpsertScopesRestriction" request + And request contains "client_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"oidc_scopes": ["openid", "email"], "permission_scopes": ["dashboards_read", "metrics_read"]}, "type": "upsert_scopes_restriction"}} + 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 0878797ffd8..30001c2fccd 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1874,6 +1874,30 @@ "type": "safe" } }, + "DeleteCostTagDescriptionByKey": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, + "GetCostTagDescriptionByKey": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, + "UpsertCostTagDescriptionByKey": { + "tag": "Cloud Cost Management", + "undo": { + "type": "idempotent" + } + }, + "GenerateCostTagDescriptionByKey": { + "tag": "Cloud Cost Management", + "undo": { + "type": "safe" + } + }, "ListCostTagKeys": { "tag": "Cloud Cost Management", "undo": { @@ -4678,6 +4702,30 @@ "type": "safe" } }, + "DeleteScopesRestriction": { + "tag": "OAuth2 Client Public", + "undo": { + "type": "idempotent" + } + }, + "GetScopesRestriction": { + "tag": "OAuth2 Client Public", + "undo": { + "type": "safe" + } + }, + "UpsertScopesRestriction": { + "tag": "OAuth2 Client Public", + "undo": { + "type": "idempotent" + } + }, + "RegisterOAuthClient": { + "tag": "OAuth2 Client Public", + "undo": { + "type": "idempotent" + } + }, "ListPipelines": { "tag": "Observability Pipelines", "undo": {