diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index be7bf771e30..1d02f30912a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1117,6 +1117,41 @@ components: required: true schema: type: string + PersonalAccessTokenID: + description: The UUID of the personal access token. + in: path + name: pat_uuid + required: true + schema: + example: "00000000-0000-1234-0000-000000000000" + type: string + PersonalAccessTokensFilterOwnerUUIDParameter: + description: Filter personal access tokens by the owner's UUID. Supports multiple values. + in: query + name: filter[owner_uuid] + required: false + schema: + items: + example: "00000000-0000-1234-0000-000000000000" + type: string + type: array + PersonalAccessTokensFilterParameter: + description: Filter personal access tokens by the specified string. + in: query + name: filter + required: false + schema: + type: string + PersonalAccessTokensSortParameter: + description: |- + Personal access token attribute used to sort results. Sort order is ascending + by default. In order to specify a descending sort, prefix the + attribute with a minus sign. + in: query + name: sort + required: false + schema: + $ref: "#/components/schemas/PersonalAccessTokensSort" PolicySort: description: >- Field to sort policies by. Supported values: `id`, `name`, `-id`, `-name`. Defaults to `id`. @@ -28230,6 +28265,63 @@ components: - name - requirements type: object + FullPersonalAccessToken: + description: Datadog personal access token, including the token key. + properties: + attributes: + $ref: "#/components/schemas/FullPersonalAccessTokenAttributes" + id: + description: ID of the personal access token. + type: string + relationships: + $ref: "#/components/schemas/PersonalAccessTokenRelationships" + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + type: object + FullPersonalAccessTokenAttributes: + description: Attributes of a full personal access token, including the token key. + properties: + alias: + description: The alias (short identifier) of the personal access token. + example: "2H9MCNMBM8FQjQ16YucXkX" + readOnly: true + type: string + created_at: + description: Creation date of the personal access token. + example: "2024-01-01T00:00:00+00:00" + format: date-time + readOnly: true + type: string + expires_at: + description: Expiration date of the personal access token. + example: "2025-12-31T23:59:59+00:00" + format: date-time + nullable: true + readOnly: true + type: string + key: + description: The personal access token key. Only returned upon creation. + readOnly: true + type: string + name: + description: Name of the personal access token. + example: "My Personal Access Token" + type: string + public_portion: + description: The public portion of the personal access token. + example: "ddpat_abc123" + readOnly: true + type: string + scopes: + description: Array of scopes granted to the personal access token. + example: + - "dashboards_read" + - "dashboards_write" + items: + description: Name of scope. + type: string + type: array + type: object GCPCredentials: description: The definition of the `GCPCredentials` object. oneOf: @@ -38815,6 +38907,17 @@ components: $ref: "#/components/schemas/OnCallNotificationRulesIncluded" type: array type: object + ListPersonalAccessTokensResponse: + description: Response for a list of personal access tokens. + properties: + data: + description: Array of personal access tokens. + items: + $ref: "#/components/schemas/PersonalAccessToken" + type: array + meta: + $ref: "#/components/schemas/PersonalAccessTokenResponseMeta" + type: object ListPipelinesResponse: description: Represents the response payload containing a list of pipelines and associated metadata. properties: @@ -51525,6 +51628,218 @@ components: type: string x-enum-varnames: - PERMISSIONS + PersonalAccessToken: + description: Datadog personal access token. + properties: + attributes: + $ref: "#/components/schemas/PersonalAccessTokenAttributes" + id: + description: ID of the personal access token. + type: string + relationships: + $ref: "#/components/schemas/PersonalAccessTokenRelationships" + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + type: object + PersonalAccessTokenAttributes: + description: Attributes of a personal access token. + properties: + alias: + description: The alias (short identifier) of the personal access token. + example: "2H9MCNMBM8FQjQ16YucXkX" + readOnly: true + type: string + created_at: + description: Creation date of the personal access token. + example: "2024-01-01T00:00:00+00:00" + format: date-time + readOnly: true + type: string + expires_at: + description: Expiration date of the personal access token. + example: "2025-12-31T23:59:59+00:00" + format: date-time + nullable: true + readOnly: true + type: string + last_used_at: + description: Date the personal access token was last used. + example: "2025-06-15T12:30:00+00:00" + format: date-time + nullable: true + readOnly: true + type: string + modified_at: + description: Date of last modification of the personal access token. + example: "2024-06-01T00:00:00+00:00" + format: date-time + nullable: true + readOnly: true + type: string + name: + description: Name of the personal access token. + example: "My Personal Access Token" + type: string + public_portion: + description: The public portion of the personal access token. + example: "ddpat_abc123" + readOnly: true + type: string + scopes: + description: Array of scopes granted to the personal access token. + example: + - "dashboards_read" + - "dashboards_write" + items: + description: Name of scope. + type: string + type: array + type: object + PersonalAccessTokenCreateAttributes: + description: Attributes used to create a personal access token. + properties: + expires_at: + description: Expiration date of the personal access token. Must be at least 24 hours in the future. + example: "2025-12-31T23:59:59+00:00" + format: date-time + type: string + name: + description: Name of the personal access token. + example: "My Personal Access Token" + type: string + scopes: + description: Array of scopes to grant the personal access token. + example: + - "dashboards_read" + - "dashboards_write" + items: + description: Name of scope. + type: string + type: array + required: + - name + - scopes + - expires_at + type: object + PersonalAccessTokenCreateData: + description: Object used to create a personal access token. + properties: + attributes: + $ref: "#/components/schemas/PersonalAccessTokenCreateAttributes" + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + required: + - attributes + - type + type: object + PersonalAccessTokenCreateRequest: + description: Request used to create a personal access token. + properties: + data: + $ref: "#/components/schemas/PersonalAccessTokenCreateData" + required: + - data + type: object + PersonalAccessTokenCreateResponse: + description: Response for creating a personal access token. Includes the token key. + properties: + data: + $ref: "#/components/schemas/FullPersonalAccessToken" + type: object + PersonalAccessTokenRelationships: + description: Resources related to the personal access token. + properties: + owned_by: + $ref: "#/components/schemas/RelationshipToUser" + type: object + PersonalAccessTokenResponse: + description: Response for retrieving a personal access token. + properties: + data: + $ref: "#/components/schemas/PersonalAccessToken" + type: object + PersonalAccessTokenResponseMeta: + description: Additional information related to the personal access token response. + properties: + page: + $ref: "#/components/schemas/PersonalAccessTokenResponseMetaPage" + type: object + PersonalAccessTokenResponseMetaPage: + description: Pagination information. + properties: + total_filtered_count: + description: Total filtered personal access token count. + format: int64 + type: integer + type: object + PersonalAccessTokenUpdateAttributes: + description: Attributes used to update a personal access token. + properties: + name: + description: Name of the personal access token. + example: "Updated Personal Access Token" + type: string + scopes: + description: Array of scopes to grant the personal access token. + example: + - "dashboards_read" + - "dashboards_write" + items: + description: Name of scope. + type: string + type: array + type: object + PersonalAccessTokenUpdateData: + description: Object used to update a personal access token. + properties: + attributes: + $ref: "#/components/schemas/PersonalAccessTokenUpdateAttributes" + id: + description: ID of the personal access token. + example: "00112233-4455-6677-8899-aabbccddeeff" + type: string + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + required: + - attributes + - id + - type + type: object + PersonalAccessTokenUpdateRequest: + description: Request used to update a personal access token. + properties: + data: + $ref: "#/components/schemas/PersonalAccessTokenUpdateData" + required: + - data + type: object + PersonalAccessTokensSort: + default: name + description: Sorting options + enum: + - name + - -name + - created_at + - -created_at + - expires_at + - -expires_at + type: string + x-enum-varnames: + - NAME_ASCENDING + - NAME_DESCENDING + - CREATED_AT_ASCENDING + - CREATED_AT_DESCENDING + - EXPIRES_AT_ASCENDING + - EXPIRES_AT_DESCENDING + PersonalAccessTokensType: + default: personal_access_tokens + description: Personal access tokens resource type. + enum: + - personal_access_tokens + example: personal_access_tokens + type: string + x-enum-varnames: + - PERSONAL_ACCESS_TOKENS Playlist: description: A single RUM replay playlist resource returned by create, update, or get operations. properties: @@ -64248,6 +64563,50 @@ components: - REPLACEMENT_STRING - PARTIAL_REPLACEMENT_FROM_BEGINNING - PARTIAL_REPLACEMENT_FROM_END + ServiceAccountAccessTokenCreateAttributes: + description: Attributes used to create a service account access token. + properties: + expires_at: + description: Expiration date of the access token. Optional for service account tokens. + example: "2025-12-31T23:59:59+00:00" + format: date-time + type: string + name: + description: Name of the access token. + example: "Service Account Access Token" + type: string + scopes: + description: Array of scopes to grant the access token. + example: + - "dashboards_read" + - "dashboards_write" + items: + description: Name of scope. + type: string + type: array + required: + - name + - scopes + type: object + ServiceAccountAccessTokenCreateData: + description: Object used to create a service account access token. + properties: + attributes: + $ref: "#/components/schemas/ServiceAccountAccessTokenCreateAttributes" + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + required: + - attributes + - type + type: object + ServiceAccountAccessTokenCreateRequest: + description: Request used to create a service account access token. + properties: + data: + $ref: "#/components/schemas/ServiceAccountAccessTokenCreateData" + required: + - data + type: object ServiceAccountCreateAttributes: description: Attributes of the created user. properties: @@ -103211,6 +103570,195 @@ paths: operator: OR permissions: - user_access_read + /api/v2/personal_access_tokens: + get: + description: List all personal access tokens for the organization. + operationId: ListPersonalAccessTokens + parameters: + - $ref: "#/components/parameters/PageSize" + - $ref: "#/components/parameters/PageNumber" + - $ref: "#/components/parameters/PersonalAccessTokensSortParameter" + - $ref: "#/components/parameters/PersonalAccessTokensFilterParameter" + - $ref: "#/components/parameters/PersonalAccessTokensFilterOwnerUUIDParameter" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ListPersonalAccessTokensResponse" + 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" + summary: Get all personal access tokens + tags: + - Key Management + "x-permission": + operator: OR + permissions: + - user_app_keys + - org_app_keys_read + post: + description: Create a personal access token for the current user. + operationId: CreatePersonalAccessToken + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenCreateRequest" + required: true + responses: + "201": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenCreateResponse" + description: Created + "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" + summary: Create a personal access token + tags: + - Key Management + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - user_app_keys + /api/v2/personal_access_tokens/{pat_uuid}: + delete: + description: Revoke a specific personal access token. + operationId: RevokePersonalAccessToken + parameters: + - $ref: "#/components/parameters/PersonalAccessTokenID" + responses: + "204": + description: No Content + "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" + summary: Revoke a personal access token + tags: + - Key Management + "x-permission": + operator: OR + permissions: + - user_app_keys + - org_app_keys_write + get: + description: Get a specific personal access token by its UUID. + operationId: GetPersonalAccessToken + parameters: + - $ref: "#/components/parameters/PersonalAccessTokenID" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenResponse" + description: OK + "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" + summary: Get a personal access token + tags: + - Key Management + "x-permission": + operator: OR + permissions: + - user_app_keys + - org_app_keys_read + patch: + description: Update a specific personal access token. + operationId: UpdatePersonalAccessToken + parameters: + - $ref: "#/components/parameters/PersonalAccessTokenID" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenUpdateRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenResponse" + 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" + summary: Update a personal access token + tags: + - Key Management + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - user_app_keys + - org_app_keys_write /api/v2/posture_management/findings: get: description: |- @@ -112460,6 +113008,208 @@ paths: operator: OR permissions: - service_account_write + /api/v2/service_accounts/{service_account_id}/access_tokens: + get: + description: List all access tokens for a specific service account. + operationId: ListServiceAccountAccessTokens + parameters: + - $ref: "#/components/parameters/ServiceAccountID" + - $ref: "#/components/parameters/PageSize" + - $ref: "#/components/parameters/PageNumber" + - $ref: "#/components/parameters/PersonalAccessTokensSortParameter" + - $ref: "#/components/parameters/PersonalAccessTokensFilterParameter" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/ListPersonalAccessTokensResponse" + 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" + summary: List access tokens for a service account + tags: + - Service Accounts + "x-permission": + operator: OR + permissions: + - service_account_write + post: + description: Create an access token for a service account. + operationId: CreateServiceAccountAccessToken + parameters: + - $ref: "#/components/parameters/ServiceAccountID" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ServiceAccountAccessTokenCreateRequest" + required: true + responses: + "201": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenCreateResponse" + description: Created + "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" + summary: Create an access token for a service account + tags: + - Service Accounts + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - service_account_write + /api/v2/service_accounts/{service_account_id}/access_tokens/{pat_uuid}: + delete: + description: Revoke a specific access token for a service account. + operationId: RevokeServiceAccountAccessToken + parameters: + - $ref: "#/components/parameters/ServiceAccountID" + - $ref: "#/components/parameters/PersonalAccessTokenID" + responses: + "204": + description: No Content + "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" + summary: Revoke an access token for a service account + tags: + - Service Accounts + "x-permission": + operator: OR + permissions: + - service_account_write + get: + description: Get a specific access token for a service account by its UUID. + operationId: GetServiceAccountAccessToken + parameters: + - $ref: "#/components/parameters/ServiceAccountID" + - $ref: "#/components/parameters/PersonalAccessTokenID" + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenResponse" + description: OK + "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" + summary: Get an access token for a service account + tags: + - Service Accounts + "x-permission": + operator: OR + permissions: + - service_account_write + patch: + description: Update a specific access token for a service account. + operationId: UpdateServiceAccountAccessToken + parameters: + - $ref: "#/components/parameters/ServiceAccountID" + - $ref: "#/components/parameters/PersonalAccessTokenID" + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenUpdateRequest" + required: true + responses: + "200": + content: + application/json: + schema: + $ref: "#/components/schemas/PersonalAccessTokenResponse" + 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" + summary: Update an access token for a service account + tags: + - Service Accounts + x-codegen-request-body-name: body + "x-permission": + operator: OR + permissions: + - service_account_write /api/v2/service_accounts/{service_account_id}/application_keys: get: description: List all application keys available for this service account. diff --git a/api/datadogV2/api_key_management.go b/api/datadogV2/api_key_management.go index 37424d5278b..af65ee57388 100644 --- a/api/datadogV2/api_key_management.go +++ b/api/datadogV2/api_key_management.go @@ -8,6 +8,7 @@ import ( _context "context" _nethttp "net/http" _neturl "net/url" + "reflect" "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) @@ -175,6 +176,86 @@ func (a *KeyManagementApi) CreateCurrentUserApplicationKey(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// CreatePersonalAccessToken Create a personal access token. +// Create a personal access token for the current user. +func (a *KeyManagementApi) CreatePersonalAccessToken(ctx _context.Context, body PersonalAccessTokenCreateRequest) (PersonalAccessTokenCreateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenCreateResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.CreatePersonalAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/personal_access_tokens" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 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 +} + // DeleteAPIKey Delete an API key. // Delete an API key. func (a *KeyManagementApi) DeleteAPIKey(ctx _context.Context, apiKeyId string) (*_nethttp.Response, error) { @@ -670,6 +751,84 @@ func (a *KeyManagementApi) GetCurrentUserApplicationKey(ctx _context.Context, ap return localVarReturnValue, localVarHTTPResponse, nil } +// GetPersonalAccessToken Get a personal access token. +// Get a specific personal access token by its UUID. +func (a *KeyManagementApi) GetPersonalAccessToken(ctx _context.Context, patUuid string) (PersonalAccessTokenResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.GetPersonalAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/personal_access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + 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 == 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 +} + // ListAPIKeysOptionalParameters holds optional parameters for ListAPIKeys. type ListAPIKeysOptionalParameters struct { PageSize *int64 @@ -1205,6 +1364,227 @@ func (a *KeyManagementApi) ListCurrentUserApplicationKeys(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// ListPersonalAccessTokensOptionalParameters holds optional parameters for ListPersonalAccessTokens. +type ListPersonalAccessTokensOptionalParameters struct { + PageSize *int64 + PageNumber *int64 + Sort *PersonalAccessTokensSort + Filter *string + FilterOwnerUuid *[]string +} + +// NewListPersonalAccessTokensOptionalParameters creates an empty struct for parameters. +func NewListPersonalAccessTokensOptionalParameters() *ListPersonalAccessTokensOptionalParameters { + this := ListPersonalAccessTokensOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListPersonalAccessTokensOptionalParameters) WithPageSize(pageSize int64) *ListPersonalAccessTokensOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListPersonalAccessTokensOptionalParameters) WithPageNumber(pageNumber int64) *ListPersonalAccessTokensOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *ListPersonalAccessTokensOptionalParameters) WithSort(sort PersonalAccessTokensSort) *ListPersonalAccessTokensOptionalParameters { + r.Sort = &sort + return r +} + +// WithFilter sets the corresponding parameter name and returns the struct. +func (r *ListPersonalAccessTokensOptionalParameters) WithFilter(filter string) *ListPersonalAccessTokensOptionalParameters { + r.Filter = &filter + return r +} + +// WithFilterOwnerUuid sets the corresponding parameter name and returns the struct. +func (r *ListPersonalAccessTokensOptionalParameters) WithFilterOwnerUuid(filterOwnerUuid []string) *ListPersonalAccessTokensOptionalParameters { + r.FilterOwnerUuid = &filterOwnerUuid + return r +} + +// ListPersonalAccessTokens Get all personal access tokens. +// List all personal access tokens for the organization. +func (a *KeyManagementApi) ListPersonalAccessTokens(ctx _context.Context, o ...ListPersonalAccessTokensOptionalParameters) (ListPersonalAccessTokensResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListPersonalAccessTokensResponse + optionalParams ListPersonalAccessTokensOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListPersonalAccessTokensOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.ListPersonalAccessTokens") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/personal_access_tokens" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.Filter != nil { + localVarQueryParams.Add("filter", datadog.ParameterToString(*optionalParams.Filter, "")) + } + if optionalParams.FilterOwnerUuid != nil { + t := *optionalParams.FilterOwnerUuid + if reflect.TypeOf(t).Kind() == reflect.Slice { + s := reflect.ValueOf(t) + for i := 0; i < s.Len(); i++ { + localVarQueryParams.Add("filter[owner_uuid]", datadog.ParameterToString(s.Index(i), "multi")) + } + } else { + localVarQueryParams.Add("filter[owner_uuid]", datadog.ParameterToString(t, "multi")) + } + } + 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 +} + +// RevokePersonalAccessToken Revoke a personal access token. +// Revoke a specific personal access token. +func (a *KeyManagementApi) RevokePersonalAccessToken(ctx _context.Context, patUuid string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.RevokePersonalAccessToken") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/personal_access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // UpdateAPIKey Edit an API key. // Update an API key. func (a *KeyManagementApi) UpdateAPIKey(ctx _context.Context, apiKeyId string, body APIKeyUpdateRequest) (APIKeyResponse, *_nethttp.Response, error) { @@ -1449,6 +1829,87 @@ func (a *KeyManagementApi) UpdateCurrentUserApplicationKey(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, nil } +// UpdatePersonalAccessToken Update a personal access token. +// Update a specific personal access token. +func (a *KeyManagementApi) UpdatePersonalAccessToken(ctx _context.Context, patUuid string, body PersonalAccessTokenUpdateRequest) (PersonalAccessTokenResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.KeyManagementApi.UpdatePersonalAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/personal_access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // NewKeyManagementApi Returns NewKeyManagementApi. func NewKeyManagementApi(client *datadog.APIClient) *KeyManagementApi { return &KeyManagementApi{ diff --git a/api/datadogV2/api_service_accounts.go b/api/datadogV2/api_service_accounts.go index bae13de4521..587e515d7e2 100644 --- a/api/datadogV2/api_service_accounts.go +++ b/api/datadogV2/api_service_accounts.go @@ -95,6 +95,87 @@ func (a *ServiceAccountsApi) CreateServiceAccount(ctx _context.Context, body Ser return localVarReturnValue, localVarHTTPResponse, nil } +// CreateServiceAccountAccessToken Create an access token for a service account. +// Create an access token for a service account. +func (a *ServiceAccountsApi) CreateServiceAccountAccessToken(ctx _context.Context, serviceAccountId string, body ServiceAccountAccessTokenCreateRequest) (PersonalAccessTokenCreateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenCreateResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceAccountsApi.CreateServiceAccountAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts/{service_account_id}/access_tokens" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service_account_id}", _neturl.PathEscape(datadog.ParameterToString(serviceAccountId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateServiceAccountApplicationKey Create an application key for this service account. // Create an application key for this service account. func (a *ServiceAccountsApi) CreateServiceAccountApplicationKey(ctx _context.Context, serviceAccountId string, body ApplicationKeyCreateRequest) (ApplicationKeyResponse, *_nethttp.Response, error) { @@ -245,6 +326,85 @@ func (a *ServiceAccountsApi) DeleteServiceAccountApplicationKey(ctx _context.Con return localVarHTTPResponse, nil } +// GetServiceAccountAccessToken Get an access token for a service account. +// Get a specific access token for a service account by its UUID. +func (a *ServiceAccountsApi) GetServiceAccountAccessToken(ctx _context.Context, serviceAccountId string, patUuid string) (PersonalAccessTokenResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceAccountsApi.GetServiceAccountAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts/{service_account_id}/access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service_account_id}", _neturl.PathEscape(datadog.ParameterToString(serviceAccountId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + 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 == 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 +} + // GetServiceAccountApplicationKey Get one application key for this service account. // Get an application key owned by this service account. func (a *ServiceAccountsApi) GetServiceAccountApplicationKey(ctx _context.Context, serviceAccountId string, appKeyId string) (PartialApplicationKeyResponse, *_nethttp.Response, error) { @@ -324,6 +484,142 @@ func (a *ServiceAccountsApi) GetServiceAccountApplicationKey(ctx _context.Contex return localVarReturnValue, localVarHTTPResponse, nil } +// ListServiceAccountAccessTokensOptionalParameters holds optional parameters for ListServiceAccountAccessTokens. +type ListServiceAccountAccessTokensOptionalParameters struct { + PageSize *int64 + PageNumber *int64 + Sort *PersonalAccessTokensSort + Filter *string +} + +// NewListServiceAccountAccessTokensOptionalParameters creates an empty struct for parameters. +func NewListServiceAccountAccessTokensOptionalParameters() *ListServiceAccountAccessTokensOptionalParameters { + this := ListServiceAccountAccessTokensOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListServiceAccountAccessTokensOptionalParameters) WithPageSize(pageSize int64) *ListServiceAccountAccessTokensOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListServiceAccountAccessTokensOptionalParameters) WithPageNumber(pageNumber int64) *ListServiceAccountAccessTokensOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *ListServiceAccountAccessTokensOptionalParameters) WithSort(sort PersonalAccessTokensSort) *ListServiceAccountAccessTokensOptionalParameters { + r.Sort = &sort + return r +} + +// WithFilter sets the corresponding parameter name and returns the struct. +func (r *ListServiceAccountAccessTokensOptionalParameters) WithFilter(filter string) *ListServiceAccountAccessTokensOptionalParameters { + r.Filter = &filter + return r +} + +// ListServiceAccountAccessTokens List access tokens for a service account. +// List all access tokens for a specific service account. +func (a *ServiceAccountsApi) ListServiceAccountAccessTokens(ctx _context.Context, serviceAccountId string, o ...ListServiceAccountAccessTokensOptionalParameters) (ListPersonalAccessTokensResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListPersonalAccessTokensResponse + optionalParams ListServiceAccountAccessTokensOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListServiceAccountAccessTokensOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceAccountsApi.ListServiceAccountAccessTokens") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts/{service_account_id}/access_tokens" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service_account_id}", _neturl.PathEscape(datadog.ParameterToString(serviceAccountId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageNumber != nil { + localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.Filter != nil { + localVarQueryParams.Add("filter", datadog.ParameterToString(*optionalParams.Filter, "")) + } + 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 +} + // ListServiceAccountApplicationKeysOptionalParameters holds optional parameters for ListServiceAccountApplicationKeys. type ListServiceAccountApplicationKeysOptionalParameters struct { PageSize *int64 @@ -480,6 +776,157 @@ func (a *ServiceAccountsApi) ListServiceAccountApplicationKeys(ctx _context.Cont return localVarReturnValue, localVarHTTPResponse, nil } +// RevokeServiceAccountAccessToken Revoke an access token for a service account. +// Revoke a specific access token for a service account. +func (a *ServiceAccountsApi) RevokeServiceAccountAccessToken(ctx _context.Context, serviceAccountId string, patUuid string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceAccountsApi.RevokeServiceAccountAccessToken") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts/{service_account_id}/access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service_account_id}", _neturl.PathEscape(datadog.ParameterToString(serviceAccountId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// UpdateServiceAccountAccessToken Update an access token for a service account. +// Update a specific access token for a service account. +func (a *ServiceAccountsApi) UpdateServiceAccountAccessToken(ctx _context.Context, serviceAccountId string, patUuid string, body PersonalAccessTokenUpdateRequest) (PersonalAccessTokenResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue PersonalAccessTokenResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ServiceAccountsApi.UpdateServiceAccountAccessToken") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/service_accounts/{service_account_id}/access_tokens/{pat_uuid}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{service_account_id}", _neturl.PathEscape(datadog.ParameterToString(serviceAccountId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{pat_uuid}", _neturl.PathEscape(datadog.ParameterToString(patUuid, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateServiceAccountApplicationKey Edit an application key for this service account. // Edit an application key owned by this service account. func (a *ServiceAccountsApi) UpdateServiceAccountApplicationKey(ctx _context.Context, serviceAccountId string, appKeyId string, body ApplicationKeyUpdateRequest) (PartialApplicationKeyResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 54d3a185b64..c0ce13e88c0 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -425,18 +425,23 @@ // - [JiraIntegrationApi.UpdateJiraIssueTemplate] // - [KeyManagementApi.CreateAPIKey] // - [KeyManagementApi.CreateCurrentUserApplicationKey] +// - [KeyManagementApi.CreatePersonalAccessToken] // - [KeyManagementApi.DeleteAPIKey] // - [KeyManagementApi.DeleteApplicationKey] // - [KeyManagementApi.DeleteCurrentUserApplicationKey] // - [KeyManagementApi.GetAPIKey] // - [KeyManagementApi.GetApplicationKey] // - [KeyManagementApi.GetCurrentUserApplicationKey] +// - [KeyManagementApi.GetPersonalAccessToken] // - [KeyManagementApi.ListAPIKeys] // - [KeyManagementApi.ListApplicationKeys] // - [KeyManagementApi.ListCurrentUserApplicationKeys] +// - [KeyManagementApi.ListPersonalAccessTokens] +// - [KeyManagementApi.RevokePersonalAccessToken] // - [KeyManagementApi.UpdateAPIKey] // - [KeyManagementApi.UpdateApplicationKey] // - [KeyManagementApi.UpdateCurrentUserApplicationKey] +// - [KeyManagementApi.UpdatePersonalAccessToken] // - [LLMObservabilityApi.CreateLLMObsAnnotationQueue] // - [LLMObservabilityApi.CreateLLMObsAnnotationQueueInteractions] // - [LLMObservabilityApi.CreateLLMObsDataset] @@ -817,10 +822,15 @@ // - [SensitiveDataScannerApi.UpdateScanningGroup] // - [SensitiveDataScannerApi.UpdateScanningRule] // - [ServiceAccountsApi.CreateServiceAccount] +// - [ServiceAccountsApi.CreateServiceAccountAccessToken] // - [ServiceAccountsApi.CreateServiceAccountApplicationKey] // - [ServiceAccountsApi.DeleteServiceAccountApplicationKey] +// - [ServiceAccountsApi.GetServiceAccountAccessToken] // - [ServiceAccountsApi.GetServiceAccountApplicationKey] +// - [ServiceAccountsApi.ListServiceAccountAccessTokens] // - [ServiceAccountsApi.ListServiceAccountApplicationKeys] +// - [ServiceAccountsApi.RevokeServiceAccountAccessToken] +// - [ServiceAccountsApi.UpdateServiceAccountAccessToken] // - [ServiceAccountsApi.UpdateServiceAccountApplicationKey] // - [ServiceDefinitionApi.CreateOrUpdateServiceDefinitions] // - [ServiceDefinitionApi.DeleteServiceDefinition] diff --git a/api/datadogV2/model_full_personal_access_token.go b/api/datadogV2/model_full_personal_access_token.go new file mode 100644 index 00000000000..197ce64da36 --- /dev/null +++ b/api/datadogV2/model_full_personal_access_token.go @@ -0,0 +1,227 @@ +// 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" +) + +// FullPersonalAccessToken Datadog personal access token, including the token key. +type FullPersonalAccessToken struct { + // Attributes of a full personal access token, including the token key. + Attributes *FullPersonalAccessTokenAttributes `json:"attributes,omitempty"` + // ID of the personal access token. + Id *string `json:"id,omitempty"` + // Resources related to the personal access token. + Relationships *PersonalAccessTokenRelationships `json:"relationships,omitempty"` + // Personal access tokens resource type. + Type *PersonalAccessTokensType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFullPersonalAccessToken instantiates a new FullPersonalAccessToken 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 NewFullPersonalAccessToken() *FullPersonalAccessToken { + this := FullPersonalAccessToken{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = &typeVar + return &this +} + +// NewFullPersonalAccessTokenWithDefaults instantiates a new FullPersonalAccessToken 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 NewFullPersonalAccessTokenWithDefaults() *FullPersonalAccessToken { + this := FullPersonalAccessToken{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *FullPersonalAccessToken) GetAttributes() FullPersonalAccessTokenAttributes { + if o == nil || o.Attributes == nil { + var ret FullPersonalAccessTokenAttributes + 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 *FullPersonalAccessToken) GetAttributesOk() (*FullPersonalAccessTokenAttributes, 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 *FullPersonalAccessToken) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given FullPersonalAccessTokenAttributes and assigns it to the Attributes field. +func (o *FullPersonalAccessToken) SetAttributes(v FullPersonalAccessTokenAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *FullPersonalAccessToken) 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 *FullPersonalAccessToken) 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 *FullPersonalAccessToken) 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 *FullPersonalAccessToken) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *FullPersonalAccessToken) GetRelationships() PersonalAccessTokenRelationships { + if o == nil || o.Relationships == nil { + var ret PersonalAccessTokenRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessToken) GetRelationshipsOk() (*PersonalAccessTokenRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *FullPersonalAccessToken) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given PersonalAccessTokenRelationships and assigns it to the Relationships field. +func (o *FullPersonalAccessToken) SetRelationships(v PersonalAccessTokenRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *FullPersonalAccessToken) GetType() PersonalAccessTokensType { + if o == nil || o.Type == nil { + var ret PersonalAccessTokensType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessToken) GetTypeOk() (*PersonalAccessTokensType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *FullPersonalAccessToken) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given PersonalAccessTokensType and assigns it to the Type field. +func (o *FullPersonalAccessToken) SetType(v PersonalAccessTokensType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FullPersonalAccessToken) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FullPersonalAccessToken) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *FullPersonalAccessTokenAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *PersonalAccessTokenRelationships `json:"relationships,omitempty"` + Type *PersonalAccessTokensType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships + if all.Type != nil && !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_full_personal_access_token_attributes.go b/api/datadogV2/model_full_personal_access_token_attributes.go new file mode 100644 index 00000000000..8a6279eed6b --- /dev/null +++ b/api/datadogV2/model_full_personal_access_token_attributes.go @@ -0,0 +1,329 @@ +// 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 ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FullPersonalAccessTokenAttributes Attributes of a full personal access token, including the token key. +type FullPersonalAccessTokenAttributes struct { + // The alias (short identifier) of the personal access token. + Alias *string `json:"alias,omitempty"` + // Creation date of the personal access token. + CreatedAt *time.Time `json:"created_at,omitempty"` + // Expiration date of the personal access token. + ExpiresAt datadog.NullableTime `json:"expires_at,omitempty"` + // The personal access token key. Only returned upon creation. + Key *string `json:"key,omitempty"` + // Name of the personal access token. + Name *string `json:"name,omitempty"` + // The public portion of the personal access token. + PublicPortion *string `json:"public_portion,omitempty"` + // Array of scopes granted to the personal access token. + Scopes []string `json:"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:"-"` +} + +// NewFullPersonalAccessTokenAttributes instantiates a new FullPersonalAccessTokenAttributes 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 NewFullPersonalAccessTokenAttributes() *FullPersonalAccessTokenAttributes { + this := FullPersonalAccessTokenAttributes{} + return &this +} + +// NewFullPersonalAccessTokenAttributesWithDefaults instantiates a new FullPersonalAccessTokenAttributes 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 NewFullPersonalAccessTokenAttributesWithDefaults() *FullPersonalAccessTokenAttributes { + this := FullPersonalAccessTokenAttributes{} + return &this +} + +// GetAlias returns the Alias field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetAlias() string { + if o == nil || o.Alias == nil { + var ret string + return ret + } + return *o.Alias +} + +// GetAliasOk returns a tuple with the Alias field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetAliasOk() (*string, bool) { + if o == nil || o.Alias == nil { + return nil, false + } + return o.Alias, true +} + +// HasAlias returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasAlias() bool { + return o != nil && o.Alias != nil +} + +// SetAlias gets a reference to the given string and assigns it to the Alias field. +func (o *FullPersonalAccessTokenAttributes) SetAlias(v string) { + o.Alias = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *FullPersonalAccessTokenAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *FullPersonalAccessTokenAttributes) GetExpiresAt() time.Time { + if o == nil || o.ExpiresAt.Get() == nil { + var ret time.Time + return ret + } + return *o.ExpiresAt.Get() +} + +// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise +// 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 *FullPersonalAccessTokenAttributes) GetExpiresAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.ExpiresAt.Get(), o.ExpiresAt.IsSet() +} + +// HasExpiresAt returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasExpiresAt() bool { + return o != nil && o.ExpiresAt.IsSet() +} + +// SetExpiresAt gets a reference to the given datadog.NullableTime and assigns it to the ExpiresAt field. +func (o *FullPersonalAccessTokenAttributes) SetExpiresAt(v time.Time) { + o.ExpiresAt.Set(&v) +} + +// SetExpiresAtNil sets the value for ExpiresAt to be an explicit nil. +func (o *FullPersonalAccessTokenAttributes) SetExpiresAtNil() { + o.ExpiresAt.Set(nil) +} + +// UnsetExpiresAt ensures that no value is present for ExpiresAt, not even an explicit nil. +func (o *FullPersonalAccessTokenAttributes) UnsetExpiresAt() { + o.ExpiresAt.Unset() +} + +// GetKey returns the Key field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetKey() string { + if o == nil || o.Key == nil { + var ret string + return ret + } + return *o.Key +} + +// GetKeyOk returns a tuple with the Key field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetKeyOk() (*string, bool) { + if o == nil || o.Key == nil { + return nil, false + } + return o.Key, true +} + +// HasKey returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasKey() bool { + return o != nil && o.Key != nil +} + +// SetKey gets a reference to the given string and assigns it to the Key field. +func (o *FullPersonalAccessTokenAttributes) SetKey(v string) { + o.Key = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *FullPersonalAccessTokenAttributes) SetName(v string) { + o.Name = &v +} + +// GetPublicPortion returns the PublicPortion field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetPublicPortion() string { + if o == nil || o.PublicPortion == nil { + var ret string + return ret + } + return *o.PublicPortion +} + +// GetPublicPortionOk returns a tuple with the PublicPortion field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetPublicPortionOk() (*string, bool) { + if o == nil || o.PublicPortion == nil { + return nil, false + } + return o.PublicPortion, true +} + +// HasPublicPortion returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasPublicPortion() bool { + return o != nil && o.PublicPortion != nil +} + +// SetPublicPortion gets a reference to the given string and assigns it to the PublicPortion field. +func (o *FullPersonalAccessTokenAttributes) SetPublicPortion(v string) { + o.PublicPortion = &v +} + +// GetScopes returns the Scopes field value if set, zero value otherwise. +func (o *FullPersonalAccessTokenAttributes) GetScopes() []string { + if o == nil || o.Scopes == nil { + var ret []string + return ret + } + return o.Scopes +} + +// GetScopesOk returns a tuple with the Scopes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FullPersonalAccessTokenAttributes) GetScopesOk() (*[]string, bool) { + if o == nil || o.Scopes == nil { + return nil, false + } + return &o.Scopes, true +} + +// HasScopes returns a boolean if a field has been set. +func (o *FullPersonalAccessTokenAttributes) HasScopes() bool { + return o != nil && o.Scopes != nil +} + +// SetScopes gets a reference to the given []string and assigns it to the Scopes field. +func (o *FullPersonalAccessTokenAttributes) SetScopes(v []string) { + o.Scopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FullPersonalAccessTokenAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Alias != nil { + toSerialize["alias"] = o.Alias + } + if o.CreatedAt != nil { + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.ExpiresAt.IsSet() { + toSerialize["expires_at"] = o.ExpiresAt.Get() + } + if o.Key != nil { + toSerialize["key"] = o.Key + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.PublicPortion != nil { + toSerialize["public_portion"] = o.PublicPortion + } + if o.Scopes != nil { + toSerialize["scopes"] = o.Scopes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FullPersonalAccessTokenAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Alias *string `json:"alias,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + ExpiresAt datadog.NullableTime `json:"expires_at,omitempty"` + Key *string `json:"key,omitempty"` + Name *string `json:"name,omitempty"` + PublicPortion *string `json:"public_portion,omitempty"` + Scopes []string `json:"scopes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"alias", "created_at", "expires_at", "key", "name", "public_portion", "scopes"}) + } else { + return err + } + o.Alias = all.Alias + o.CreatedAt = all.CreatedAt + o.ExpiresAt = all.ExpiresAt + o.Key = all.Key + o.Name = all.Name + o.PublicPortion = all.PublicPortion + o.Scopes = all.Scopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_list_personal_access_tokens_response.go b/api/datadogV2/model_list_personal_access_tokens_response.go new file mode 100644 index 00000000000..ea9b50df583 --- /dev/null +++ b/api/datadogV2/model_list_personal_access_tokens_response.go @@ -0,0 +1,146 @@ +// 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" +) + +// ListPersonalAccessTokensResponse Response for a list of personal access tokens. +type ListPersonalAccessTokensResponse struct { + // Array of personal access tokens. + Data []PersonalAccessToken `json:"data,omitempty"` + // Additional information related to the personal access token response. + Meta *PersonalAccessTokenResponseMeta `json:"meta,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:"-"` +} + +// NewListPersonalAccessTokensResponse instantiates a new ListPersonalAccessTokensResponse 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 NewListPersonalAccessTokensResponse() *ListPersonalAccessTokensResponse { + this := ListPersonalAccessTokensResponse{} + return &this +} + +// NewListPersonalAccessTokensResponseWithDefaults instantiates a new ListPersonalAccessTokensResponse 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 NewListPersonalAccessTokensResponseWithDefaults() *ListPersonalAccessTokensResponse { + this := ListPersonalAccessTokensResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ListPersonalAccessTokensResponse) GetData() []PersonalAccessToken { + if o == nil || o.Data == nil { + var ret []PersonalAccessToken + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListPersonalAccessTokensResponse) GetDataOk() (*[]PersonalAccessToken, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ListPersonalAccessTokensResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []PersonalAccessToken and assigns it to the Data field. +func (o *ListPersonalAccessTokensResponse) SetData(v []PersonalAccessToken) { + o.Data = v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *ListPersonalAccessTokensResponse) GetMeta() PersonalAccessTokenResponseMeta { + if o == nil || o.Meta == nil { + var ret PersonalAccessTokenResponseMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListPersonalAccessTokensResponse) GetMetaOk() (*PersonalAccessTokenResponseMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *ListPersonalAccessTokensResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given PersonalAccessTokenResponseMeta and assigns it to the Meta field. +func (o *ListPersonalAccessTokensResponse) SetMeta(v PersonalAccessTokenResponseMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListPersonalAccessTokensResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListPersonalAccessTokensResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []PersonalAccessToken `json:"data,omitempty"` + Meta *PersonalAccessTokenResponseMeta `json:"meta,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = all.Data + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token.go b/api/datadogV2/model_personal_access_token.go new file mode 100644 index 00000000000..031c61516e3 --- /dev/null +++ b/api/datadogV2/model_personal_access_token.go @@ -0,0 +1,227 @@ +// 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" +) + +// PersonalAccessToken Datadog personal access token. +type PersonalAccessToken struct { + // Attributes of a personal access token. + Attributes *PersonalAccessTokenAttributes `json:"attributes,omitempty"` + // ID of the personal access token. + Id *string `json:"id,omitempty"` + // Resources related to the personal access token. + Relationships *PersonalAccessTokenRelationships `json:"relationships,omitempty"` + // Personal access tokens resource type. + Type *PersonalAccessTokensType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPersonalAccessToken instantiates a new PersonalAccessToken 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 NewPersonalAccessToken() *PersonalAccessToken { + this := PersonalAccessToken{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = &typeVar + return &this +} + +// NewPersonalAccessTokenWithDefaults instantiates a new PersonalAccessToken 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 NewPersonalAccessTokenWithDefaults() *PersonalAccessToken { + this := PersonalAccessToken{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *PersonalAccessToken) GetAttributes() PersonalAccessTokenAttributes { + if o == nil || o.Attributes == nil { + var ret PersonalAccessTokenAttributes + 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 *PersonalAccessToken) GetAttributesOk() (*PersonalAccessTokenAttributes, 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 *PersonalAccessToken) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given PersonalAccessTokenAttributes and assigns it to the Attributes field. +func (o *PersonalAccessToken) SetAttributes(v PersonalAccessTokenAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *PersonalAccessToken) 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 *PersonalAccessToken) 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 *PersonalAccessToken) 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 *PersonalAccessToken) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *PersonalAccessToken) GetRelationships() PersonalAccessTokenRelationships { + if o == nil || o.Relationships == nil { + var ret PersonalAccessTokenRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessToken) GetRelationshipsOk() (*PersonalAccessTokenRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *PersonalAccessToken) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given PersonalAccessTokenRelationships and assigns it to the Relationships field. +func (o *PersonalAccessToken) SetRelationships(v PersonalAccessTokenRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *PersonalAccessToken) GetType() PersonalAccessTokensType { + if o == nil || o.Type == nil { + var ret PersonalAccessTokensType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessToken) GetTypeOk() (*PersonalAccessTokensType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *PersonalAccessToken) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given PersonalAccessTokensType and assigns it to the Type field. +func (o *PersonalAccessToken) SetType(v PersonalAccessTokensType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessToken) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessToken) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PersonalAccessTokenAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *PersonalAccessTokenRelationships `json:"relationships,omitempty"` + Type *PersonalAccessTokensType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships + if all.Type != nil && !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_personal_access_token_attributes.go b/api/datadogV2/model_personal_access_token_attributes.go new file mode 100644 index 00000000000..e0177090627 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_attributes.go @@ -0,0 +1,386 @@ +// 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 ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PersonalAccessTokenAttributes Attributes of a personal access token. +type PersonalAccessTokenAttributes struct { + // The alias (short identifier) of the personal access token. + Alias *string `json:"alias,omitempty"` + // Creation date of the personal access token. + CreatedAt *time.Time `json:"created_at,omitempty"` + // Expiration date of the personal access token. + ExpiresAt datadog.NullableTime `json:"expires_at,omitempty"` + // Date the personal access token was last used. + LastUsedAt datadog.NullableTime `json:"last_used_at,omitempty"` + // Date of last modification of the personal access token. + ModifiedAt datadog.NullableTime `json:"modified_at,omitempty"` + // Name of the personal access token. + Name *string `json:"name,omitempty"` + // The public portion of the personal access token. + PublicPortion *string `json:"public_portion,omitempty"` + // Array of scopes granted to the personal access token. + Scopes []string `json:"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:"-"` +} + +// NewPersonalAccessTokenAttributes instantiates a new PersonalAccessTokenAttributes 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 NewPersonalAccessTokenAttributes() *PersonalAccessTokenAttributes { + this := PersonalAccessTokenAttributes{} + return &this +} + +// NewPersonalAccessTokenAttributesWithDefaults instantiates a new PersonalAccessTokenAttributes 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 NewPersonalAccessTokenAttributesWithDefaults() *PersonalAccessTokenAttributes { + this := PersonalAccessTokenAttributes{} + return &this +} + +// GetAlias returns the Alias field value if set, zero value otherwise. +func (o *PersonalAccessTokenAttributes) GetAlias() string { + if o == nil || o.Alias == nil { + var ret string + return ret + } + return *o.Alias +} + +// GetAliasOk returns a tuple with the Alias field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenAttributes) GetAliasOk() (*string, bool) { + if o == nil || o.Alias == nil { + return nil, false + } + return o.Alias, true +} + +// HasAlias returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasAlias() bool { + return o != nil && o.Alias != nil +} + +// SetAlias gets a reference to the given string and assigns it to the Alias field. +func (o *PersonalAccessTokenAttributes) SetAlias(v string) { + o.Alias = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *PersonalAccessTokenAttributes) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *PersonalAccessTokenAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *PersonalAccessTokenAttributes) GetExpiresAt() time.Time { + if o == nil || o.ExpiresAt.Get() == nil { + var ret time.Time + return ret + } + return *o.ExpiresAt.Get() +} + +// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise +// 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 *PersonalAccessTokenAttributes) GetExpiresAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.ExpiresAt.Get(), o.ExpiresAt.IsSet() +} + +// HasExpiresAt returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasExpiresAt() bool { + return o != nil && o.ExpiresAt.IsSet() +} + +// SetExpiresAt gets a reference to the given datadog.NullableTime and assigns it to the ExpiresAt field. +func (o *PersonalAccessTokenAttributes) SetExpiresAt(v time.Time) { + o.ExpiresAt.Set(&v) +} + +// SetExpiresAtNil sets the value for ExpiresAt to be an explicit nil. +func (o *PersonalAccessTokenAttributes) SetExpiresAtNil() { + o.ExpiresAt.Set(nil) +} + +// UnsetExpiresAt ensures that no value is present for ExpiresAt, not even an explicit nil. +func (o *PersonalAccessTokenAttributes) UnsetExpiresAt() { + o.ExpiresAt.Unset() +} + +// GetLastUsedAt returns the LastUsedAt field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *PersonalAccessTokenAttributes) GetLastUsedAt() time.Time { + if o == nil || o.LastUsedAt.Get() == nil { + var ret time.Time + return ret + } + return *o.LastUsedAt.Get() +} + +// GetLastUsedAtOk returns a tuple with the LastUsedAt field value if set, nil otherwise +// 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 *PersonalAccessTokenAttributes) GetLastUsedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.LastUsedAt.Get(), o.LastUsedAt.IsSet() +} + +// HasLastUsedAt returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasLastUsedAt() bool { + return o != nil && o.LastUsedAt.IsSet() +} + +// SetLastUsedAt gets a reference to the given datadog.NullableTime and assigns it to the LastUsedAt field. +func (o *PersonalAccessTokenAttributes) SetLastUsedAt(v time.Time) { + o.LastUsedAt.Set(&v) +} + +// SetLastUsedAtNil sets the value for LastUsedAt to be an explicit nil. +func (o *PersonalAccessTokenAttributes) SetLastUsedAtNil() { + o.LastUsedAt.Set(nil) +} + +// UnsetLastUsedAt ensures that no value is present for LastUsedAt, not even an explicit nil. +func (o *PersonalAccessTokenAttributes) UnsetLastUsedAt() { + o.LastUsedAt.Unset() +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *PersonalAccessTokenAttributes) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt.Get() == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt.Get() +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// 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 *PersonalAccessTokenAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.ModifiedAt.Get(), o.ModifiedAt.IsSet() +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt.IsSet() +} + +// SetModifiedAt gets a reference to the given datadog.NullableTime and assigns it to the ModifiedAt field. +func (o *PersonalAccessTokenAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt.Set(&v) +} + +// SetModifiedAtNil sets the value for ModifiedAt to be an explicit nil. +func (o *PersonalAccessTokenAttributes) SetModifiedAtNil() { + o.ModifiedAt.Set(nil) +} + +// UnsetModifiedAt ensures that no value is present for ModifiedAt, not even an explicit nil. +func (o *PersonalAccessTokenAttributes) UnsetModifiedAt() { + o.ModifiedAt.Unset() +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PersonalAccessTokenAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PersonalAccessTokenAttributes) SetName(v string) { + o.Name = &v +} + +// GetPublicPortion returns the PublicPortion field value if set, zero value otherwise. +func (o *PersonalAccessTokenAttributes) GetPublicPortion() string { + if o == nil || o.PublicPortion == nil { + var ret string + return ret + } + return *o.PublicPortion +} + +// GetPublicPortionOk returns a tuple with the PublicPortion field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenAttributes) GetPublicPortionOk() (*string, bool) { + if o == nil || o.PublicPortion == nil { + return nil, false + } + return o.PublicPortion, true +} + +// HasPublicPortion returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasPublicPortion() bool { + return o != nil && o.PublicPortion != nil +} + +// SetPublicPortion gets a reference to the given string and assigns it to the PublicPortion field. +func (o *PersonalAccessTokenAttributes) SetPublicPortion(v string) { + o.PublicPortion = &v +} + +// GetScopes returns the Scopes field value if set, zero value otherwise. +func (o *PersonalAccessTokenAttributes) GetScopes() []string { + if o == nil || o.Scopes == nil { + var ret []string + return ret + } + return o.Scopes +} + +// GetScopesOk returns a tuple with the Scopes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenAttributes) GetScopesOk() (*[]string, bool) { + if o == nil || o.Scopes == nil { + return nil, false + } + return &o.Scopes, true +} + +// HasScopes returns a boolean if a field has been set. +func (o *PersonalAccessTokenAttributes) HasScopes() bool { + return o != nil && o.Scopes != nil +} + +// SetScopes gets a reference to the given []string and assigns it to the Scopes field. +func (o *PersonalAccessTokenAttributes) SetScopes(v []string) { + o.Scopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Alias != nil { + toSerialize["alias"] = o.Alias + } + if o.CreatedAt != nil { + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.ExpiresAt.IsSet() { + toSerialize["expires_at"] = o.ExpiresAt.Get() + } + if o.LastUsedAt.IsSet() { + toSerialize["last_used_at"] = o.LastUsedAt.Get() + } + if o.ModifiedAt.IsSet() { + toSerialize["modified_at"] = o.ModifiedAt.Get() + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.PublicPortion != nil { + toSerialize["public_portion"] = o.PublicPortion + } + if o.Scopes != nil { + toSerialize["scopes"] = o.Scopes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Alias *string `json:"alias,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + ExpiresAt datadog.NullableTime `json:"expires_at,omitempty"` + LastUsedAt datadog.NullableTime `json:"last_used_at,omitempty"` + ModifiedAt datadog.NullableTime `json:"modified_at,omitempty"` + Name *string `json:"name,omitempty"` + PublicPortion *string `json:"public_portion,omitempty"` + Scopes []string `json:"scopes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"alias", "created_at", "expires_at", "last_used_at", "modified_at", "name", "public_portion", "scopes"}) + } else { + return err + } + o.Alias = all.Alias + o.CreatedAt = all.CreatedAt + o.ExpiresAt = all.ExpiresAt + o.LastUsedAt = all.LastUsedAt + o.ModifiedAt = all.ModifiedAt + o.Name = all.Name + o.PublicPortion = all.PublicPortion + o.Scopes = all.Scopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_create_attributes.go b/api/datadogV2/model_personal_access_token_create_attributes.go new file mode 100644 index 00000000000..a6b2d993e34 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_create_attributes.go @@ -0,0 +1,170 @@ +// 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" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PersonalAccessTokenCreateAttributes Attributes used to create a personal access token. +type PersonalAccessTokenCreateAttributes struct { + // Expiration date of the personal access token. Must be at least 24 hours in the future. + ExpiresAt time.Time `json:"expires_at"` + // Name of the personal access token. + Name string `json:"name"` + // Array of scopes to grant the personal access token. + Scopes []string `json:"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:"-"` +} + +// NewPersonalAccessTokenCreateAttributes instantiates a new PersonalAccessTokenCreateAttributes 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 NewPersonalAccessTokenCreateAttributes(expiresAt time.Time, name string, scopes []string) *PersonalAccessTokenCreateAttributes { + this := PersonalAccessTokenCreateAttributes{} + this.ExpiresAt = expiresAt + this.Name = name + this.Scopes = scopes + return &this +} + +// NewPersonalAccessTokenCreateAttributesWithDefaults instantiates a new PersonalAccessTokenCreateAttributes 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 NewPersonalAccessTokenCreateAttributesWithDefaults() *PersonalAccessTokenCreateAttributes { + this := PersonalAccessTokenCreateAttributes{} + return &this +} + +// GetExpiresAt returns the ExpiresAt field value. +func (o *PersonalAccessTokenCreateAttributes) GetExpiresAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ExpiresAt +} + +// GetExpiresAtOk returns a tuple with the ExpiresAt field value +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenCreateAttributes) GetExpiresAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ExpiresAt, true +} + +// SetExpiresAt sets field value. +func (o *PersonalAccessTokenCreateAttributes) SetExpiresAt(v time.Time) { + o.ExpiresAt = v +} + +// GetName returns the Name field value. +func (o *PersonalAccessTokenCreateAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenCreateAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *PersonalAccessTokenCreateAttributes) SetName(v string) { + o.Name = v +} + +// GetScopes returns the Scopes field value. +func (o *PersonalAccessTokenCreateAttributes) GetScopes() []string { + if o == nil { + var ret []string + return ret + } + return o.Scopes +} + +// GetScopesOk returns a tuple with the Scopes field value +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenCreateAttributes) GetScopesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Scopes, true +} + +// SetScopes sets field value. +func (o *PersonalAccessTokenCreateAttributes) SetScopes(v []string) { + o.Scopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ExpiresAt.Nanosecond() == 0 { + toSerialize["expires_at"] = o.ExpiresAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["expires_at"] = o.ExpiresAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["name"] = o.Name + toSerialize["scopes"] = o.Scopes + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ExpiresAt *time.Time `json:"expires_at"` + Name *string `json:"name"` + Scopes *[]string `json:"scopes"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ExpiresAt == nil { + return fmt.Errorf("required field expires_at missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Scopes == nil { + return fmt.Errorf("required field scopes missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"expires_at", "name", "scopes"}) + } else { + return err + } + o.ExpiresAt = *all.ExpiresAt + o.Name = *all.Name + o.Scopes = *all.Scopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_create_data.go b/api/datadogV2/model_personal_access_token_create_data.go new file mode 100644 index 00000000000..9ece5155ef9 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_create_data.go @@ -0,0 +1,148 @@ +// 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" +) + +// PersonalAccessTokenCreateData Object used to create a personal access token. +type PersonalAccessTokenCreateData struct { + // Attributes used to create a personal access token. + Attributes PersonalAccessTokenCreateAttributes `json:"attributes"` + // Personal access tokens resource type. + Type PersonalAccessTokensType `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:"-"` +} + +// NewPersonalAccessTokenCreateData instantiates a new PersonalAccessTokenCreateData 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 NewPersonalAccessTokenCreateData(attributes PersonalAccessTokenCreateAttributes, typeVar PersonalAccessTokensType) *PersonalAccessTokenCreateData { + this := PersonalAccessTokenCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewPersonalAccessTokenCreateDataWithDefaults instantiates a new PersonalAccessTokenCreateData 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 NewPersonalAccessTokenCreateDataWithDefaults() *PersonalAccessTokenCreateData { + this := PersonalAccessTokenCreateData{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PersonalAccessTokenCreateData) GetAttributes() PersonalAccessTokenCreateAttributes { + if o == nil { + var ret PersonalAccessTokenCreateAttributes + 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 *PersonalAccessTokenCreateData) GetAttributesOk() (*PersonalAccessTokenCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PersonalAccessTokenCreateData) SetAttributes(v PersonalAccessTokenCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *PersonalAccessTokenCreateData) GetType() PersonalAccessTokensType { + if o == nil { + var ret PersonalAccessTokensType + 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 *PersonalAccessTokenCreateData) GetTypeOk() (*PersonalAccessTokensType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PersonalAccessTokenCreateData) SetType(v PersonalAccessTokensType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 *PersonalAccessTokenCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PersonalAccessTokenCreateAttributes `json:"attributes"` + Type *PersonalAccessTokensType `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.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if 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_personal_access_token_create_request.go b/api/datadogV2/model_personal_access_token_create_request.go new file mode 100644 index 00000000000..334dd8c179a --- /dev/null +++ b/api/datadogV2/model_personal_access_token_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PersonalAccessTokenCreateRequest Request used to create a personal access token. +type PersonalAccessTokenCreateRequest struct { + // Object used to create a personal access token. + Data PersonalAccessTokenCreateData `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:"-"` +} + +// NewPersonalAccessTokenCreateRequest instantiates a new PersonalAccessTokenCreateRequest 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 NewPersonalAccessTokenCreateRequest(data PersonalAccessTokenCreateData) *PersonalAccessTokenCreateRequest { + this := PersonalAccessTokenCreateRequest{} + this.Data = data + return &this +} + +// NewPersonalAccessTokenCreateRequestWithDefaults instantiates a new PersonalAccessTokenCreateRequest 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 NewPersonalAccessTokenCreateRequestWithDefaults() *PersonalAccessTokenCreateRequest { + this := PersonalAccessTokenCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *PersonalAccessTokenCreateRequest) GetData() PersonalAccessTokenCreateData { + if o == nil { + var ret PersonalAccessTokenCreateData + 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 *PersonalAccessTokenCreateRequest) GetDataOk() (*PersonalAccessTokenCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PersonalAccessTokenCreateRequest) SetData(v PersonalAccessTokenCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenCreateRequest) 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 *PersonalAccessTokenCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PersonalAccessTokenCreateData `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.Unmarshal(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_personal_access_token_create_response.go b/api/datadogV2/model_personal_access_token_create_response.go new file mode 100644 index 00000000000..48579dea3d8 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_create_response.go @@ -0,0 +1,111 @@ +// 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" +) + +// PersonalAccessTokenCreateResponse Response for creating a personal access token. Includes the token key. +type PersonalAccessTokenCreateResponse struct { + // Datadog personal access token, including the token key. + Data *FullPersonalAccessToken `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPersonalAccessTokenCreateResponse instantiates a new PersonalAccessTokenCreateResponse 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 NewPersonalAccessTokenCreateResponse() *PersonalAccessTokenCreateResponse { + this := PersonalAccessTokenCreateResponse{} + return &this +} + +// NewPersonalAccessTokenCreateResponseWithDefaults instantiates a new PersonalAccessTokenCreateResponse 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 NewPersonalAccessTokenCreateResponseWithDefaults() *PersonalAccessTokenCreateResponse { + this := PersonalAccessTokenCreateResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *PersonalAccessTokenCreateResponse) GetData() FullPersonalAccessToken { + if o == nil || o.Data == nil { + var ret FullPersonalAccessToken + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenCreateResponse) GetDataOk() (*FullPersonalAccessToken, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *PersonalAccessTokenCreateResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given FullPersonalAccessToken and assigns it to the Data field. +func (o *PersonalAccessTokenCreateResponse) SetData(v FullPersonalAccessToken) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenCreateResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenCreateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *FullPersonalAccessToken `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && 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_personal_access_token_relationships.go b/api/datadogV2/model_personal_access_token_relationships.go new file mode 100644 index 00000000000..bd6730d9c73 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_relationships.go @@ -0,0 +1,111 @@ +// 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" +) + +// PersonalAccessTokenRelationships Resources related to the personal access token. +type PersonalAccessTokenRelationships struct { + // Relationship to user. + OwnedBy *RelationshipToUser `json:"owned_by,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPersonalAccessTokenRelationships instantiates a new PersonalAccessTokenRelationships 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 NewPersonalAccessTokenRelationships() *PersonalAccessTokenRelationships { + this := PersonalAccessTokenRelationships{} + return &this +} + +// NewPersonalAccessTokenRelationshipsWithDefaults instantiates a new PersonalAccessTokenRelationships 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 NewPersonalAccessTokenRelationshipsWithDefaults() *PersonalAccessTokenRelationships { + this := PersonalAccessTokenRelationships{} + return &this +} + +// GetOwnedBy returns the OwnedBy field value if set, zero value otherwise. +func (o *PersonalAccessTokenRelationships) GetOwnedBy() RelationshipToUser { + if o == nil || o.OwnedBy == nil { + var ret RelationshipToUser + return ret + } + return *o.OwnedBy +} + +// GetOwnedByOk returns a tuple with the OwnedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenRelationships) GetOwnedByOk() (*RelationshipToUser, bool) { + if o == nil || o.OwnedBy == nil { + return nil, false + } + return o.OwnedBy, true +} + +// HasOwnedBy returns a boolean if a field has been set. +func (o *PersonalAccessTokenRelationships) HasOwnedBy() bool { + return o != nil && o.OwnedBy != nil +} + +// SetOwnedBy gets a reference to the given RelationshipToUser and assigns it to the OwnedBy field. +func (o *PersonalAccessTokenRelationships) SetOwnedBy(v RelationshipToUser) { + o.OwnedBy = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.OwnedBy != nil { + toSerialize["owned_by"] = o.OwnedBy + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + OwnedBy *RelationshipToUser `json:"owned_by,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"owned_by"}) + } else { + return err + } + + hasInvalidField := false + if all.OwnedBy != nil && all.OwnedBy.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.OwnedBy = all.OwnedBy + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_response.go b/api/datadogV2/model_personal_access_token_response.go new file mode 100644 index 00000000000..b4ae686bd61 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_response.go @@ -0,0 +1,111 @@ +// 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" +) + +// PersonalAccessTokenResponse Response for retrieving a personal access token. +type PersonalAccessTokenResponse struct { + // Datadog personal access token. + Data *PersonalAccessToken `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPersonalAccessTokenResponse instantiates a new PersonalAccessTokenResponse 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 NewPersonalAccessTokenResponse() *PersonalAccessTokenResponse { + this := PersonalAccessTokenResponse{} + return &this +} + +// NewPersonalAccessTokenResponseWithDefaults instantiates a new PersonalAccessTokenResponse 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 NewPersonalAccessTokenResponseWithDefaults() *PersonalAccessTokenResponse { + this := PersonalAccessTokenResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *PersonalAccessTokenResponse) GetData() PersonalAccessToken { + if o == nil || o.Data == nil { + var ret PersonalAccessToken + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenResponse) GetDataOk() (*PersonalAccessToken, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *PersonalAccessTokenResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given PersonalAccessToken and assigns it to the Data field. +func (o *PersonalAccessTokenResponse) SetData(v PersonalAccessToken) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PersonalAccessToken `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && 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_personal_access_token_response_meta.go b/api/datadogV2/model_personal_access_token_response_meta.go new file mode 100644 index 00000000000..629f4d20761 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_response_meta.go @@ -0,0 +1,111 @@ +// 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" +) + +// PersonalAccessTokenResponseMeta Additional information related to the personal access token response. +type PersonalAccessTokenResponseMeta struct { + // Pagination information. + Page *PersonalAccessTokenResponseMetaPage `json:"page,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:"-"` +} + +// NewPersonalAccessTokenResponseMeta instantiates a new PersonalAccessTokenResponseMeta 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 NewPersonalAccessTokenResponseMeta() *PersonalAccessTokenResponseMeta { + this := PersonalAccessTokenResponseMeta{} + return &this +} + +// NewPersonalAccessTokenResponseMetaWithDefaults instantiates a new PersonalAccessTokenResponseMeta 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 NewPersonalAccessTokenResponseMetaWithDefaults() *PersonalAccessTokenResponseMeta { + this := PersonalAccessTokenResponseMeta{} + return &this +} + +// GetPage returns the Page field value if set, zero value otherwise. +func (o *PersonalAccessTokenResponseMeta) GetPage() PersonalAccessTokenResponseMetaPage { + if o == nil || o.Page == nil { + var ret PersonalAccessTokenResponseMetaPage + return ret + } + return *o.Page +} + +// GetPageOk returns a tuple with the Page field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenResponseMeta) GetPageOk() (*PersonalAccessTokenResponseMetaPage, bool) { + if o == nil || o.Page == nil { + return nil, false + } + return o.Page, true +} + +// HasPage returns a boolean if a field has been set. +func (o *PersonalAccessTokenResponseMeta) HasPage() bool { + return o != nil && o.Page != nil +} + +// SetPage gets a reference to the given PersonalAccessTokenResponseMetaPage and assigns it to the Page field. +func (o *PersonalAccessTokenResponseMeta) SetPage(v PersonalAccessTokenResponseMetaPage) { + o.Page = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenResponseMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Page != nil { + toSerialize["page"] = o.Page + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenResponseMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Page *PersonalAccessTokenResponseMetaPage `json:"page,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"page"}) + } else { + return err + } + + hasInvalidField := false + if all.Page != nil && all.Page.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Page = all.Page + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_response_meta_page.go b/api/datadogV2/model_personal_access_token_response_meta_page.go new file mode 100644 index 00000000000..793997e184c --- /dev/null +++ b/api/datadogV2/model_personal_access_token_response_meta_page.go @@ -0,0 +1,102 @@ +// 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" +) + +// PersonalAccessTokenResponseMetaPage Pagination information. +type PersonalAccessTokenResponseMetaPage struct { + // Total filtered personal access token count. + TotalFilteredCount *int64 `json:"total_filtered_count,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:"-"` +} + +// NewPersonalAccessTokenResponseMetaPage instantiates a new PersonalAccessTokenResponseMetaPage 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 NewPersonalAccessTokenResponseMetaPage() *PersonalAccessTokenResponseMetaPage { + this := PersonalAccessTokenResponseMetaPage{} + return &this +} + +// NewPersonalAccessTokenResponseMetaPageWithDefaults instantiates a new PersonalAccessTokenResponseMetaPage 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 NewPersonalAccessTokenResponseMetaPageWithDefaults() *PersonalAccessTokenResponseMetaPage { + this := PersonalAccessTokenResponseMetaPage{} + return &this +} + +// GetTotalFilteredCount returns the TotalFilteredCount field value if set, zero value otherwise. +func (o *PersonalAccessTokenResponseMetaPage) GetTotalFilteredCount() int64 { + if o == nil || o.TotalFilteredCount == nil { + var ret int64 + return ret + } + return *o.TotalFilteredCount +} + +// GetTotalFilteredCountOk returns a tuple with the TotalFilteredCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenResponseMetaPage) GetTotalFilteredCountOk() (*int64, bool) { + if o == nil || o.TotalFilteredCount == nil { + return nil, false + } + return o.TotalFilteredCount, true +} + +// HasTotalFilteredCount returns a boolean if a field has been set. +func (o *PersonalAccessTokenResponseMetaPage) HasTotalFilteredCount() bool { + return o != nil && o.TotalFilteredCount != nil +} + +// SetTotalFilteredCount gets a reference to the given int64 and assigns it to the TotalFilteredCount field. +func (o *PersonalAccessTokenResponseMetaPage) SetTotalFilteredCount(v int64) { + o.TotalFilteredCount = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenResponseMetaPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.TotalFilteredCount != nil { + toSerialize["total_filtered_count"] = o.TotalFilteredCount + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenResponseMetaPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + TotalFilteredCount *int64 `json:"total_filtered_count,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"total_filtered_count"}) + } else { + return err + } + o.TotalFilteredCount = all.TotalFilteredCount + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_update_attributes.go b/api/datadogV2/model_personal_access_token_update_attributes.go new file mode 100644 index 00000000000..cb782ef7c78 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_update_attributes.go @@ -0,0 +1,137 @@ +// 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" +) + +// PersonalAccessTokenUpdateAttributes Attributes used to update a personal access token. +type PersonalAccessTokenUpdateAttributes struct { + // Name of the personal access token. + Name *string `json:"name,omitempty"` + // Array of scopes to grant the personal access token. + Scopes []string `json:"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:"-"` +} + +// NewPersonalAccessTokenUpdateAttributes instantiates a new PersonalAccessTokenUpdateAttributes 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 NewPersonalAccessTokenUpdateAttributes() *PersonalAccessTokenUpdateAttributes { + this := PersonalAccessTokenUpdateAttributes{} + return &this +} + +// NewPersonalAccessTokenUpdateAttributesWithDefaults instantiates a new PersonalAccessTokenUpdateAttributes 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 NewPersonalAccessTokenUpdateAttributesWithDefaults() *PersonalAccessTokenUpdateAttributes { + this := PersonalAccessTokenUpdateAttributes{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PersonalAccessTokenUpdateAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenUpdateAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PersonalAccessTokenUpdateAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PersonalAccessTokenUpdateAttributes) SetName(v string) { + o.Name = &v +} + +// GetScopes returns the Scopes field value if set, zero value otherwise. +func (o *PersonalAccessTokenUpdateAttributes) GetScopes() []string { + if o == nil || o.Scopes == nil { + var ret []string + return ret + } + return o.Scopes +} + +// GetScopesOk returns a tuple with the Scopes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PersonalAccessTokenUpdateAttributes) GetScopesOk() (*[]string, bool) { + if o == nil || o.Scopes == nil { + return nil, false + } + return &o.Scopes, true +} + +// HasScopes returns a boolean if a field has been set. +func (o *PersonalAccessTokenUpdateAttributes) HasScopes() bool { + return o != nil && o.Scopes != nil +} + +// SetScopes gets a reference to the given []string and assigns it to the Scopes field. +func (o *PersonalAccessTokenUpdateAttributes) SetScopes(v []string) { + o.Scopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Scopes != nil { + toSerialize["scopes"] = o.Scopes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PersonalAccessTokenUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name,omitempty"` + Scopes []string `json:"scopes,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "scopes"}) + } else { + return err + } + o.Name = all.Name + o.Scopes = all.Scopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_personal_access_token_update_data.go b/api/datadogV2/model_personal_access_token_update_data.go new file mode 100644 index 00000000000..921e9290455 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_update_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PersonalAccessTokenUpdateData Object used to update a personal access token. +type PersonalAccessTokenUpdateData struct { + // Attributes used to update a personal access token. + Attributes PersonalAccessTokenUpdateAttributes `json:"attributes"` + // ID of the personal access token. + Id string `json:"id"` + // Personal access tokens resource type. + Type PersonalAccessTokensType `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:"-"` +} + +// NewPersonalAccessTokenUpdateData instantiates a new PersonalAccessTokenUpdateData 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 NewPersonalAccessTokenUpdateData(attributes PersonalAccessTokenUpdateAttributes, id string, typeVar PersonalAccessTokensType) *PersonalAccessTokenUpdateData { + this := PersonalAccessTokenUpdateData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewPersonalAccessTokenUpdateDataWithDefaults instantiates a new PersonalAccessTokenUpdateData 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 NewPersonalAccessTokenUpdateDataWithDefaults() *PersonalAccessTokenUpdateData { + this := PersonalAccessTokenUpdateData{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *PersonalAccessTokenUpdateData) GetAttributes() PersonalAccessTokenUpdateAttributes { + if o == nil { + var ret PersonalAccessTokenUpdateAttributes + 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 *PersonalAccessTokenUpdateData) GetAttributesOk() (*PersonalAccessTokenUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *PersonalAccessTokenUpdateData) SetAttributes(v PersonalAccessTokenUpdateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *PersonalAccessTokenUpdateData) 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 *PersonalAccessTokenUpdateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PersonalAccessTokenUpdateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PersonalAccessTokenUpdateData) GetType() PersonalAccessTokensType { + if o == nil { + var ret PersonalAccessTokensType + 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 *PersonalAccessTokenUpdateData) GetTypeOk() (*PersonalAccessTokensType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PersonalAccessTokenUpdateData) SetType(v PersonalAccessTokensType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenUpdateData) 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 *PersonalAccessTokenUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PersonalAccessTokenUpdateAttributes `json:"attributes"` + Id *string `json:"id"` + Type *PersonalAccessTokensType `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.Unmarshal(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_personal_access_token_update_request.go b/api/datadogV2/model_personal_access_token_update_request.go new file mode 100644 index 00000000000..0af79e0a8c6 --- /dev/null +++ b/api/datadogV2/model_personal_access_token_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PersonalAccessTokenUpdateRequest Request used to update a personal access token. +type PersonalAccessTokenUpdateRequest struct { + // Object used to update a personal access token. + Data PersonalAccessTokenUpdateData `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:"-"` +} + +// NewPersonalAccessTokenUpdateRequest instantiates a new PersonalAccessTokenUpdateRequest 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 NewPersonalAccessTokenUpdateRequest(data PersonalAccessTokenUpdateData) *PersonalAccessTokenUpdateRequest { + this := PersonalAccessTokenUpdateRequest{} + this.Data = data + return &this +} + +// NewPersonalAccessTokenUpdateRequestWithDefaults instantiates a new PersonalAccessTokenUpdateRequest 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 NewPersonalAccessTokenUpdateRequestWithDefaults() *PersonalAccessTokenUpdateRequest { + this := PersonalAccessTokenUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *PersonalAccessTokenUpdateRequest) GetData() PersonalAccessTokenUpdateData { + if o == nil { + var ret PersonalAccessTokenUpdateData + 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 *PersonalAccessTokenUpdateRequest) GetDataOk() (*PersonalAccessTokenUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PersonalAccessTokenUpdateRequest) SetData(v PersonalAccessTokenUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PersonalAccessTokenUpdateRequest) 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 *PersonalAccessTokenUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PersonalAccessTokenUpdateData `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.Unmarshal(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_personal_access_tokens_sort.go b/api/datadogV2/model_personal_access_tokens_sort.go new file mode 100644 index 00000000000..6c7253e4033 --- /dev/null +++ b/api/datadogV2/model_personal_access_tokens_sort.go @@ -0,0 +1,74 @@ +// 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" +) + +// PersonalAccessTokensSort Sorting options +type PersonalAccessTokensSort string + +// List of PersonalAccessTokensSort. +const ( + PERSONALACCESSTOKENSSORT_NAME_ASCENDING PersonalAccessTokensSort = "name" + PERSONALACCESSTOKENSSORT_NAME_DESCENDING PersonalAccessTokensSort = "-name" + PERSONALACCESSTOKENSSORT_CREATED_AT_ASCENDING PersonalAccessTokensSort = "created_at" + PERSONALACCESSTOKENSSORT_CREATED_AT_DESCENDING PersonalAccessTokensSort = "-created_at" + PERSONALACCESSTOKENSSORT_EXPIRES_AT_ASCENDING PersonalAccessTokensSort = "expires_at" + PERSONALACCESSTOKENSSORT_EXPIRES_AT_DESCENDING PersonalAccessTokensSort = "-expires_at" +) + +var allowedPersonalAccessTokensSortEnumValues = []PersonalAccessTokensSort{ + PERSONALACCESSTOKENSSORT_NAME_ASCENDING, + PERSONALACCESSTOKENSSORT_NAME_DESCENDING, + PERSONALACCESSTOKENSSORT_CREATED_AT_ASCENDING, + PERSONALACCESSTOKENSSORT_CREATED_AT_DESCENDING, + PERSONALACCESSTOKENSSORT_EXPIRES_AT_ASCENDING, + PERSONALACCESSTOKENSSORT_EXPIRES_AT_DESCENDING, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PersonalAccessTokensSort) GetAllowedValues() []PersonalAccessTokensSort { + return allowedPersonalAccessTokensSortEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PersonalAccessTokensSort) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PersonalAccessTokensSort(value) + return nil +} + +// NewPersonalAccessTokensSortFromValue returns a pointer to a valid PersonalAccessTokensSort +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPersonalAccessTokensSortFromValue(v string) (*PersonalAccessTokensSort, error) { + ev := PersonalAccessTokensSort(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PersonalAccessTokensSort: valid values are %v", v, allowedPersonalAccessTokensSortEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PersonalAccessTokensSort) IsValid() bool { + for _, existing := range allowedPersonalAccessTokensSortEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PersonalAccessTokensSort value. +func (v PersonalAccessTokensSort) Ptr() *PersonalAccessTokensSort { + return &v +} diff --git a/api/datadogV2/model_personal_access_tokens_type.go b/api/datadogV2/model_personal_access_tokens_type.go new file mode 100644 index 00000000000..9e9a9390500 --- /dev/null +++ b/api/datadogV2/model_personal_access_tokens_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" +) + +// PersonalAccessTokensType Personal access tokens resource type. +type PersonalAccessTokensType string + +// List of PersonalAccessTokensType. +const ( + PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS PersonalAccessTokensType = "personal_access_tokens" +) + +var allowedPersonalAccessTokensTypeEnumValues = []PersonalAccessTokensType{ + PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PersonalAccessTokensType) GetAllowedValues() []PersonalAccessTokensType { + return allowedPersonalAccessTokensTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PersonalAccessTokensType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PersonalAccessTokensType(value) + return nil +} + +// NewPersonalAccessTokensTypeFromValue returns a pointer to a valid PersonalAccessTokensType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPersonalAccessTokensTypeFromValue(v string) (*PersonalAccessTokensType, error) { + ev := PersonalAccessTokensType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PersonalAccessTokensType: valid values are %v", v, allowedPersonalAccessTokensTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PersonalAccessTokensType) IsValid() bool { + for _, existing := range allowedPersonalAccessTokensTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PersonalAccessTokensType value. +func (v PersonalAccessTokensType) Ptr() *PersonalAccessTokensType { + return &v +} diff --git a/api/datadogV2/model_service_account_access_token_create_attributes.go b/api/datadogV2/model_service_account_access_token_create_attributes.go new file mode 100644 index 00000000000..80876ab7bdb --- /dev/null +++ b/api/datadogV2/model_service_account_access_token_create_attributes.go @@ -0,0 +1,173 @@ +// 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" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceAccountAccessTokenCreateAttributes Attributes used to create a service account access token. +type ServiceAccountAccessTokenCreateAttributes struct { + // Expiration date of the access token. Optional for service account tokens. + ExpiresAt *time.Time `json:"expires_at,omitempty"` + // Name of the access token. + Name string `json:"name"` + // Array of scopes to grant the access token. + Scopes []string `json:"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:"-"` +} + +// NewServiceAccountAccessTokenCreateAttributes instantiates a new ServiceAccountAccessTokenCreateAttributes 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 NewServiceAccountAccessTokenCreateAttributes(name string, scopes []string) *ServiceAccountAccessTokenCreateAttributes { + this := ServiceAccountAccessTokenCreateAttributes{} + this.Name = name + this.Scopes = scopes + return &this +} + +// NewServiceAccountAccessTokenCreateAttributesWithDefaults instantiates a new ServiceAccountAccessTokenCreateAttributes 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 NewServiceAccountAccessTokenCreateAttributesWithDefaults() *ServiceAccountAccessTokenCreateAttributes { + this := ServiceAccountAccessTokenCreateAttributes{} + return &this +} + +// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise. +func (o *ServiceAccountAccessTokenCreateAttributes) GetExpiresAt() time.Time { + if o == nil || o.ExpiresAt == nil { + var ret time.Time + return ret + } + return *o.ExpiresAt +} + +// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceAccountAccessTokenCreateAttributes) GetExpiresAtOk() (*time.Time, bool) { + if o == nil || o.ExpiresAt == nil { + return nil, false + } + return o.ExpiresAt, true +} + +// HasExpiresAt returns a boolean if a field has been set. +func (o *ServiceAccountAccessTokenCreateAttributes) HasExpiresAt() bool { + return o != nil && o.ExpiresAt != nil +} + +// SetExpiresAt gets a reference to the given time.Time and assigns it to the ExpiresAt field. +func (o *ServiceAccountAccessTokenCreateAttributes) SetExpiresAt(v time.Time) { + o.ExpiresAt = &v +} + +// GetName returns the Name field value. +func (o *ServiceAccountAccessTokenCreateAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ServiceAccountAccessTokenCreateAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ServiceAccountAccessTokenCreateAttributes) SetName(v string) { + o.Name = v +} + +// GetScopes returns the Scopes field value. +func (o *ServiceAccountAccessTokenCreateAttributes) GetScopes() []string { + if o == nil { + var ret []string + return ret + } + return o.Scopes +} + +// GetScopesOk returns a tuple with the Scopes field value +// and a boolean to check if the value has been set. +func (o *ServiceAccountAccessTokenCreateAttributes) GetScopesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.Scopes, true +} + +// SetScopes sets field value. +func (o *ServiceAccountAccessTokenCreateAttributes) SetScopes(v []string) { + o.Scopes = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceAccountAccessTokenCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ExpiresAt != nil { + if o.ExpiresAt.Nanosecond() == 0 { + toSerialize["expires_at"] = o.ExpiresAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["expires_at"] = o.ExpiresAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + toSerialize["name"] = o.Name + toSerialize["scopes"] = o.Scopes + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceAccountAccessTokenCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ExpiresAt *time.Time `json:"expires_at,omitempty"` + Name *string `json:"name"` + Scopes *[]string `json:"scopes"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Scopes == nil { + return fmt.Errorf("required field scopes missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"expires_at", "name", "scopes"}) + } else { + return err + } + o.ExpiresAt = all.ExpiresAt + o.Name = *all.Name + o.Scopes = *all.Scopes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_account_access_token_create_data.go b/api/datadogV2/model_service_account_access_token_create_data.go new file mode 100644 index 00000000000..86088df0135 --- /dev/null +++ b/api/datadogV2/model_service_account_access_token_create_data.go @@ -0,0 +1,148 @@ +// 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" +) + +// ServiceAccountAccessTokenCreateData Object used to create a service account access token. +type ServiceAccountAccessTokenCreateData struct { + // Attributes used to create a service account access token. + Attributes ServiceAccountAccessTokenCreateAttributes `json:"attributes"` + // Personal access tokens resource type. + Type PersonalAccessTokensType `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:"-"` +} + +// NewServiceAccountAccessTokenCreateData instantiates a new ServiceAccountAccessTokenCreateData 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 NewServiceAccountAccessTokenCreateData(attributes ServiceAccountAccessTokenCreateAttributes, typeVar PersonalAccessTokensType) *ServiceAccountAccessTokenCreateData { + this := ServiceAccountAccessTokenCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewServiceAccountAccessTokenCreateDataWithDefaults instantiates a new ServiceAccountAccessTokenCreateData 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 NewServiceAccountAccessTokenCreateDataWithDefaults() *ServiceAccountAccessTokenCreateData { + this := ServiceAccountAccessTokenCreateData{} + var typeVar PersonalAccessTokensType = PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceAccountAccessTokenCreateData) GetAttributes() ServiceAccountAccessTokenCreateAttributes { + if o == nil { + var ret ServiceAccountAccessTokenCreateAttributes + 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 *ServiceAccountAccessTokenCreateData) GetAttributesOk() (*ServiceAccountAccessTokenCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceAccountAccessTokenCreateData) SetAttributes(v ServiceAccountAccessTokenCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ServiceAccountAccessTokenCreateData) GetType() PersonalAccessTokensType { + if o == nil { + var ret PersonalAccessTokensType + 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 *ServiceAccountAccessTokenCreateData) GetTypeOk() (*PersonalAccessTokensType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceAccountAccessTokenCreateData) SetType(v PersonalAccessTokensType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceAccountAccessTokenCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 *ServiceAccountAccessTokenCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceAccountAccessTokenCreateAttributes `json:"attributes"` + Type *PersonalAccessTokensType `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.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if 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_service_account_access_token_create_request.go b/api/datadogV2/model_service_account_access_token_create_request.go new file mode 100644 index 00000000000..90fcabc60a5 --- /dev/null +++ b/api/datadogV2/model_service_account_access_token_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ServiceAccountAccessTokenCreateRequest Request used to create a service account access token. +type ServiceAccountAccessTokenCreateRequest struct { + // Object used to create a service account access token. + Data ServiceAccountAccessTokenCreateData `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:"-"` +} + +// NewServiceAccountAccessTokenCreateRequest instantiates a new ServiceAccountAccessTokenCreateRequest 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 NewServiceAccountAccessTokenCreateRequest(data ServiceAccountAccessTokenCreateData) *ServiceAccountAccessTokenCreateRequest { + this := ServiceAccountAccessTokenCreateRequest{} + this.Data = data + return &this +} + +// NewServiceAccountAccessTokenCreateRequestWithDefaults instantiates a new ServiceAccountAccessTokenCreateRequest 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 NewServiceAccountAccessTokenCreateRequestWithDefaults() *ServiceAccountAccessTokenCreateRequest { + this := ServiceAccountAccessTokenCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceAccountAccessTokenCreateRequest) GetData() ServiceAccountAccessTokenCreateData { + if o == nil { + var ret ServiceAccountAccessTokenCreateData + 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 *ServiceAccountAccessTokenCreateRequest) GetDataOk() (*ServiceAccountAccessTokenCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceAccountAccessTokenCreateRequest) SetData(v ServiceAccountAccessTokenCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceAccountAccessTokenCreateRequest) 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 *ServiceAccountAccessTokenCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ServiceAccountAccessTokenCreateData `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.Unmarshal(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/examples/v2/key-management/CreatePersonalAccessToken.go b/examples/v2/key-management/CreatePersonalAccessToken.go new file mode 100644 index 00000000000..452267d6608 --- /dev/null +++ b/examples/v2/key-management/CreatePersonalAccessToken.go @@ -0,0 +1,42 @@ +// Create a personal access token returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.PersonalAccessTokenCreateRequest{ + Data: datadogV2.PersonalAccessTokenCreateData{ + Type: datadogV2.PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS, + Attributes: datadogV2.PersonalAccessTokenCreateAttributes{ + Name: "Example-Key-Management", + Scopes: []string{ + "dashboards_read", + }, + ExpiresAt: time.Now().AddDate(0, 0, 365), + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewKeyManagementApi(apiClient) + resp, r, err := api.CreatePersonalAccessToken(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `KeyManagementApi.CreatePersonalAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `KeyManagementApi.CreatePersonalAccessToken`:\n%s\n", responseContent) +} diff --git a/examples/v2/key-management/GetPersonalAccessToken.go b/examples/v2/key-management/GetPersonalAccessToken.go new file mode 100644 index 00000000000..a529e716b9a --- /dev/null +++ b/examples/v2/key-management/GetPersonalAccessToken.go @@ -0,0 +1,32 @@ +// Get a personal access token returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "personal_access_token" in the system + PersonalAccessTokenDataID := os.Getenv("PERSONAL_ACCESS_TOKEN_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewKeyManagementApi(apiClient) + resp, r, err := api.GetPersonalAccessToken(ctx, PersonalAccessTokenDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `KeyManagementApi.GetPersonalAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `KeyManagementApi.GetPersonalAccessToken`:\n%s\n", responseContent) +} diff --git a/examples/v2/key-management/ListPersonalAccessTokens.go b/examples/v2/key-management/ListPersonalAccessTokens.go new file mode 100644 index 00000000000..d3b6d05e7ea --- /dev/null +++ b/examples/v2/key-management/ListPersonalAccessTokens.go @@ -0,0 +1,29 @@ +// Get all personal access tokens 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.NewKeyManagementApi(apiClient) + resp, r, err := api.ListPersonalAccessTokens(ctx, *datadogV2.NewListPersonalAccessTokensOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `KeyManagementApi.ListPersonalAccessTokens`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `KeyManagementApi.ListPersonalAccessTokens`:\n%s\n", responseContent) +} diff --git a/examples/v2/key-management/RevokePersonalAccessToken.go b/examples/v2/key-management/RevokePersonalAccessToken.go new file mode 100644 index 00000000000..ea8e7f991c4 --- /dev/null +++ b/examples/v2/key-management/RevokePersonalAccessToken.go @@ -0,0 +1,28 @@ +// Revoke a personal access token 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() { + // there is a valid "personal_access_token" in the system + PersonalAccessTokenDataID := os.Getenv("PERSONAL_ACCESS_TOKEN_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewKeyManagementApi(apiClient) + r, err := api.RevokePersonalAccessToken(ctx, PersonalAccessTokenDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `KeyManagementApi.RevokePersonalAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/key-management/UpdatePersonalAccessToken.go b/examples/v2/key-management/UpdatePersonalAccessToken.go new file mode 100644 index 00000000000..ffe72d26fb7 --- /dev/null +++ b/examples/v2/key-management/UpdatePersonalAccessToken.go @@ -0,0 +1,41 @@ +// Update a personal access token returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "personal_access_token" in the system + PersonalAccessTokenDataID := os.Getenv("PERSONAL_ACCESS_TOKEN_DATA_ID") + + body := datadogV2.PersonalAccessTokenUpdateRequest{ + Data: datadogV2.PersonalAccessTokenUpdateData{ + Type: datadogV2.PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS, + Id: PersonalAccessTokenDataID, + Attributes: datadogV2.PersonalAccessTokenUpdateAttributes{ + Name: datadog.PtrString("Example-Key-Management-updated"), + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewKeyManagementApi(apiClient) + resp, r, err := api.UpdatePersonalAccessToken(ctx, PersonalAccessTokenDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `KeyManagementApi.UpdatePersonalAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `KeyManagementApi.UpdatePersonalAccessToken`:\n%s\n", responseContent) +} diff --git a/examples/v2/service-accounts/CreateServiceAccountAccessToken.go b/examples/v2/service-accounts/CreateServiceAccountAccessToken.go new file mode 100644 index 00000000000..1eaa19be208 --- /dev/null +++ b/examples/v2/service-accounts/CreateServiceAccountAccessToken.go @@ -0,0 +1,43 @@ +// Create an access token for a service account returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "service_account_user" in the system + ServiceAccountUserDataID := os.Getenv("SERVICE_ACCOUNT_USER_DATA_ID") + + body := datadogV2.ServiceAccountAccessTokenCreateRequest{ + Data: datadogV2.ServiceAccountAccessTokenCreateData{ + Type: datadogV2.PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS, + Attributes: datadogV2.ServiceAccountAccessTokenCreateAttributes{ + Name: "Example-Service-Account", + Scopes: []string{ + "dashboards_read", + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceAccountsApi(apiClient) + resp, r, err := api.CreateServiceAccountAccessToken(ctx, ServiceAccountUserDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.CreateServiceAccountAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceAccountsApi.CreateServiceAccountAccessToken`:\n%s\n", responseContent) +} diff --git a/examples/v2/service-accounts/GetServiceAccountAccessToken.go b/examples/v2/service-accounts/GetServiceAccountAccessToken.go new file mode 100644 index 00000000000..5cc2dab4675 --- /dev/null +++ b/examples/v2/service-accounts/GetServiceAccountAccessToken.go @@ -0,0 +1,35 @@ +// Get an access token for a service account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "service_account_user" in the system + ServiceAccountUserDataID := os.Getenv("SERVICE_ACCOUNT_USER_DATA_ID") + + // there is a valid "service_account_access_token" for "service_account_user" + ServiceAccountAccessTokenDataID := os.Getenv("SERVICE_ACCOUNT_ACCESS_TOKEN_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceAccountsApi(apiClient) + resp, r, err := api.GetServiceAccountAccessToken(ctx, ServiceAccountUserDataID, ServiceAccountAccessTokenDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.GetServiceAccountAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceAccountsApi.GetServiceAccountAccessToken`:\n%s\n", responseContent) +} diff --git a/examples/v2/service-accounts/ListServiceAccountAccessTokens.go b/examples/v2/service-accounts/ListServiceAccountAccessTokens.go new file mode 100644 index 00000000000..1cdfad43d5c --- /dev/null +++ b/examples/v2/service-accounts/ListServiceAccountAccessTokens.go @@ -0,0 +1,32 @@ +// List access tokens for a service account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "service_account_user" in the system + ServiceAccountUserDataID := os.Getenv("SERVICE_ACCOUNT_USER_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceAccountsApi(apiClient) + resp, r, err := api.ListServiceAccountAccessTokens(ctx, ServiceAccountUserDataID, *datadogV2.NewListServiceAccountAccessTokensOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.ListServiceAccountAccessTokens`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceAccountsApi.ListServiceAccountAccessTokens`:\n%s\n", responseContent) +} diff --git a/examples/v2/service-accounts/RevokeServiceAccountAccessToken.go b/examples/v2/service-accounts/RevokeServiceAccountAccessToken.go new file mode 100644 index 00000000000..2935c89550e --- /dev/null +++ b/examples/v2/service-accounts/RevokeServiceAccountAccessToken.go @@ -0,0 +1,31 @@ +// Revoke an access token for a service account 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() { + // there is a valid "service_account_user" in the system + ServiceAccountUserDataID := os.Getenv("SERVICE_ACCOUNT_USER_DATA_ID") + + // there is a valid "service_account_access_token" for "service_account_user" + ServiceAccountAccessTokenDataID := os.Getenv("SERVICE_ACCOUNT_ACCESS_TOKEN_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceAccountsApi(apiClient) + r, err := api.RevokeServiceAccountAccessToken(ctx, ServiceAccountUserDataID, ServiceAccountAccessTokenDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.RevokeServiceAccountAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/service-accounts/UpdateServiceAccountAccessToken.go b/examples/v2/service-accounts/UpdateServiceAccountAccessToken.go new file mode 100644 index 00000000000..290111c2eaf --- /dev/null +++ b/examples/v2/service-accounts/UpdateServiceAccountAccessToken.go @@ -0,0 +1,44 @@ +// Update an access token for a service account returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "service_account_user" in the system + ServiceAccountUserDataID := os.Getenv("SERVICE_ACCOUNT_USER_DATA_ID") + + // there is a valid "service_account_access_token" for "service_account_user" + ServiceAccountAccessTokenDataID := os.Getenv("SERVICE_ACCOUNT_ACCESS_TOKEN_DATA_ID") + + body := datadogV2.PersonalAccessTokenUpdateRequest{ + Data: datadogV2.PersonalAccessTokenUpdateData{ + Id: ServiceAccountAccessTokenDataID, + Type: datadogV2.PERSONALACCESSTOKENSTYPE_PERSONAL_ACCESS_TOKENS, + Attributes: datadogV2.PersonalAccessTokenUpdateAttributes{ + Name: datadog.PtrString("My Personal Access Token-updated"), + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceAccountsApi(apiClient) + resp, r, err := api.UpdateServiceAccountAccessToken(ctx, ServiceAccountUserDataID, ServiceAccountAccessTokenDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceAccountsApi.UpdateServiceAccountAccessToken`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceAccountsApi.UpdateServiceAccountAccessToken`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.freeze new file mode 100644 index 00000000000..1ab7569dc43 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-04-08T16:45:23.208Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.yaml new file mode 100644 index 00000000000..31ac99c9f9b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Create_a_personal_access_token_returns_Created_response.yaml @@ -0,0 +1,37 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"expires_at":"2027-04-08T16:45:23.208Z","name":"Test-Create_a_personal_access_token_returns_Created_response-1775666723","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":{"id":"da1bd5f8-847b-4aec-a33d-11b04ebde244","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:23.302611856Z","expires_at":"2027-04-08T16:45:23.208Z","key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxXxxxxxxxxxx","name":"Test-Create_a_personal_access_token_returns_Created_response-1775666723","public_portion":"6dZ2zcpumTdlnHIgx2SlHA","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/da1bd5f8-847b-4aec-a33d-11b04ebde244 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.freeze new file mode 100644 index 00000000000..04a4adeef36 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-08T16:45:35.914Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.yaml new file mode 100644 index 00000000000..e87af3b1c57 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_a_personal_access_token_returns_OK_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"expires_at":"2027-04-08T16:45:35.914Z","name":"Test-Get_a_personal_access_token_returns_OK_response-1775666735","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":{"id":"6ada9c44-0b7f-4e35-826b-ccecd6d358d5","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:36.006189144Z","expires_at":"2027-04-08T16:45:35.914Z","key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxXxxxxxxxxx","name":"Test-Get_a_personal_access_token_returns_OK_response-1775666735","public_portion":"3Fd5hG1s1rf27qn2E4nNdF","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/personal_access_tokens/6ada9c44-0b7f-4e35-826b-ccecd6d358d5 + response: + body: '{"data":{"id":"6ada9c44-0b7f-4e35-826b-ccecd6d358d5","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:36.006189Z","expires_at":"2027-04-08T16:45:35.914Z","last_used_at":null,"name":"Test-Get_a_personal_access_token_returns_OK_response-1775666735","public_portion":"3Fd5hG1s1rf27qn2E4nNdF","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/6ada9c44-0b7f-4e35-826b-ccecd6d358d5 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.freeze new file mode 100644 index 00000000000..fc8e158682b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-08T16:46:16.639Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.yaml new file mode 100644 index 00000000000..73ae249750e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Get_all_personal_access_tokens_returns_OK_response.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"expires_at":"2027-04-08T16:46:16.639Z","name":"Test-Get_all_personal_access_tokens_returns_OK_response-1775666776","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":{"id":"35ef7728-4761-41dd-8a7b-f1112a26f840","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:46:16.769979863Z","expires_at":"2027-04-08T16:46:16.639Z","key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Get_all_personal_access_tokens_returns_OK_response-1775666776","public_portion":"1dm1op4lL89nV8pt94Tdk8","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":[{"id":"61c07794-df2a-4403-a6ad-caa6bb70dae2","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T08:58:54.688182Z","expires_at":"2026-04-09T08:58:54Z","last_used_at":"2026-04-08T08:58:55.302839705Z","name":"dd_auth_cli-DhhOC4JHLtgPkfDr6DEXUcTL79UOCx1w2ENxgmIHh7w","public_portion":"2ySDERb6wx1YqV1udJl61q","scopes":["admin","standard","logs_read_index_data","logs_modify_indexes","logs_live_tail","logs_write_exclusion_filters","logs_write_pipelines","logs_write_processors","logs_write_archives","logs_generate_metrics","dashboards_read","dashboards_write","dashboards_public_share","monitors_read","monitors_write","monitors_downtime","logs_read_data","logs_read_archives","security_monitoring_rules_read","security_monitoring_rules_write","security_monitoring_signals_read","security_monitoring_signals_write","user_access_invite","user_access_manage","user_app_keys","org_app_keys_read","org_app_keys_write","synthetics_private_location_read","synthetics_private_location_write","billing_read","billing_edit","usage_read","usage_edit","metric_tags_write","logs_write_historical_view","audit_logs_read","api_keys_read","api_keys_write","synthetics_global_variable_read","synthetics_global_variable_write","synthetics_read","synthetics_write","synthetics_default_settings_read","synthetics_default_settings_write","logs_write_facets","service_account_write","integrations_api","apm_read","apm_retention_filter_read","apm_retention_filter_write","apm_service_ingest_read","apm_service_ingest_write","apm_apdex_manage_write","apm_tag_management_write","apm_primary_operation_write","audit_logs_write","rum_apps_write","debugger_write","debugger_read","data_scanner_read","data_scanner_write","org_management","security_monitoring_filters_read","security_monitoring_filters_write","incident_read","incident_write","incident_settings_read","incident_settings_write","metrics_read","timeseries_query","events_read","appsec_event_rule_read","appsec_event_rule_write","rum_apps_read","rum_session_replay_read","security_monitoring_notification_profiles_read","security_monitoring_notification_profiles_write","apm_generate_metrics","security_monitoring_cws_agent_rules_read","security_monitoring_cws_agent_rules_write","apm_pipelines_write","apm_pipelines_read","observability_pipelines_read","observability_pipelines_write","workflows_read","workflows_write","workflows_run","connections_read","connections_write","notebooks_read","notebooks_write","logs_delete_data","rum_generate_metrics","aws_configurations_manage","azure_configurations_manage","gcp_configurations_manage","manage_integrations","usage_notifications_read","usage_notifications_write","generate_dashboard_reports","slos_read","slos_write","slos_corrections","monitor_config_policy_write","apm_service_catalog_write","apm_service_catalog_read","logs_write_forwarding_rules","watchdog_insights_read","connections_resolve","user_access_read","appsec_protect_read","appsec_protect_write","appsec_activation_read","appsec_activation_write","apps_run","apps_write","cases_read","cases_write","apm_remote_configuration_write","apm_remote_configuration_read","ci_visibility_read","ci_visibility_write","ci_provider_settings_write","ci_visibility_settings_write","continuous_profiler_read","teams_read","teams_manage","security_monitoring_findings_read","incident_notification_settings_read","incident_notification_settings_write","ci_ingestion_control_write","error_tracking_write","watchdog_alerts_write","saved_views_write","client_tokens_read","client_tokens_write","event_correlation_config_read","event_correlation_config_write","event_config_write","security_monitoring_findings_write","cloud_cost_management_read","cloud_cost_management_write","host_tags_write","ci_visibility_pipelines_write","quality_gate_rules_read","quality_gate_rules_write","metrics_metadata_write","rum_delete_data","appsec_vm_write","reference_tables_write","rum_playlist_write","observability_pipelines_delete","observability_pipelines_deploy","processes_generate_metrics","api_keys_delete","agent_flare_collection","org_connections_write","org_connections_read","facets_write","security_monitoring_suppressions_read","security_monitoring_suppressions_write","static_analysis_settings_write","create_webhooks","cd_visibility_read","ndm_netflow_port_mappings_write","appsec_vm_read","debugger_capture_variables","error_tracking_settings_write","error_tracking_exclusion_filters_write","integrations_read","apm_api_catalog_write","apm_api_catalog_read","containers_generate_image_metrics","rum_extend_retention","on_prem_runner_read","on_prem_runner_use","on_prem_runner_write","dora_settings_write","agent_upgrade_write","continuous_profiler_pgo_read","oci_configurations_manage","aws_configuration_read","azure_configuration_read","gcp_configuration_read","oci_configuration_read","hosts_read","aws_configuration_edit","azure_configuration_edit","gcp_configuration_edit","oci_configuration_edit","llm_observability_read","flex_logs_config_write","reference_tables_read","fleet_policies_write","orchestration_custom_resource_definitions_write","code_analysis_read","orchestration_workload_scaling_write","llm_observability_write","observability_pipelines_capture_read","observability_pipelines_capture_write","apps_datastore_read","apps_datastore_write","apps_datastore_manage","security_pipelines_read","security_pipelines_write","connection_groups_write","quality_gates_evaluations_read","connection_groups_read","security_monitoring_cws_agent_rules_actions","rum_retention_filters_read","rum_retention_filters_write","ddsql_editor_read","disaster_recovery_status_read","disaster_recovery_status_write","rum_settings_write","test_optimization_read","test_optimization_write","test_optimization_settings_write","security_comments_write","security_comments_read","dashboards_invite_share","dashboards_embed_share","embeddable_graphs_share","logs_read_workspaces","logs_write_workspaces","audience_management_read","audience_management_write","logs_read_config","on_call_read","on_call_write","on_call_page","dora_metrics_read","error_tracking_read","on_call_respond","process_tags_read","process_tags_write","network_connections_read","serverless_aws_instrumentation_read","serverless_aws_instrumentation_write","coterm_write","coterm_read","data_streams_monitoring_capture_messages","cloudcraft_read","ndm_device_profiles_view","ndm_device_profiles_edit","generate_log_reports","manage_log_reports","ndm_devices_read","ndm_device_tags_write","bits_investigations_read","sheets_read","sheets_write","status_pages_settings_read","status_pages_settings_write","status_pages_incident_write","on_call_admin","orchestration_autoscaling_manage","code_coverage_read","cases_shared_settings_write","repo_info_read","repo_settings_write","product_analytics_apps_write","actions_interface_run","ai_guard_evaluate","generate_ccm_report_schedules","manage_ccm_report_schedules","user_self_profile_read","governance_console_read","data_scanner_unmask","apps_form_read","apps_form_manage","user_self_profile_write","dora_metrics_write","bits_investigations_write","debugger_write_pre_prod","network_health_insights_read","security_monitoring_datasets_read","security_monitoring_datasets_write","feature_flag_config_write","feature_flag_config_read","feature_flag_environment_config_write","feature_flag_environment_config_read","assistant_access","dbm_read","ndm_geomap_locations_write","ndm_device_config_read","dbm_parameterized_queries_read","apm_service_renaming_write","deployment_gates_read","deployment_gates_write","deployment_gates_evaluate","product_analytics_saved_widgets_read","product_analytics_saved_widgets_write","mcp_write","mcp_read","external_provider_status_notifications_read","external_provider_status_notifications_write","governance_console_write","bits_security_analyst_write","bits_security_analyst_config_write","feature_flag_approvals_override","infrastructure_resource_policies_read","infrastructure_resource_policies_write","agent_builder_read","agent_builder_write","agent_builder_run","bits_dev_write","product_analytics_settings_read","product_analytics_settings_write","product_analytics_experiments_read","product_analytics_experiments_write","product_analytics_metrics_read","product_analytics_metrics_write","product_analytics_certified_metrics_write","product_analytics_warehouse_model_write","data_streams_kafka_produce_message","org_group_read","org_group_write","apm_recommendations_notification_rules_read","apm_recommendations_notification_rules_write","product_dashboards_write"]},"relationships":{"owned_by":{"data":{"id":"48e5159f-e308-11ef-bcfc-2666505bfd8f","type":"users"}}}},{"id":"717da798-83bd-4f68-8b0a-dfa98c65bddb","type":"personal_access_tokens","attributes":{"created_at":"2026-04-02T20:01:42.043142Z","expires_at":null,"last_used_at":null,"name":"Test-Create_a_service_account_access_token_returns_Created_response-1775160101","public_portion":"3S9YYEuPThXA4AbPGMcqjr","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"c465e3ca-2ece-11f1-b6f0-363c69093c72","type":"users"}}}},{"id":"35ef7728-4761-41dd-8a7b-f1112a26f840","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:46:16.769979Z","expires_at":"2027-04-08T16:46:16.639Z","last_used_at":null,"name":"Test-Get_all_personal_access_tokens_returns_OK_response-1775666776","public_portion":"1dm1op4lL89nV8pt94Tdk8","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}],"meta":{"page":{"total_filtered_count":3}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/35ef7728-4761-41dd-8a7b-f1112a26f840 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.freeze new file mode 100644 index 00000000000..96f3a2ce253 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.freeze @@ -0,0 +1 @@ +2026-04-08T16:45:51.557Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.yaml new file mode 100644 index 00000000000..eb0c05619ce --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Revoke_a_personal_access_token_returns_No_Content_response.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"expires_at":"2027-04-08T16:45:51.557Z","name":"Test-Revoke_a_personal_access_token_returns_No_Content_response-1775666751","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":{"id":"6bebbb55-0f75-4444-bec1-52de5987290f","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:51.638215611Z","expires_at":"2027-04-08T16:45:51.557Z","key":"xxxxx_xxxxxxxxxxxxxxxxxxXxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Revoke_a_personal_access_token_returns_No_Content_response-1775666751","public_portion":"3HduL45lLrtTDsrdaAXE6B","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/6bebbb55-0f75-4444-bec1-52de5987290f + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/6bebbb55-0f75-4444-bec1-52de5987290f + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.freeze new file mode 100644 index 00000000000..0d415665772 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-08T16:45:59.540Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.yaml new file mode 100644 index 00000000000..dcc77371f4d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Key_Management/Scenario_Update_a_personal_access_token_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"expires_at":"2027-04-08T16:45:59.540Z","name":"Test-Update_a_personal_access_token_returns_OK_response-1775666759","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/personal_access_tokens + response: + body: '{"data":{"id":"7d2c1007-41f2-482e-8ee8-a4dab4a5369e","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:59.640614886Z","expires_at":"2027-04-08T16:45:59.54Z","key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Update_a_personal_access_token_returns_OK_response-1775666759","public_portion":"3oCB0TOwLiDNpTdO6FYPq2","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Update_a_personal_access_token_returns_OK_response-1775666759-updated"},"id":"7d2c1007-41f2-482e-8ee8-a4dab4a5369e","type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PATCH + url: https://api.datadoghq.com/api/v2/personal_access_tokens/7d2c1007-41f2-482e-8ee8-a4dab4a5369e + response: + body: '{"data":{"id":"7d2c1007-41f2-482e-8ee8-a4dab4a5369e","type":"personal_access_tokens","attributes":{"created_at":"2026-04-08T16:45:59.640614Z","expires_at":"2027-04-08T16:45:59.54Z","last_used_at":null,"modified_at":"2026-04-08T16:45:59.747202Z","name":"Test-Update_a_personal_access_token_returns_OK_response-1775666759-updated","public_portion":"3oCB0TOwLiDNpTdO6FYPq2","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"users"}}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/personal_access_tokens/7d2c1007-41f2-482e-8ee8-a4dab4a5369e + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.freeze new file mode 100644 index 00000000000..b457d0ec92c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-04-03T21:02:56.793Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.yaml new file mode 100644 index 00000000000..6d2f1538644 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Create_an_access_token_for_a_service_account_returns_Created_response.yaml @@ -0,0 +1,75 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"email":"Test-Create_an_access_token_for_a_service_account_returns_Created_response-1775250176@datadoghq.com","service_account":true,"title":"user title"},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0","attributes":{"name":null,"handle":"7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0","created_at":"2026-04-03T21:02:56.980609+00:00","modified_at":"2026-04-03T21:02:56.980609+00:00","email":"test-create_an_access_token_for_a_service_account_returns_created_response-1775250176@datadoghq.com","icon":"https://secure.gravatar.com/avatar/1a703b50769c96d7b84a5470f474ef74?s=48&d=retro","title":"user + title","verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Create_an_access_token_for_a_service_account_returns_Created_response-1775250176","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts/7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0/access_tokens + response: + body: '{"data":{"id":"6f2491f5-8c3f-45a3-962a-5f769b95e806","type":"personal_access_tokens","attributes":{"alias":"3NirNJ5Y2qB4Fmac8B4wnm","created_at":"2026-04-03T21:02:57.288351972Z","expires_at":null,"key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxXxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Create_an_access_token_for_a_service_account_returns_Created_response-1775250176","public_portion":"3NirNJ5Y2qB4Fmac8B4wnm","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/service_accounts/7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0/access_tokens/6f2491f5-8c3f-45a3-962a-5f769b95e806 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/users/7d5e5ea9-2fa0-11f1-991f-62f4bfc595d0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.freeze new file mode 100644 index 00000000000..55c4828532c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-03T21:03:03.500Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.yaml new file mode 100644 index 00000000000..436e00a25c0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Get_an_access_token_for_a_service_account_returns_OK_response.yaml @@ -0,0 +1,92 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"email":"Test-Get_an_access_token_for_a_service_account_returns_OK_response-1775250183@datadoghq.com","service_account":true,"title":"user title"},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"8161ef90-2fa0-11f1-991f-62f4bfc595d0","attributes":{"name":null,"handle":"8161ef90-2fa0-11f1-991f-62f4bfc595d0","created_at":"2026-04-03T21:03:03.714879+00:00","modified_at":"2026-04-03T21:03:03.714879+00:00","email":"test-get_an_access_token_for_a_service_account_returns_ok_response-1775250183@datadoghq.com","icon":"https://secure.gravatar.com/avatar/bb3c6df0d99066bbe05cf7dff99b5561?s=48&d=retro","title":"user + title","verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Get_an_access_token_for_a_service_account_returns_OK_response-1775250183","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts/8161ef90-2fa0-11f1-991f-62f4bfc595d0/access_tokens + response: + body: '{"data":{"id":"f2362958-1e67-414b-985d-d3196afd9315","type":"personal_access_tokens","attributes":{"alias":"7N2tUOwxIjSF8QziOBIpVd","created_at":"2026-04-03T21:03:04.002376467Z","expires_at":null,"key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Get_an_access_token_for_a_service_account_returns_OK_response-1775250183","public_portion":"7N2tUOwxIjSF8QziOBIpVd","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"8161ef90-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 2 + method: GET + url: https://api.datadoghq.com/api/v2/service_accounts/8161ef90-2fa0-11f1-991f-62f4bfc595d0/access_tokens/f2362958-1e67-414b-985d-d3196afd9315 + response: + body: '{"data":{"id":"f2362958-1e67-414b-985d-d3196afd9315","type":"personal_access_tokens","attributes":{"alias":"7N2tUOwxIjSF8QziOBIpVd","created_at":"2026-04-03T21:03:04.002376Z","expires_at":null,"last_used_at":null,"name":"Test-Get_an_access_token_for_a_service_account_returns_OK_response-1775250183","public_portion":"7N2tUOwxIjSF8QziOBIpVd","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"8161ef90-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/service_accounts/8161ef90-2fa0-11f1-991f-62f4bfc595d0/access_tokens/f2362958-1e67-414b-985d-d3196afd9315 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/users/8161ef90-2fa0-11f1-991f-62f4bfc595d0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.freeze new file mode 100644 index 00000000000..6234af8a3e4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-03T21:03:09.026Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.yaml new file mode 100644 index 00000000000..499e160a9bc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_List_access_tokens_for_a_service_account_returns_OK_response.yaml @@ -0,0 +1,55 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"email":"Test-List_access_tokens_for_a_service_account_returns_OK_response-1775250189@datadoghq.com","service_account":true,"title":"user title"},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"84a7b33b-2fa0-11f1-96b6-7a9b8860a1d7","attributes":{"name":null,"handle":"84a7b33b-2fa0-11f1-96b6-7a9b8860a1d7","created_at":"2026-04-03T21:03:09.205232+00:00","modified_at":"2026-04-03T21:03:09.205232+00:00","email":"test-list_access_tokens_for_a_service_account_returns_ok_response-1775250189@datadoghq.com","icon":"https://secure.gravatar.com/avatar/816e106f74328dd4c20e98c116a9edeb?s=48&d=retro","title":"user + title","verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/service_accounts/84a7b33b-2fa0-11f1-96b6-7a9b8860a1d7/access_tokens + response: + body: '{"data":[],"meta":{"page":{"total_filtered_count":0}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/users/84a7b33b-2fa0-11f1-96b6-7a9b8860a1d7 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.freeze new file mode 100644 index 00000000000..fa38ba91a95 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.freeze @@ -0,0 +1 @@ +2026-04-03T21:03:10.520Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.yaml new file mode 100644 index 00000000000..bd62e41dca8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Revoke_an_access_token_for_a_service_account_returns_No_Content_response.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"email":"Test-Revoke_an_access_token_for_a_service_account_returns_No_Content_response-1775250190@datadoghq.com","service_account":true,"title":"user title"},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"860878b5-2fa0-11f1-991f-62f4bfc595d0","attributes":{"name":null,"handle":"860878b5-2fa0-11f1-991f-62f4bfc595d0","created_at":"2026-04-03T21:03:11.517157+00:00","modified_at":"2026-04-03T21:03:11.517157+00:00","email":"test-revoke_an_access_token_for_a_service_account_returns_no_content_response-1775250190@datadoghq.com","icon":"https://secure.gravatar.com/avatar/7d18813f3cbc71a5e46b1184fc3ad8fb?s=48&d=retro","title":"user + title","verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Revoke_an_access_token_for_a_service_account_returns_No_Content_response-1775250190","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts/860878b5-2fa0-11f1-991f-62f4bfc595d0/access_tokens + response: + body: '{"data":{"id":"7346d75b-83f3-48ba-9186-899fc80bce16","type":"personal_access_tokens","attributes":{"alias":"3VWUVmuRsjFIKue2Uq9ii6","created_at":"2026-04-03T21:03:11.782016283Z","expires_at":null,"key":"xxxxx_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Revoke_an_access_token_for_a_service_account_returns_No_Content_response-1775250190","public_portion":"3VWUVmuRsjFIKue2Uq9ii6","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"860878b5-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/service_accounts/860878b5-2fa0-11f1-991f-62f4bfc595d0/access_tokens/7346d75b-83f3-48ba-9186-899fc80bce16 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/service_accounts/860878b5-2fa0-11f1-991f-62f4bfc595d0/access_tokens/7346d75b-83f3-48ba-9186-899fc80bce16 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/users/860878b5-2fa0-11f1-991f-62f4bfc595d0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.freeze new file mode 100644 index 00000000000..6a894d59da1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-04-03T21:03:12.499Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.yaml new file mode 100644 index 00000000000..863ff33c1b9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Service_Accounts/Scenario_Update_an_access_token_for_a_service_account_returns_OK_response.yaml @@ -0,0 +1,95 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"email":"Test-Update_an_access_token_for_a_service_account_returns_OK_response-1775250192@datadoghq.com","service_account":true,"title":"user title"},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts + response: + body: '{"data":{"type":"users","id":"86bdf0d7-2fa0-11f1-991f-62f4bfc595d0","attributes":{"name":null,"handle":"86bdf0d7-2fa0-11f1-991f-62f4bfc595d0","created_at":"2026-04-03T21:03:12.706435+00:00","modified_at":"2026-04-03T21:03:12.706435+00:00","email":"test-update_an_access_token_for_a_service_account_returns_ok_response-1775250192@datadoghq.com","icon":"https://secure.gravatar.com/avatar/8ef25c203ebdbe5e11acb74bd99ba7da?s=48&d=retro","title":"user + title","verified":true,"service_account":true,"disabled":false,"allowed_login_methods":[],"status":"Active","last_login_time":null},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + + ' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Update_an_access_token_for_a_service_account_returns_OK_response-1775250192","scopes":["dashboards_read"]},"type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/service_accounts/86bdf0d7-2fa0-11f1-991f-62f4bfc595d0/access_tokens + response: + body: '{"data":{"id":"9a7d27cc-4969-4a57-990c-03c23a9f2adc","type":"personal_access_tokens","attributes":{"alias":"4hW0tyOpjf5Dj84mZaXqwe","created_at":"2026-04-03T21:03:12.978132411Z","expires_at":null,"key":"xxxxx_xxxxxxxxxxxxxxxxxxXxxx_xxxxxXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","name":"Test-Update_an_access_token_for_a_service_account_returns_OK_response-1775250192","public_portion":"4hW0tyOpjf5Dj84mZaXqwe","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"86bdf0d7-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"name":"Test-Update_an_access_token_for_a_service_account_returns_OK_response-1775250192-updated"},"id":"9a7d27cc-4969-4a57-990c-03c23a9f2adc","type":"personal_access_tokens"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 2 + method: PATCH + url: https://api.datadoghq.com/api/v2/service_accounts/86bdf0d7-2fa0-11f1-991f-62f4bfc595d0/access_tokens/9a7d27cc-4969-4a57-990c-03c23a9f2adc + response: + body: '{"data":{"id":"9a7d27cc-4969-4a57-990c-03c23a9f2adc","type":"personal_access_tokens","attributes":{"alias":"4hW0tyOpjf5Dj84mZaXqwe","created_at":"2026-04-03T21:03:12.978132Z","expires_at":null,"last_used_at":null,"modified_at":"2026-04-03T21:03:13.152078Z","name":"Test-Update_an_access_token_for_a_service_account_returns_OK_response-1775250192-updated","public_portion":"4hW0tyOpjf5Dj84mZaXqwe","scopes":["dashboards_read"]},"relationships":{"owned_by":{"data":{"id":"86bdf0d7-2fa0-11f1-991f-62f4bfc595d0","type":"users"}}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/service_accounts/86bdf0d7-2fa0-11f1-991f-62f4bfc595d0/access_tokens/9a7d27cc-4969-4a57-990c-03c23a9f2adc + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 4 + method: DELETE + url: https://api.datadoghq.com/api/v2/users/86bdf0d7-2fa0-11f1-991f-62f4bfc595d0 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 7782d060c2e..303db68e6b3 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -986,6 +986,18 @@ "tag": "Roles", "operationId": "ListPermissions" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"scopes\": [\"dashboards_read\"],\n \"expires_at\": \"{{ timeISO('now+365d') }}\"\n },\n \"type\": \"personal_access_tokens\"\n }\n}" + } + ], + "step": "there is a valid \"personal_access_token\" in the system", + "key": "personal_access_token", + "tag": "Key Management", + "operationId": "CreatePersonalAccessToken" + }, { "parameters": [ { @@ -1300,6 +1312,22 @@ "tag": "Service Accounts", "operationId": "CreateServiceAccount" }, + { + "parameters": [ + { + "name": "service_account_id", + "value": "\"{{ service_account_user.data.id }}\"" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"scopes\": [\"dashboards_read\"]\n },\n \"type\": \"personal_access_tokens\"\n }\n}" + } + ], + "step": "there is a valid \"service_account_access_token\" for \"service_account_user\"", + "key": "service_account_access_token", + "tag": "Service Accounts", + "operationId": "CreateServiceAccountAccessToken" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/key_management.feature b/tests/scenarios/features/v2/key_management.feature index 40daf9df54f..6c464845562 100644 --- a/tests/scenarios/features/v2/key_management.feature +++ b/tests/scenarios/features/v2/key_management.feature @@ -12,6 +12,24 @@ Feature: Key Management And a valid "appKeyAuth" key in the system And an instance of "KeyManagement" API + @generated @skip @team:DataDog/credentials-management + Scenario: Create a personal access token returns "Bad Request" response + Given new "CreatePersonalAccessToken" request + And body with value {"data": {"attributes": {"expires_at": "2025-12-31T23:59:59+00:00", "name": "My Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/credentials-management + Scenario: Create a personal access token returns "Created" response + Given new "CreatePersonalAccessToken" request + And body with value {"data": {"type": "personal_access_tokens", "attributes": {"name": "{{ unique }}", "scopes": ["dashboards_read"], "expires_at": "{{ timeISO('now+365d') }}"}}} + When the request is sent + Then the response status is 201 Created + And the response "data.type" is equal to "personal_access_tokens" + And the response "data.attributes.name" is equal to "{{ unique }}" + And the response "data.attributes.scopes" is equal to ["dashboards_read"] + And the response "data.attributes" has field "key" + @generated @skip @team:DataDog/credentials-management Scenario: Create an API key returns "Bad Request" response Given new "CreateAPIKey" request @@ -200,6 +218,23 @@ Feature: Key Management And the response "data.id" is equal to "{{ api_key.data.id }}" And the response "data.attributes" has field "date_last_used" + @generated @skip @team:DataDog/credentials-management + Scenario: Get a personal access token returns "Not Found" response + Given new "GetPersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/credentials-management + Scenario: Get a personal access token returns "OK" response + Given there is a valid "personal_access_token" in the system + And new "GetPersonalAccessToken" request + And request contains "pat_uuid" parameter from "personal_access_token.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "personal_access_tokens" + And the response "data.id" has the same value as "personal_access_token.data.id" + @generated @skip @team:DataDog/credentials-management Scenario: Get all API keys returns "Bad Request" response Given new "ListAPIKeys" request @@ -257,6 +292,20 @@ Feature: Key Management And the response "data[0].type" is equal to "application_keys" And the response "data[0].attributes" has field "last_used_at" + @generated @skip @team:DataDog/credentials-management + Scenario: Get all personal access tokens returns "Bad Request" response + Given new "ListPersonalAccessTokens" request + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/credentials-management + Scenario: Get all personal access tokens returns "OK" response + Given there is a valid "personal_access_token" in the system + And new "ListPersonalAccessTokens" request + When the request is sent + Then the response status is 200 OK + And the response "data" has item with field "type" with value "personal_access_tokens" + @generated @skip @team:DataDog/credentials-management Scenario: Get an application key returns "Bad Request" response Given new "GetApplicationKey" request @@ -301,3 +350,44 @@ Feature: Key Management And the response "data.attributes.name" is equal to "{{ application_key.data.attributes.name }}" And the response "data.attributes" has field "scopes" And the response "data.attributes" has field "last_used_at" + + @team:DataDog/credentials-management + Scenario: Revoke a personal access token returns "No Content" response + Given there is a valid "personal_access_token" in the system + And new "RevokePersonalAccessToken" request + And request contains "pat_uuid" parameter from "personal_access_token.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke a personal access token returns "Not Found" response + Given new "RevokePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Update a personal access token returns "Bad Request" response + Given new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Update a personal access token returns "Not Found" response + Given new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/credentials-management + Scenario: Update a personal access token returns "OK" response + Given there is a valid "personal_access_token" in the system + And new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "personal_access_token.data.id" + And body with value {"data": {"type": "personal_access_tokens", "id": "{{ personal_access_token.data.id }}", "attributes": {"name": "{{ unique }}-updated"}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "{{ unique }}-updated" diff --git a/tests/scenarios/features/v2/service_accounts.feature b/tests/scenarios/features/v2/service_accounts.feature index 12976f5ebce..25744abc832 100644 --- a/tests/scenarios/features/v2/service_accounts.feature +++ b/tests/scenarios/features/v2/service_accounts.feature @@ -29,6 +29,34 @@ Feature: Service Accounts And the response "data.attributes.service_account" is equal to true And the response "data.relationships.roles.data[0].id" is equal to "{{ role.data.id }}" + @generated @skip @team:DataDog/credentials-management + Scenario: Create an access token for a service account returns "Bad Request" response + Given new "CreateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expires_at": "2025-12-31T23:59:59+00:00", "name": "Service Account Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/credentials-management + Scenario: Create an access token for a service account returns "Created" response + Given there is a valid "service_account_user" in the system + And new "CreateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "service_account_user.data.id" + And body with value {"data": {"type": "personal_access_tokens", "attributes": {"name": "{{ unique }}", "scopes": ["dashboards_read"]}}} + When the request is sent + Then the response status is 201 Created + And the response "data.type" is equal to "personal_access_tokens" + And the response "data.attributes.name" is equal to "{{ unique }}" + And the response "data.relationships.owned_by.data.id" has the same value as "service_account_user.data.id" + + @generated @skip @team:DataDog/credentials-management + Scenario: Create an access token for a service account returns "Not Found" response + Given new "CreateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"expires_at": "2025-12-31T23:59:59+00:00", "name": "Service Account Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/credentials-management @team:DataDog/org-management Scenario: Create an application key for this service account returns "Bad Request" response Given new "CreateServiceAccountApplicationKey" request @@ -110,6 +138,27 @@ Feature: Service Accounts And the response "data.type" is equal to "application_keys" And the response "data.id" is equal to "{{ service_account_application_key.data.id }}" + @generated @skip @team:DataDog/credentials-management + Scenario: Get an access token for a service account returns "Not Found" response + Given new "GetServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/credentials-management + Scenario: Get an access token for a service account returns "OK" response + Given there is a valid "service_account_user" in the system + And there is a valid "service_account_access_token" for "service_account_user" + And new "GetServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "service_account_user.data.id" + And request contains "pat_uuid" parameter from "service_account_access_token.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" has the same value as "service_account_access_token.data.attributes.name" + And the response "data.type" is equal to "personal_access_tokens" + And the response "data.id" is equal to "{{ service_account_access_token.data.id }}" + @generated @skip @team:DataDog/credentials-management @team:DataDog/org-management Scenario: Get one application key for this service account returns "Not Found" response Given new "GetServiceAccountApplicationKey" request @@ -131,6 +180,29 @@ Feature: Service Accounts And the response "data.type" is equal to "application_keys" And the response "data.id" is equal to "{{ service_account_application_key.data.id }}" + @generated @skip @team:DataDog/credentials-management + Scenario: List access tokens for a service account returns "Bad Request" response + Given new "ListServiceAccountAccessTokens" request + And request contains "service_account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: List access tokens for a service account returns "Not Found" response + Given new "ListServiceAccountAccessTokens" request + And request contains "service_account_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/credentials-management + Scenario: List access tokens for a service account returns "OK" response + Given there is a valid "service_account_user" in the system + And new "ListServiceAccountAccessTokens" request + And request contains "service_account_id" parameter from "service_account_user.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 0 + @generated @skip @team:DataDog/credentials-management @team:DataDog/org-management Scenario: List application keys for this service account returns "Bad Request" response Given new "ListServiceAccountApplicationKeys" request @@ -153,3 +225,53 @@ Feature: Service Accounts When the request is sent Then the response status is 200 OK And the response "data" has length 0 + + @team:DataDog/credentials-management + Scenario: Revoke an access token for a service account returns "No Content" response + Given there is a valid "service_account_user" in the system + And there is a valid "service_account_access_token" for "service_account_user" + And new "RevokeServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "service_account_user.data.id" + And request contains "pat_uuid" parameter from "service_account_access_token.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke an access token for a service account returns "Not Found" response + Given new "RevokeServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Update an access token for a service account returns "Bad Request" response + Given new "UpdateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Update an access token for a service account returns "Not Found" response + Given new "UpdateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "REPLACE.ME" + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/credentials-management + Scenario: Update an access token for a service account returns "OK" response + Given there is a valid "service_account_user" in the system + And there is a valid "service_account_access_token" for "service_account_user" + And new "UpdateServiceAccountAccessToken" request + And request contains "service_account_id" parameter from "service_account_user.data.id" + And request contains "pat_uuid" parameter from "service_account_access_token.data.id" + And body with value {"data": {"id": "{{ service_account_access_token.data.id }}", "type": "personal_access_tokens", "attributes": {"name": "{{ service_account_access_token.data.attributes.name }}-updated"}}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.name" is equal to "{{ service_account_access_token.data.attributes.name }}-updated" + And the response "data.type" is equal to "personal_access_tokens" + And the response "data.id" is equal to "{{ service_account_access_token.data.id }}" diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 21caf3f3290..bb84d5c5e03 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -4257,6 +4257,43 @@ "type": "safe" } }, + "ListPersonalAccessTokens": { + "tag": "Key Management", + "undo": { + "type": "safe" + } + }, + "CreatePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "operationId": "RevokePersonalAccessToken", + "parameters": [ + { + "name": "pat_uuid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "RevokePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, + "GetPersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "safe" + } + }, + "UpdatePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, "ListFindings": { "tag": "Security Monitoring", "undo": { @@ -5739,6 +5776,47 @@ "type": "unsafe" } }, + "ListServiceAccountAccessTokens": { + "tag": "Service Accounts", + "undo": { + "type": "safe" + } + }, + "CreateServiceAccountAccessToken": { + "tag": "Service Accounts", + "undo": { + "operationId": "RevokeServiceAccountAccessToken", + "parameters": [ + { + "name": "service_account_id", + "source": "data.relationships.owned_by.data.id" + }, + { + "name": "pat_uuid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "RevokeServiceAccountAccessToken": { + "tag": "Service Accounts", + "undo": { + "type": "idempotent" + } + }, + "GetServiceAccountAccessToken": { + "tag": "Service Accounts", + "undo": { + "type": "safe" + } + }, + "UpdateServiceAccountAccessToken": { + "tag": "Service Accounts", + "undo": { + "type": "idempotent" + } + }, "ListServiceAccountApplicationKeys": { "tag": "Service Accounts", "undo": {