From 685dd371d7e44ab06bbc0a89ec7ad023bf1b6122 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 27 Nov 2025 10:05:46 +0000 Subject: [PATCH] Regenerate client from commit f1a395c of spec repo --- .generator/schemas/v2/openapi.yaml | 734 ++++++++++++ api/datadog/configuration.go | 11 + api/datadogV2/api_logs_restriction_queries.go | 1043 +++++++++++++++++ api/datadogV2/doc.go | 11 + .../model_logs_restriction_queries_type.go | 64 + .../model_restriction_query_attributes.go | 322 +++++ ...del_restriction_query_create_attributes.go | 101 ++ .../model_restriction_query_create_data.go | 154 +++ .../model_restriction_query_create_payload.go | 111 ++ .../model_restriction_query_list_response.go | 102 ++ ...estriction_query_response_included_item.go | 73 ++ api/datadogV2/model_restriction_query_role.go | 180 +++ .../model_restriction_query_role_attribute.go | 102 ++ .../model_restriction_query_roles_response.go | 102 ++ ...del_restriction_query_update_attributes.go | 101 ++ .../model_restriction_query_update_data.go | 154 +++ .../model_restriction_query_update_payload.go | 111 ++ ...el_restriction_query_with_relationships.go | 227 ++++ ...ction_query_with_relationships_response.go | 146 +++ ...restriction_query_without_relationships.go | 181 +++ ...on_query_without_relationships_response.go | 111 ++ .../AddRoleToRestrictionQuery.go | 38 + .../CreateRestrictionQuery.go | 38 + .../DeleteRestrictionQuery.go | 29 + .../GetRestrictionQuery.go | 33 + .../GetRoleRestrictionQuery.go | 33 + .../ListRestrictionQueries.go | 30 + .../ListRestrictionQueryRoles.go | 33 + .../ListUserRestrictionQueries.go | 33 + .../RemoveRoleFromRestrictionQuery.go | 38 + .../ReplaceRestrictionQuery.go | 41 + .../UpdateRestrictionQuery.go | 41 + tests/scenarios/api_mappings.go | 1 + ..._query_returns_Bad_Request_response.freeze | 1 + ...on_query_returns_Bad_Request_response.yaml | 23 + ...striction_query_returns_OK_response.freeze | 1 + ...restriction_query_returns_OK_response.yaml | 41 + ..._query_returns_Bad_Request_response.freeze | 1 + ...on_query_returns_Bad_Request_response.yaml | 19 + ...on_query_returns_Not_found_response.freeze | 1 + ...tion_query_returns_Not_found_response.yaml | 19 + ...striction_query_returns_OK_response.freeze | 1 + ...restriction_query_returns_OK_response.yaml | 58 + ..._query_returns_Bad_Request_response.freeze | 1 + ...on_query_returns_Bad_Request_response.yaml | 19 + ...on_query_returns_Not_found_response.freeze | 1 + ...tion_query_returns_Not_found_response.yaml | 19 + ...striction_query_returns_OK_response.freeze | 1 + ...restriction_query_returns_OK_response.yaml | 60 + ...n_user_returns_Bad_Request_response.freeze | 1 + ...ven_user_returns_Bad_Request_response.yaml | 19 + ...ven_user_returns_Not_found_response.freeze | 1 + ...given_user_returns_Not_found_response.yaml | 20 + ...n_role_returns_Bad_Request_response.freeze | 1 + ...ven_role_returns_Bad_Request_response.yaml | 19 + ...ven_role_returns_Not_found_response.freeze | 1 + ...given_role_returns_Not_found_response.yaml | 19 + ...or_a_given_role_returns_OK_response.freeze | 1 + ..._for_a_given_role_returns_OK_response.yaml | 56 + ..._query_returns_Bad_Request_response.freeze | 1 + ...on_query_returns_Bad_Request_response.yaml | 22 + ...on_query_returns_Not_found_response.freeze | 1 + ...tion_query_returns_Not_found_response.yaml | 22 + ...striction_query_returns_OK_response.freeze | 1 + ...restriction_query_returns_OK_response.yaml | 96 ++ ...riction_queries_returns_OK_response.freeze | 1 + ...striction_queries_returns_OK_response.yaml | 21 + ..._query_returns_Bad_Request_response.freeze | 1 + ...on_query_returns_Bad_Request_response.yaml | 19 + ...on_query_returns_Not_found_response.freeze | 1 + ...tion_query_returns_Not_found_response.yaml | 19 + ...striction_query_returns_OK_response.freeze | 1 + ...restriction_query_returns_OK_response.yaml | 60 + tests/scenarios/features/v2/given.json | 12 + .../v2/logs_restriction_queries.feature | 287 +++++ tests/scenarios/features/v2/undo.json | 73 ++ 76 files changed, 5571 insertions(+) create mode 100644 api/datadogV2/api_logs_restriction_queries.go create mode 100644 api/datadogV2/model_logs_restriction_queries_type.go create mode 100644 api/datadogV2/model_restriction_query_attributes.go create mode 100644 api/datadogV2/model_restriction_query_create_attributes.go create mode 100644 api/datadogV2/model_restriction_query_create_data.go create mode 100644 api/datadogV2/model_restriction_query_create_payload.go create mode 100644 api/datadogV2/model_restriction_query_list_response.go create mode 100644 api/datadogV2/model_restriction_query_response_included_item.go create mode 100644 api/datadogV2/model_restriction_query_role.go create mode 100644 api/datadogV2/model_restriction_query_role_attribute.go create mode 100644 api/datadogV2/model_restriction_query_roles_response.go create mode 100644 api/datadogV2/model_restriction_query_update_attributes.go create mode 100644 api/datadogV2/model_restriction_query_update_data.go create mode 100644 api/datadogV2/model_restriction_query_update_payload.go create mode 100644 api/datadogV2/model_restriction_query_with_relationships.go create mode 100644 api/datadogV2/model_restriction_query_with_relationships_response.go create mode 100644 api/datadogV2/model_restriction_query_without_relationships.go create mode 100644 api/datadogV2/model_restriction_query_without_relationships_response.go create mode 100644 examples/v2/logs-restriction-queries/AddRoleToRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/CreateRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/DeleteRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/GetRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/GetRoleRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/ListRestrictionQueries.go create mode 100644 examples/v2/logs-restriction-queries/ListRestrictionQueryRoles.go create mode 100644 examples/v2/logs-restriction-queries/ListUserRestrictionQueries.go create mode 100644 examples/v2/logs-restriction-queries/RemoveRoleFromRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/ReplaceRestrictionQuery.go create mode 100644 examples/v2/logs-restriction-queries/UpdateRestrictionQuery.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.yaml create mode 100644 tests/scenarios/features/v2/logs_restriction_queries.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb715496..be2fed88a24 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -945,6 +945,27 @@ components: required: true schema: type: string + RestrictionQueryID: + description: The ID of the restriction query. + in: path + name: restriction_query_id + required: true + schema: + type: string + RestrictionQueryRoleID: + description: The ID of the role. + in: path + name: role_id + required: true + schema: + type: string + RestrictionQueryUserID: + description: The ID of the user. + in: path + name: user_id + required: true + schema: + type: string RetentionFilterIdParam: description: The ID of the retention filter. in: path @@ -30501,6 +30522,15 @@ components: example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== type: string type: object + LogsRestrictionQueriesType: + default: logs_restriction_queries + description: Restriction query resource type. + enum: + - logs_restriction_queries + example: logs_restriction_queries + type: string + x-enum-varnames: + - LOGS_RESTRICTION_QUERIES LogsSort: description: Sort parameters when querying logs. enum: @@ -41838,6 +41868,191 @@ components: required: - data type: object + RestrictionQueryAttributes: + description: Attributes of the restriction query. + properties: + created_at: + description: Creation time of the restriction query. + example: '2020-03-17T21:06:44.000Z' + format: date-time + readOnly: true + type: string + last_modifier_email: + description: Email of the user who last modified this restriction query. + example: user@example.com + readOnly: true + type: string + last_modifier_name: + description: Name of the user who last modified this restriction query. + example: John Doe + readOnly: true + type: string + modified_at: + description: Time of last restriction query modification. + example: '2020-03-17T21:15:15.000Z' + format: date-time + readOnly: true + type: string + restriction_query: + description: The query that defines the restriction. Only the content matching + the query can be returned. + example: env:sandbox + type: string + role_count: + description: Number of roles associated with this restriction query. + example: 3 + format: int64 + readOnly: true + type: integer + user_count: + description: Number of users associated with this restriction query. + example: 5 + format: int64 + readOnly: true + type: integer + type: object + RestrictionQueryCreateAttributes: + description: Attributes of the created restriction query. + properties: + restriction_query: + description: The restriction query. + example: env:sandbox + type: string + required: + - restriction_query + type: object + RestrictionQueryCreateData: + description: Data related to the creation of a restriction query. + properties: + attributes: + $ref: '#/components/schemas/RestrictionQueryCreateAttributes' + type: + $ref: '#/components/schemas/LogsRestrictionQueriesType' + type: object + RestrictionQueryCreatePayload: + description: Create a restriction query. + properties: + data: + $ref: '#/components/schemas/RestrictionQueryCreateData' + type: object + RestrictionQueryListResponse: + description: Response containing information about multiple restriction queries. + properties: + data: + description: Array of returned restriction queries. + items: + $ref: '#/components/schemas/RestrictionQueryWithoutRelationships' + type: array + type: object + RestrictionQueryResponseIncludedItem: + description: An object related to a restriction query. + oneOf: + - $ref: '#/components/schemas/RestrictionQueryRole' + RestrictionQueryRole: + description: Partial role object. + properties: + attributes: + $ref: '#/components/schemas/RestrictionQueryRoleAttribute' + id: + description: ID of the role. + example: + type: string + type: + $ref: '#/components/schemas/RolesType' + required: + - type + - id + - attributes + type: object + RestrictionQueryRoleAttribute: + description: Attributes of the role for a restriction query. + properties: + name: + description: The role name. + example: Datadog Admin Role + type: string + type: object + RestrictionQueryRolesResponse: + description: Response containing information about roles attached to a restriction + query. + properties: + data: + description: Array of roles. + items: + $ref: '#/components/schemas/RestrictionQueryRole' + type: array + type: object + RestrictionQueryUpdateAttributes: + description: Attributes of the edited restriction query. + properties: + restriction_query: + description: The restriction query. + example: env:sandbox + type: string + required: + - restriction_query + type: object + RestrictionQueryUpdateData: + description: Data related to the update of a restriction query. + properties: + attributes: + $ref: '#/components/schemas/RestrictionQueryUpdateAttributes' + type: + $ref: '#/components/schemas/LogsRestrictionQueriesType' + type: object + RestrictionQueryUpdatePayload: + description: Update a restriction query. + properties: + data: + $ref: '#/components/schemas/RestrictionQueryUpdateData' + type: object + RestrictionQueryWithRelationships: + description: Restriction query object returned by the API. + properties: + attributes: + $ref: '#/components/schemas/RestrictionQueryAttributes' + id: + description: ID of the restriction query. + example: 79a0e60a-644a-11ea-ad29-43329f7f58b5 + type: string + relationships: + $ref: '#/components/schemas/UserRelationships' + type: + $ref: '#/components/schemas/LogsRestrictionQueriesType' + type: object + RestrictionQueryWithRelationshipsResponse: + description: Response containing information about a single restriction query. + properties: + data: + $ref: '#/components/schemas/RestrictionQueryWithRelationships' + included: + description: Array of objects related to the restriction query. + items: + $ref: '#/components/schemas/RestrictionQueryResponseIncludedItem' + type: array + type: object + RestrictionQueryWithoutRelationships: + description: Restriction query object returned by the API. + properties: + attributes: + $ref: '#/components/schemas/RestrictionQueryAttributes' + id: + description: ID of the restriction query. + example: 79a0e60a-644a-11ea-ad29-43329f7f58b5 + type: string + type: + default: logs_restriction_queries + description: Restriction queries type. + example: logs_restriction_queries + readOnly: true + type: string + type: object + RestrictionQueryWithoutRelationshipsResponse: + description: Response containing information about a single restriction query. + properties: + data: + $ref: '#/components/schemas/RestrictionQueryWithoutRelationships' + type: object RetentionFilter: description: The definition of the retention filter. properties: @@ -70264,6 +70479,487 @@ paths: operator: OR permissions: - logs_generate_metrics + /api/v2/logs/config/restriction_queries: + get: + description: Returns all restriction queries, including their names and IDs. + operationId: ListRestrictionQueries + parameters: + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryListResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List restriction queries + tags: + - Logs Restriction Queries + x-permission: + operator: OR + permissions: + - logs_read_config + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new restriction query for your organization. + operationId: CreateRestrictionQuery + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryCreatePayload' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryWithoutRelationshipsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/logs/config/restriction_queries/role/{role_id}: + get: + description: Get restriction query for a given role. + operationId: GetRoleRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryRoleID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryListResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get restriction query for a given role + tags: + - Logs Restriction Queries + x-permission: + operator: OR + permissions: + - logs_read_config + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/logs/config/restriction_queries/user/{user_id}: + get: + description: Get all restriction queries for a given user. + operationId: ListUserRestrictionQueries + parameters: + - $ref: '#/components/parameters/RestrictionQueryUserID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryListResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get all restriction queries for a given user + tags: + - Logs Restriction Queries + x-permission: + operator: OR + permissions: + - logs_read_config + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/logs/config/restriction_queries/{restriction_query_id}: + delete: + description: Deletes a restriction query. + operationId: DeleteRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + responses: + '204': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a restriction query in the organization specified by the restriction + query's `restriction_query_id`. + operationId: GetRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryWithRelationshipsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - logs_read_config + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Edit a restriction query. + operationId: UpdateRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryUpdatePayload' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryWithoutRelationshipsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Replace a restriction query. + operationId: ReplaceRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryUpdatePayload' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryWithoutRelationshipsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Replace a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/logs/config/restriction_queries/{restriction_query_id}/roles: + delete: + description: Removes a role from a restriction query. + operationId: RemoveRoleFromRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RelationshipToRole' + required: true + responses: + '204': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Revoke role from a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Returns all roles that have a given restriction query. + operationId: ListRestrictionQueryRoles + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/RestrictionQueryRolesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List roles for a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - logs_read_config + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: 'Adds a role to a restriction query. + + + **Note**: This operation automatically grants the `logs_read_data` permission + to the role if it doesn''t already have it.' + operationId: AddRoleToRestrictionQuery + parameters: + - $ref: '#/components/parameters/RestrictionQueryID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RelationshipToRole' + required: true + responses: + '204': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication error + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Grant role to a restriction query + tags: + - Logs Restriction Queries + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - user_access_manage + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/logs/events: get: description: 'List endpoint returns logs that match a log search query. @@ -85210,6 +85906,44 @@ tags: description: Find out more at url: https://docs.datadoghq.com/logs/logs_to_metrics/ name: Logs Metrics +- description: '**Note: This endpoint is in public beta. If you have any feedback, + contact [Datadog support](https://docs.datadoghq.com/help/).** + + + A Restriction Query is a logs query that restricts which logs the `logs_read_data` + permission grants read access to. + + For users whose roles have Restriction Queries, any log query they make only returns + those log events that also match + + one of their Restriction Queries. This is true whether the user queries log events + from any log-related feature, including + + the log explorer, Live Tail, re-hydration, or a dashboard widget. + + + Restriction Queries currently only support use of the following components of + log events: + + + - Reserved attributes + + - The log message + + - Tags + + + To restrict read access on log data, add a team tag to log events to indicate + which teams own them, and then scope Restriction Queries to the relevant values + of the team tag. Tags can be applied to log events in many ways, and a log event + can have multiple tags with the same key (like team) and different values. This + means the same log event can be visible to roles whose restriction queries are + scoped to different team values. + + + See [How to Set Up RBAC for Logs](https://docs.datadoghq.com/logs/guide/logs-rbac/?tab=api#restrict-access-to-logs) + for details on how to add restriction queries.' + name: Logs Restriction Queries - description: "The metrics endpoint allows you to:\n\n- Post metrics data so it can be graphed on Datadog\u2019s dashboards\n- Query metrics from any time period (timeseries and scalar)\n- Modify tag configurations for metrics\n- View tags diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 04693dd2f2c..041334c441d 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -690,6 +690,17 @@ func NewConfiguration() *Configuration { "v2.UpdateIncidentNotificationTemplate": false, "v2.UpdateIncidentTodo": false, "v2.UpdateIncidentType": false, + "v2.AddRoleToRestrictionQuery": false, + "v2.CreateRestrictionQuery": false, + "v2.DeleteRestrictionQuery": false, + "v2.GetRestrictionQuery": false, + "v2.GetRoleRestrictionQuery": false, + "v2.ListRestrictionQueries": false, + "v2.ListRestrictionQueryRoles": false, + "v2.ListUserRestrictionQueries": false, + "v2.RemoveRoleFromRestrictionQuery": false, + "v2.ReplaceRestrictionQuery": false, + "v2.UpdateRestrictionQuery": false, "v2.CreateMonitorUserTemplate": false, "v2.DeleteMonitorUserTemplate": false, "v2.GetMonitorUserTemplate": false, diff --git a/api/datadogV2/api_logs_restriction_queries.go b/api/datadogV2/api_logs_restriction_queries.go new file mode 100644 index 00000000000..33ba5b9d725 --- /dev/null +++ b/api/datadogV2/api_logs_restriction_queries.go @@ -0,0 +1,1043 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// LogsRestrictionQueriesApi service type +type LogsRestrictionQueriesApi datadog.Service + +// AddRoleToRestrictionQuery Grant role to a restriction query. +// Adds a role to a restriction query. +// +// **Note**: This operation automatically grants the `logs_read_data` permission to the role if it doesn't already have it. +func (a *LogsRestrictionQueriesApi) AddRoleToRestrictionQuery(ctx _context.Context, restrictionQueryId string, body RelationshipToRole) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + ) + + operationId := "v2.AddRoleToRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.AddRoleToRestrictionQuery") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 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 +} + +// CreateRestrictionQuery Create a restriction query. +// Create a new restriction query for your organization. +func (a *LogsRestrictionQueriesApi) CreateRestrictionQuery(ctx _context.Context, body RestrictionQueryCreatePayload) (RestrictionQueryWithoutRelationshipsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue RestrictionQueryWithoutRelationshipsResponse + ) + + operationId := "v2.CreateRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.CreateRestrictionQuery") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries" + + 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 +} + +// DeleteRestrictionQuery Delete a restriction query. +// Deletes a restriction query. +func (a *LogsRestrictionQueriesApi) DeleteRestrictionQuery(ctx _context.Context, restrictionQueryId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.DeleteRestrictionQuery") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetRestrictionQuery Get a restriction query. +// Get a restriction query in the organization specified by the restriction query's `restriction_query_id`. +func (a *LogsRestrictionQueriesApi) GetRestrictionQuery(ctx _context.Context, restrictionQueryId string) (RestrictionQueryWithRelationshipsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RestrictionQueryWithRelationshipsResponse + ) + + operationId := "v2.GetRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.GetRestrictionQuery") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetRoleRestrictionQuery Get restriction query for a given role. +// Get restriction query for a given role. +func (a *LogsRestrictionQueriesApi) GetRoleRestrictionQuery(ctx _context.Context, roleId string) (RestrictionQueryListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RestrictionQueryListResponse + ) + + operationId := "v2.GetRoleRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.GetRoleRestrictionQuery") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/role/{role_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{role_id}", _neturl.PathEscape(datadog.ParameterToString(roleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListRestrictionQueriesOptionalParameters holds optional parameters for ListRestrictionQueries. +type ListRestrictionQueriesOptionalParameters struct { + PageSize *int64 + PageNumber *int64 +} + +// NewListRestrictionQueriesOptionalParameters creates an empty struct for parameters. +func NewListRestrictionQueriesOptionalParameters() *ListRestrictionQueriesOptionalParameters { + this := ListRestrictionQueriesOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListRestrictionQueriesOptionalParameters) WithPageSize(pageSize int64) *ListRestrictionQueriesOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListRestrictionQueriesOptionalParameters) WithPageNumber(pageNumber int64) *ListRestrictionQueriesOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// ListRestrictionQueries List restriction queries. +// Returns all restriction queries, including their names and IDs. +func (a *LogsRestrictionQueriesApi) ListRestrictionQueries(ctx _context.Context, o ...ListRestrictionQueriesOptionalParameters) (RestrictionQueryListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RestrictionQueryListResponse + optionalParams ListRestrictionQueriesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListRestrictionQueriesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListRestrictionQueries" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.ListRestrictionQueries") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries" + + 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, "")) + } + 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 == 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 +} + +// ListRestrictionQueryRolesOptionalParameters holds optional parameters for ListRestrictionQueryRoles. +type ListRestrictionQueryRolesOptionalParameters struct { + PageSize *int64 + PageNumber *int64 +} + +// NewListRestrictionQueryRolesOptionalParameters creates an empty struct for parameters. +func NewListRestrictionQueryRolesOptionalParameters() *ListRestrictionQueryRolesOptionalParameters { + this := ListRestrictionQueryRolesOptionalParameters{} + return &this +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListRestrictionQueryRolesOptionalParameters) WithPageSize(pageSize int64) *ListRestrictionQueryRolesOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageNumber sets the corresponding parameter name and returns the struct. +func (r *ListRestrictionQueryRolesOptionalParameters) WithPageNumber(pageNumber int64) *ListRestrictionQueryRolesOptionalParameters { + r.PageNumber = &pageNumber + return r +} + +// ListRestrictionQueryRoles List roles for a restriction query. +// Returns all roles that have a given restriction query. +func (a *LogsRestrictionQueriesApi) ListRestrictionQueryRoles(ctx _context.Context, restrictionQueryId string, o ...ListRestrictionQueryRolesOptionalParameters) (RestrictionQueryRolesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RestrictionQueryRolesResponse + optionalParams ListRestrictionQueryRolesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListRestrictionQueryRolesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListRestrictionQueryRoles" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.ListRestrictionQueryRoles") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + 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, "")) + } + 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 +} + +// ListUserRestrictionQueries Get all restriction queries for a given user. +// Get all restriction queries for a given user. +func (a *LogsRestrictionQueriesApi) ListUserRestrictionQueries(ctx _context.Context, userId string) (RestrictionQueryListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue RestrictionQueryListResponse + ) + + operationId := "v2.ListUserRestrictionQueries" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.ListUserRestrictionQueries") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/user/{user_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{user_id}", _neturl.PathEscape(datadog.ParameterToString(userId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// RemoveRoleFromRestrictionQuery Revoke role from a restriction query. +// Removes a role from a restriction query. +func (a *LogsRestrictionQueriesApi) RemoveRoleFromRestrictionQuery(ctx _context.Context, restrictionQueryId string, body RelationshipToRole) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.RemoveRoleFromRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.RemoveRoleFromRestrictionQuery") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 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 +} + +// ReplaceRestrictionQuery Replace a restriction query. +// Replace a restriction query. +func (a *LogsRestrictionQueriesApi) ReplaceRestrictionQuery(ctx _context.Context, restrictionQueryId string, body RestrictionQueryUpdatePayload) (RestrictionQueryWithoutRelationshipsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue RestrictionQueryWithoutRelationshipsResponse + ) + + operationId := "v2.ReplaceRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.ReplaceRestrictionQuery") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + 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 +} + +// UpdateRestrictionQuery Update a restriction query. +// Edit a restriction query. +func (a *LogsRestrictionQueriesApi) UpdateRestrictionQuery(ctx _context.Context, restrictionQueryId string, body RestrictionQueryUpdatePayload) (RestrictionQueryWithoutRelationshipsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue RestrictionQueryWithoutRelationshipsResponse + ) + + operationId := "v2.UpdateRestrictionQuery" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.LogsRestrictionQueriesApi.UpdateRestrictionQuery") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/logs/config/restriction_queries/{restriction_query_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{restriction_query_id}", _neturl.PathEscape(datadog.ParameterToString(restrictionQueryId, ""))) + + 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 +} + +// NewLogsRestrictionQueriesApi Returns NewLogsRestrictionQueriesApi. +func NewLogsRestrictionQueriesApi(client *datadog.APIClient) *LogsRestrictionQueriesApi { + return &LogsRestrictionQueriesApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c5cf4723b97..d089d88095e 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -360,6 +360,17 @@ // - [LogsMetricsApi.GetLogsMetric] // - [LogsMetricsApi.ListLogsMetrics] // - [LogsMetricsApi.UpdateLogsMetric] +// - [LogsRestrictionQueriesApi.AddRoleToRestrictionQuery] +// - [LogsRestrictionQueriesApi.CreateRestrictionQuery] +// - [LogsRestrictionQueriesApi.DeleteRestrictionQuery] +// - [LogsRestrictionQueriesApi.GetRestrictionQuery] +// - [LogsRestrictionQueriesApi.GetRoleRestrictionQuery] +// - [LogsRestrictionQueriesApi.ListRestrictionQueries] +// - [LogsRestrictionQueriesApi.ListRestrictionQueryRoles] +// - [LogsRestrictionQueriesApi.ListUserRestrictionQueries] +// - [LogsRestrictionQueriesApi.RemoveRoleFromRestrictionQuery] +// - [LogsRestrictionQueriesApi.ReplaceRestrictionQuery] +// - [LogsRestrictionQueriesApi.UpdateRestrictionQuery] // - [MetricsApi.CreateBulkTagsMetricsConfiguration] // - [MetricsApi.CreateTagConfiguration] // - [MetricsApi.DeleteBulkTagsMetricsConfiguration] diff --git a/api/datadogV2/model_logs_restriction_queries_type.go b/api/datadogV2/model_logs_restriction_queries_type.go new file mode 100644 index 00000000000..eac117fa4a0 --- /dev/null +++ b/api/datadogV2/model_logs_restriction_queries_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" +) + +// LogsRestrictionQueriesType Restriction query resource type. +type LogsRestrictionQueriesType string + +// List of LogsRestrictionQueriesType. +const ( + LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES LogsRestrictionQueriesType = "logs_restriction_queries" +) + +var allowedLogsRestrictionQueriesTypeEnumValues = []LogsRestrictionQueriesType{ + LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *LogsRestrictionQueriesType) GetAllowedValues() []LogsRestrictionQueriesType { + return allowedLogsRestrictionQueriesTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *LogsRestrictionQueriesType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = LogsRestrictionQueriesType(value) + return nil +} + +// NewLogsRestrictionQueriesTypeFromValue returns a pointer to a valid LogsRestrictionQueriesType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewLogsRestrictionQueriesTypeFromValue(v string) (*LogsRestrictionQueriesType, error) { + ev := LogsRestrictionQueriesType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for LogsRestrictionQueriesType: valid values are %v", v, allowedLogsRestrictionQueriesTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v LogsRestrictionQueriesType) IsValid() bool { + for _, existing := range allowedLogsRestrictionQueriesTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to LogsRestrictionQueriesType value. +func (v LogsRestrictionQueriesType) Ptr() *LogsRestrictionQueriesType { + return &v +} diff --git a/api/datadogV2/model_restriction_query_attributes.go b/api/datadogV2/model_restriction_query_attributes.go new file mode 100644 index 00000000000..f8fdba856a5 --- /dev/null +++ b/api/datadogV2/model_restriction_query_attributes.go @@ -0,0 +1,322 @@ +// 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" +) + +// RestrictionQueryAttributes Attributes of the restriction query. +type RestrictionQueryAttributes struct { + // Creation time of the restriction query. + CreatedAt *time.Time `json:"created_at,omitempty"` + // Email of the user who last modified this restriction query. + LastModifierEmail *string `json:"last_modifier_email,omitempty"` + // Name of the user who last modified this restriction query. + LastModifierName *string `json:"last_modifier_name,omitempty"` + // Time of last restriction query modification. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The query that defines the restriction. Only the content matching the query can be returned. + RestrictionQuery *string `json:"restriction_query,omitempty"` + // Number of roles associated with this restriction query. + RoleCount *int64 `json:"role_count,omitempty"` + // Number of users associated with this restriction query. + UserCount *int64 `json:"user_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:"-"` +} + +// NewRestrictionQueryAttributes instantiates a new RestrictionQueryAttributes 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 NewRestrictionQueryAttributes() *RestrictionQueryAttributes { + this := RestrictionQueryAttributes{} + return &this +} + +// NewRestrictionQueryAttributesWithDefaults instantiates a new RestrictionQueryAttributes 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 NewRestrictionQueryAttributesWithDefaults() *RestrictionQueryAttributes { + this := RestrictionQueryAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) 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 *RestrictionQueryAttributes) 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 *RestrictionQueryAttributes) 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 *RestrictionQueryAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetLastModifierEmail returns the LastModifierEmail field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetLastModifierEmail() string { + if o == nil || o.LastModifierEmail == nil { + var ret string + return ret + } + return *o.LastModifierEmail +} + +// GetLastModifierEmailOk returns a tuple with the LastModifierEmail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetLastModifierEmailOk() (*string, bool) { + if o == nil || o.LastModifierEmail == nil { + return nil, false + } + return o.LastModifierEmail, true +} + +// HasLastModifierEmail returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasLastModifierEmail() bool { + return o != nil && o.LastModifierEmail != nil +} + +// SetLastModifierEmail gets a reference to the given string and assigns it to the LastModifierEmail field. +func (o *RestrictionQueryAttributes) SetLastModifierEmail(v string) { + o.LastModifierEmail = &v +} + +// GetLastModifierName returns the LastModifierName field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetLastModifierName() string { + if o == nil || o.LastModifierName == nil { + var ret string + return ret + } + return *o.LastModifierName +} + +// GetLastModifierNameOk returns a tuple with the LastModifierName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetLastModifierNameOk() (*string, bool) { + if o == nil || o.LastModifierName == nil { + return nil, false + } + return o.LastModifierName, true +} + +// HasLastModifierName returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasLastModifierName() bool { + return o != nil && o.LastModifierName != nil +} + +// SetLastModifierName gets a reference to the given string and assigns it to the LastModifierName field. +func (o *RestrictionQueryAttributes) SetLastModifierName(v string) { + o.LastModifierName = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given time.Time and assigns it to the ModifiedAt field. +func (o *RestrictionQueryAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetRestrictionQuery returns the RestrictionQuery field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetRestrictionQuery() string { + if o == nil || o.RestrictionQuery == nil { + var ret string + return ret + } + return *o.RestrictionQuery +} + +// GetRestrictionQueryOk returns a tuple with the RestrictionQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetRestrictionQueryOk() (*string, bool) { + if o == nil || o.RestrictionQuery == nil { + return nil, false + } + return o.RestrictionQuery, true +} + +// HasRestrictionQuery returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasRestrictionQuery() bool { + return o != nil && o.RestrictionQuery != nil +} + +// SetRestrictionQuery gets a reference to the given string and assigns it to the RestrictionQuery field. +func (o *RestrictionQueryAttributes) SetRestrictionQuery(v string) { + o.RestrictionQuery = &v +} + +// GetRoleCount returns the RoleCount field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetRoleCount() int64 { + if o == nil || o.RoleCount == nil { + var ret int64 + return ret + } + return *o.RoleCount +} + +// GetRoleCountOk returns a tuple with the RoleCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetRoleCountOk() (*int64, bool) { + if o == nil || o.RoleCount == nil { + return nil, false + } + return o.RoleCount, true +} + +// HasRoleCount returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasRoleCount() bool { + return o != nil && o.RoleCount != nil +} + +// SetRoleCount gets a reference to the given int64 and assigns it to the RoleCount field. +func (o *RestrictionQueryAttributes) SetRoleCount(v int64) { + o.RoleCount = &v +} + +// GetUserCount returns the UserCount field value if set, zero value otherwise. +func (o *RestrictionQueryAttributes) GetUserCount() int64 { + if o == nil || o.UserCount == nil { + var ret int64 + return ret + } + return *o.UserCount +} + +// GetUserCountOk returns a tuple with the UserCount field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryAttributes) GetUserCountOk() (*int64, bool) { + if o == nil || o.UserCount == nil { + return nil, false + } + return o.UserCount, true +} + +// HasUserCount returns a boolean if a field has been set. +func (o *RestrictionQueryAttributes) HasUserCount() bool { + return o != nil && o.UserCount != nil +} + +// SetUserCount gets a reference to the given int64 and assigns it to the UserCount field. +func (o *RestrictionQueryAttributes) SetUserCount(v int64) { + o.UserCount = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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.LastModifierEmail != nil { + toSerialize["last_modifier_email"] = o.LastModifierEmail + } + if o.LastModifierName != nil { + toSerialize["last_modifier_name"] = o.LastModifierName + } + if o.ModifiedAt != nil { + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.RestrictionQuery != nil { + toSerialize["restriction_query"] = o.RestrictionQuery + } + if o.RoleCount != nil { + toSerialize["role_count"] = o.RoleCount + } + if o.UserCount != nil { + toSerialize["user_count"] = o.UserCount + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RestrictionQueryAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at,omitempty"` + LastModifierEmail *string `json:"last_modifier_email,omitempty"` + LastModifierName *string `json:"last_modifier_name,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + RestrictionQuery *string `json:"restriction_query,omitempty"` + RoleCount *int64 `json:"role_count,omitempty"` + UserCount *int64 `json:"user_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{"created_at", "last_modifier_email", "last_modifier_name", "modified_at", "restriction_query", "role_count", "user_count"}) + } else { + return err + } + o.CreatedAt = all.CreatedAt + o.LastModifierEmail = all.LastModifierEmail + o.LastModifierName = all.LastModifierName + o.ModifiedAt = all.ModifiedAt + o.RestrictionQuery = all.RestrictionQuery + o.RoleCount = all.RoleCount + o.UserCount = all.UserCount + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_create_attributes.go b/api/datadogV2/model_restriction_query_create_attributes.go new file mode 100644 index 00000000000..12b4a644cb7 --- /dev/null +++ b/api/datadogV2/model_restriction_query_create_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RestrictionQueryCreateAttributes Attributes of the created restriction query. +type RestrictionQueryCreateAttributes struct { + // The restriction query. + RestrictionQuery string `json:"restriction_query"` + // 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:"-"` +} + +// NewRestrictionQueryCreateAttributes instantiates a new RestrictionQueryCreateAttributes 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 NewRestrictionQueryCreateAttributes(restrictionQuery string) *RestrictionQueryCreateAttributes { + this := RestrictionQueryCreateAttributes{} + this.RestrictionQuery = restrictionQuery + return &this +} + +// NewRestrictionQueryCreateAttributesWithDefaults instantiates a new RestrictionQueryCreateAttributes 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 NewRestrictionQueryCreateAttributesWithDefaults() *RestrictionQueryCreateAttributes { + this := RestrictionQueryCreateAttributes{} + return &this +} + +// GetRestrictionQuery returns the RestrictionQuery field value. +func (o *RestrictionQueryCreateAttributes) GetRestrictionQuery() string { + if o == nil { + var ret string + return ret + } + return o.RestrictionQuery +} + +// GetRestrictionQueryOk returns a tuple with the RestrictionQuery field value +// and a boolean to check if the value has been set. +func (o *RestrictionQueryCreateAttributes) GetRestrictionQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RestrictionQuery, true +} + +// SetRestrictionQuery sets field value. +func (o *RestrictionQueryCreateAttributes) SetRestrictionQuery(v string) { + o.RestrictionQuery = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["restriction_query"] = o.RestrictionQuery + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RestrictionQueryCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RestrictionQuery *string `json:"restriction_query"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.RestrictionQuery == nil { + return fmt.Errorf("required field restriction_query missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"restriction_query"}) + } else { + return err + } + o.RestrictionQuery = *all.RestrictionQuery + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_create_data.go b/api/datadogV2/model_restriction_query_create_data.go new file mode 100644 index 00000000000..c97c1a6206b --- /dev/null +++ b/api/datadogV2/model_restriction_query_create_data.go @@ -0,0 +1,154 @@ +// 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" +) + +// RestrictionQueryCreateData Data related to the creation of a restriction query. +type RestrictionQueryCreateData struct { + // Attributes of the created restriction query. + Attributes *RestrictionQueryCreateAttributes `json:"attributes,omitempty"` + // Restriction query resource type. + Type *LogsRestrictionQueriesType `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:"-"` +} + +// NewRestrictionQueryCreateData instantiates a new RestrictionQueryCreateData 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 NewRestrictionQueryCreateData() *RestrictionQueryCreateData { + this := RestrictionQueryCreateData{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// NewRestrictionQueryCreateDataWithDefaults instantiates a new RestrictionQueryCreateData 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 NewRestrictionQueryCreateDataWithDefaults() *RestrictionQueryCreateData { + this := RestrictionQueryCreateData{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *RestrictionQueryCreateData) GetAttributes() RestrictionQueryCreateAttributes { + if o == nil || o.Attributes == nil { + var ret RestrictionQueryCreateAttributes + 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 *RestrictionQueryCreateData) GetAttributesOk() (*RestrictionQueryCreateAttributes, 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 *RestrictionQueryCreateData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given RestrictionQueryCreateAttributes and assigns it to the Attributes field. +func (o *RestrictionQueryCreateData) SetAttributes(v RestrictionQueryCreateAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *RestrictionQueryCreateData) GetType() LogsRestrictionQueriesType { + if o == nil || o.Type == nil { + var ret LogsRestrictionQueriesType + 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 *RestrictionQueryCreateData) GetTypeOk() (*LogsRestrictionQueriesType, 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 *RestrictionQueryCreateData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given LogsRestrictionQueriesType and assigns it to the Type field. +func (o *RestrictionQueryCreateData) SetType(v LogsRestrictionQueriesType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryCreateData) 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.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 *RestrictionQueryCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RestrictionQueryCreateAttributes `json:"attributes,omitempty"` + Type *LogsRestrictionQueriesType `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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != 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_restriction_query_create_payload.go b/api/datadogV2/model_restriction_query_create_payload.go new file mode 100644 index 00000000000..e5b8a4e4ff6 --- /dev/null +++ b/api/datadogV2/model_restriction_query_create_payload.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" +) + +// RestrictionQueryCreatePayload Create a restriction query. +type RestrictionQueryCreatePayload struct { + // Data related to the creation of a restriction query. + Data *RestrictionQueryCreateData `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:"-"` +} + +// NewRestrictionQueryCreatePayload instantiates a new RestrictionQueryCreatePayload 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 NewRestrictionQueryCreatePayload() *RestrictionQueryCreatePayload { + this := RestrictionQueryCreatePayload{} + return &this +} + +// NewRestrictionQueryCreatePayloadWithDefaults instantiates a new RestrictionQueryCreatePayload 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 NewRestrictionQueryCreatePayloadWithDefaults() *RestrictionQueryCreatePayload { + this := RestrictionQueryCreatePayload{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryCreatePayload) GetData() RestrictionQueryCreateData { + if o == nil || o.Data == nil { + var ret RestrictionQueryCreateData + 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 *RestrictionQueryCreatePayload) GetDataOk() (*RestrictionQueryCreateData, 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 *RestrictionQueryCreatePayload) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given RestrictionQueryCreateData and assigns it to the Data field. +func (o *RestrictionQueryCreatePayload) SetData(v RestrictionQueryCreateData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryCreatePayload) 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 *RestrictionQueryCreatePayload) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RestrictionQueryCreateData `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_restriction_query_list_response.go b/api/datadogV2/model_restriction_query_list_response.go new file mode 100644 index 00000000000..196a3f6c6d8 --- /dev/null +++ b/api/datadogV2/model_restriction_query_list_response.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" +) + +// RestrictionQueryListResponse Response containing information about multiple restriction queries. +type RestrictionQueryListResponse struct { + // Array of returned restriction queries. + Data []RestrictionQueryWithoutRelationships `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:"-"` +} + +// NewRestrictionQueryListResponse instantiates a new RestrictionQueryListResponse 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 NewRestrictionQueryListResponse() *RestrictionQueryListResponse { + this := RestrictionQueryListResponse{} + return &this +} + +// NewRestrictionQueryListResponseWithDefaults instantiates a new RestrictionQueryListResponse 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 NewRestrictionQueryListResponseWithDefaults() *RestrictionQueryListResponse { + this := RestrictionQueryListResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryListResponse) GetData() []RestrictionQueryWithoutRelationships { + if o == nil || o.Data == nil { + var ret []RestrictionQueryWithoutRelationships + 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 *RestrictionQueryListResponse) GetDataOk() (*[]RestrictionQueryWithoutRelationships, 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 *RestrictionQueryListResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []RestrictionQueryWithoutRelationships and assigns it to the Data field. +func (o *RestrictionQueryListResponse) SetData(v []RestrictionQueryWithoutRelationships) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryListResponse) 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 *RestrictionQueryListResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []RestrictionQueryWithoutRelationships `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 + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_response_included_item.go b/api/datadogV2/model_restriction_query_response_included_item.go new file mode 100644 index 00000000000..091d959823a --- /dev/null +++ b/api/datadogV2/model_restriction_query_response_included_item.go @@ -0,0 +1,73 @@ +// 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" +) + +// RestrictionQueryResponseIncludedItem - An object related to a restriction query. +type RestrictionQueryResponseIncludedItem struct { + RestrictionQueryRole *RestrictionQueryRole + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// RestrictionQueryRoleAsRestrictionQueryResponseIncludedItem is a convenience function that returns RestrictionQueryRole wrapped in RestrictionQueryResponseIncludedItem. +func RestrictionQueryRoleAsRestrictionQueryResponseIncludedItem(v *RestrictionQueryRole) RestrictionQueryResponseIncludedItem { + return RestrictionQueryResponseIncludedItem{RestrictionQueryRole: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *RestrictionQueryResponseIncludedItem) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into RestrictionQueryRole + err = datadog.Unmarshal(data, &obj.RestrictionQueryRole) + if err == nil { + if obj.RestrictionQueryRole != nil && obj.RestrictionQueryRole.UnparsedObject == nil { + jsonRestrictionQueryRole, _ := datadog.Marshal(obj.RestrictionQueryRole) + if string(jsonRestrictionQueryRole) == "{}" { // empty struct + obj.RestrictionQueryRole = nil + } else { + match++ + } + } else { + obj.RestrictionQueryRole = nil + } + } else { + obj.RestrictionQueryRole = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.RestrictionQueryRole = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj RestrictionQueryResponseIncludedItem) MarshalJSON() ([]byte, error) { + if obj.RestrictionQueryRole != nil { + return datadog.Marshal(&obj.RestrictionQueryRole) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *RestrictionQueryResponseIncludedItem) GetActualInstance() interface{} { + if obj.RestrictionQueryRole != nil { + return obj.RestrictionQueryRole + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_restriction_query_role.go b/api/datadogV2/model_restriction_query_role.go new file mode 100644 index 00000000000..babb2203879 --- /dev/null +++ b/api/datadogV2/model_restriction_query_role.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" +) + +// RestrictionQueryRole Partial role object. +type RestrictionQueryRole struct { + // Attributes of the role for a restriction query. + Attributes RestrictionQueryRoleAttribute `json:"attributes"` + // ID of the role. + Id string `json:"id"` + // Roles type. + Type RolesType `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:"-"` +} + +// NewRestrictionQueryRole instantiates a new RestrictionQueryRole 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 NewRestrictionQueryRole(attributes RestrictionQueryRoleAttribute, id string, typeVar RolesType) *RestrictionQueryRole { + this := RestrictionQueryRole{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewRestrictionQueryRoleWithDefaults instantiates a new RestrictionQueryRole 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 NewRestrictionQueryRoleWithDefaults() *RestrictionQueryRole { + this := RestrictionQueryRole{} + var typeVar RolesType = ROLESTYPE_ROLES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *RestrictionQueryRole) GetAttributes() RestrictionQueryRoleAttribute { + if o == nil { + var ret RestrictionQueryRoleAttribute + 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 *RestrictionQueryRole) GetAttributesOk() (*RestrictionQueryRoleAttribute, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *RestrictionQueryRole) SetAttributes(v RestrictionQueryRoleAttribute) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *RestrictionQueryRole) 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 *RestrictionQueryRole) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *RestrictionQueryRole) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *RestrictionQueryRole) GetType() RolesType { + if o == nil { + var ret RolesType + 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 *RestrictionQueryRole) GetTypeOk() (*RolesType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *RestrictionQueryRole) SetType(v RolesType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryRole) 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 *RestrictionQueryRole) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RestrictionQueryRoleAttribute `json:"attributes"` + Id *string `json:"id"` + Type *RolesType `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_restriction_query_role_attribute.go b/api/datadogV2/model_restriction_query_role_attribute.go new file mode 100644 index 00000000000..24219dae682 --- /dev/null +++ b/api/datadogV2/model_restriction_query_role_attribute.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" +) + +// RestrictionQueryRoleAttribute Attributes of the role for a restriction query. +type RestrictionQueryRoleAttribute struct { + // The role name. + Name *string `json:"name,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:"-"` +} + +// NewRestrictionQueryRoleAttribute instantiates a new RestrictionQueryRoleAttribute 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 NewRestrictionQueryRoleAttribute() *RestrictionQueryRoleAttribute { + this := RestrictionQueryRoleAttribute{} + return &this +} + +// NewRestrictionQueryRoleAttributeWithDefaults instantiates a new RestrictionQueryRoleAttribute 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 NewRestrictionQueryRoleAttributeWithDefaults() *RestrictionQueryRoleAttribute { + this := RestrictionQueryRoleAttribute{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *RestrictionQueryRoleAttribute) 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 *RestrictionQueryRoleAttribute) 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 *RestrictionQueryRoleAttribute) 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 *RestrictionQueryRoleAttribute) SetName(v string) { + o.Name = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryRoleAttribute) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RestrictionQueryRoleAttribute) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name,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"}) + } else { + return err + } + o.Name = all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_roles_response.go b/api/datadogV2/model_restriction_query_roles_response.go new file mode 100644 index 00000000000..5fed0aeb8d9 --- /dev/null +++ b/api/datadogV2/model_restriction_query_roles_response.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" +) + +// RestrictionQueryRolesResponse Response containing information about roles attached to a restriction query. +type RestrictionQueryRolesResponse struct { + // Array of roles. + Data []RestrictionQueryRole `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:"-"` +} + +// NewRestrictionQueryRolesResponse instantiates a new RestrictionQueryRolesResponse 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 NewRestrictionQueryRolesResponse() *RestrictionQueryRolesResponse { + this := RestrictionQueryRolesResponse{} + return &this +} + +// NewRestrictionQueryRolesResponseWithDefaults instantiates a new RestrictionQueryRolesResponse 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 NewRestrictionQueryRolesResponseWithDefaults() *RestrictionQueryRolesResponse { + this := RestrictionQueryRolesResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryRolesResponse) GetData() []RestrictionQueryRole { + if o == nil || o.Data == nil { + var ret []RestrictionQueryRole + 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 *RestrictionQueryRolesResponse) GetDataOk() (*[]RestrictionQueryRole, 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 *RestrictionQueryRolesResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []RestrictionQueryRole and assigns it to the Data field. +func (o *RestrictionQueryRolesResponse) SetData(v []RestrictionQueryRole) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryRolesResponse) 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 *RestrictionQueryRolesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []RestrictionQueryRole `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 + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_update_attributes.go b/api/datadogV2/model_restriction_query_update_attributes.go new file mode 100644 index 00000000000..6aaf698a9e9 --- /dev/null +++ b/api/datadogV2/model_restriction_query_update_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RestrictionQueryUpdateAttributes Attributes of the edited restriction query. +type RestrictionQueryUpdateAttributes struct { + // The restriction query. + RestrictionQuery string `json:"restriction_query"` + // 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:"-"` +} + +// NewRestrictionQueryUpdateAttributes instantiates a new RestrictionQueryUpdateAttributes 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 NewRestrictionQueryUpdateAttributes(restrictionQuery string) *RestrictionQueryUpdateAttributes { + this := RestrictionQueryUpdateAttributes{} + this.RestrictionQuery = restrictionQuery + return &this +} + +// NewRestrictionQueryUpdateAttributesWithDefaults instantiates a new RestrictionQueryUpdateAttributes 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 NewRestrictionQueryUpdateAttributesWithDefaults() *RestrictionQueryUpdateAttributes { + this := RestrictionQueryUpdateAttributes{} + return &this +} + +// GetRestrictionQuery returns the RestrictionQuery field value. +func (o *RestrictionQueryUpdateAttributes) GetRestrictionQuery() string { + if o == nil { + var ret string + return ret + } + return o.RestrictionQuery +} + +// GetRestrictionQueryOk returns a tuple with the RestrictionQuery field value +// and a boolean to check if the value has been set. +func (o *RestrictionQueryUpdateAttributes) GetRestrictionQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.RestrictionQuery, true +} + +// SetRestrictionQuery sets field value. +func (o *RestrictionQueryUpdateAttributes) SetRestrictionQuery(v string) { + o.RestrictionQuery = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["restriction_query"] = o.RestrictionQuery + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RestrictionQueryUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RestrictionQuery *string `json:"restriction_query"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.RestrictionQuery == nil { + return fmt.Errorf("required field restriction_query missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"restriction_query"}) + } else { + return err + } + o.RestrictionQuery = *all.RestrictionQuery + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_update_data.go b/api/datadogV2/model_restriction_query_update_data.go new file mode 100644 index 00000000000..d657fe51f11 --- /dev/null +++ b/api/datadogV2/model_restriction_query_update_data.go @@ -0,0 +1,154 @@ +// 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" +) + +// RestrictionQueryUpdateData Data related to the update of a restriction query. +type RestrictionQueryUpdateData struct { + // Attributes of the edited restriction query. + Attributes *RestrictionQueryUpdateAttributes `json:"attributes,omitempty"` + // Restriction query resource type. + Type *LogsRestrictionQueriesType `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:"-"` +} + +// NewRestrictionQueryUpdateData instantiates a new RestrictionQueryUpdateData 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 NewRestrictionQueryUpdateData() *RestrictionQueryUpdateData { + this := RestrictionQueryUpdateData{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// NewRestrictionQueryUpdateDataWithDefaults instantiates a new RestrictionQueryUpdateData 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 NewRestrictionQueryUpdateDataWithDefaults() *RestrictionQueryUpdateData { + this := RestrictionQueryUpdateData{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *RestrictionQueryUpdateData) GetAttributes() RestrictionQueryUpdateAttributes { + if o == nil || o.Attributes == nil { + var ret RestrictionQueryUpdateAttributes + 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 *RestrictionQueryUpdateData) GetAttributesOk() (*RestrictionQueryUpdateAttributes, 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 *RestrictionQueryUpdateData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given RestrictionQueryUpdateAttributes and assigns it to the Attributes field. +func (o *RestrictionQueryUpdateData) SetAttributes(v RestrictionQueryUpdateAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *RestrictionQueryUpdateData) GetType() LogsRestrictionQueriesType { + if o == nil || o.Type == nil { + var ret LogsRestrictionQueriesType + 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 *RestrictionQueryUpdateData) GetTypeOk() (*LogsRestrictionQueriesType, 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 *RestrictionQueryUpdateData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given LogsRestrictionQueriesType and assigns it to the Type field. +func (o *RestrictionQueryUpdateData) SetType(v LogsRestrictionQueriesType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryUpdateData) 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.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 *RestrictionQueryUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RestrictionQueryUpdateAttributes `json:"attributes,omitempty"` + Type *LogsRestrictionQueriesType `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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != 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_restriction_query_update_payload.go b/api/datadogV2/model_restriction_query_update_payload.go new file mode 100644 index 00000000000..e485304ca08 --- /dev/null +++ b/api/datadogV2/model_restriction_query_update_payload.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" +) + +// RestrictionQueryUpdatePayload Update a restriction query. +type RestrictionQueryUpdatePayload struct { + // Data related to the update of a restriction query. + Data *RestrictionQueryUpdateData `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:"-"` +} + +// NewRestrictionQueryUpdatePayload instantiates a new RestrictionQueryUpdatePayload 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 NewRestrictionQueryUpdatePayload() *RestrictionQueryUpdatePayload { + this := RestrictionQueryUpdatePayload{} + return &this +} + +// NewRestrictionQueryUpdatePayloadWithDefaults instantiates a new RestrictionQueryUpdatePayload 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 NewRestrictionQueryUpdatePayloadWithDefaults() *RestrictionQueryUpdatePayload { + this := RestrictionQueryUpdatePayload{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryUpdatePayload) GetData() RestrictionQueryUpdateData { + if o == nil || o.Data == nil { + var ret RestrictionQueryUpdateData + 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 *RestrictionQueryUpdatePayload) GetDataOk() (*RestrictionQueryUpdateData, 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 *RestrictionQueryUpdatePayload) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given RestrictionQueryUpdateData and assigns it to the Data field. +func (o *RestrictionQueryUpdatePayload) SetData(v RestrictionQueryUpdateData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryUpdatePayload) 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 *RestrictionQueryUpdatePayload) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RestrictionQueryUpdateData `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_restriction_query_with_relationships.go b/api/datadogV2/model_restriction_query_with_relationships.go new file mode 100644 index 00000000000..28fcf0f65e5 --- /dev/null +++ b/api/datadogV2/model_restriction_query_with_relationships.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" +) + +// RestrictionQueryWithRelationships Restriction query object returned by the API. +type RestrictionQueryWithRelationships struct { + // Attributes of the restriction query. + Attributes *RestrictionQueryAttributes `json:"attributes,omitempty"` + // ID of the restriction query. + Id *string `json:"id,omitempty"` + // Relationships of the user object. + Relationships *UserRelationships `json:"relationships,omitempty"` + // Restriction query resource type. + Type *LogsRestrictionQueriesType `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:"-"` +} + +// NewRestrictionQueryWithRelationships instantiates a new RestrictionQueryWithRelationships 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 NewRestrictionQueryWithRelationships() *RestrictionQueryWithRelationships { + this := RestrictionQueryWithRelationships{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// NewRestrictionQueryWithRelationshipsWithDefaults instantiates a new RestrictionQueryWithRelationships 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 NewRestrictionQueryWithRelationshipsWithDefaults() *RestrictionQueryWithRelationships { + this := RestrictionQueryWithRelationships{} + var typeVar LogsRestrictionQueriesType = LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationships) GetAttributes() RestrictionQueryAttributes { + if o == nil || o.Attributes == nil { + var ret RestrictionQueryAttributes + 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 *RestrictionQueryWithRelationships) GetAttributesOk() (*RestrictionQueryAttributes, 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 *RestrictionQueryWithRelationships) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given RestrictionQueryAttributes and assigns it to the Attributes field. +func (o *RestrictionQueryWithRelationships) SetAttributes(v RestrictionQueryAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationships) 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 *RestrictionQueryWithRelationships) 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 *RestrictionQueryWithRelationships) 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 *RestrictionQueryWithRelationships) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationships) GetRelationships() UserRelationships { + if o == nil || o.Relationships == nil { + var ret UserRelationships + 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 *RestrictionQueryWithRelationships) GetRelationshipsOk() (*UserRelationships, 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 *RestrictionQueryWithRelationships) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given UserRelationships and assigns it to the Relationships field. +func (o *RestrictionQueryWithRelationships) SetRelationships(v UserRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationships) GetType() LogsRestrictionQueriesType { + if o == nil || o.Type == nil { + var ret LogsRestrictionQueriesType + 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 *RestrictionQueryWithRelationships) GetTypeOk() (*LogsRestrictionQueriesType, 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 *RestrictionQueryWithRelationships) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given LogsRestrictionQueriesType and assigns it to the Type field. +func (o *RestrictionQueryWithRelationships) SetType(v LogsRestrictionQueriesType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryWithRelationships) 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 *RestrictionQueryWithRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RestrictionQueryAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *UserRelationships `json:"relationships,omitempty"` + Type *LogsRestrictionQueriesType `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_restriction_query_with_relationships_response.go b/api/datadogV2/model_restriction_query_with_relationships_response.go new file mode 100644 index 00000000000..5d5457fd187 --- /dev/null +++ b/api/datadogV2/model_restriction_query_with_relationships_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" +) + +// RestrictionQueryWithRelationshipsResponse Response containing information about a single restriction query. +type RestrictionQueryWithRelationshipsResponse struct { + // Restriction query object returned by the API. + Data *RestrictionQueryWithRelationships `json:"data,omitempty"` + // Array of objects related to the restriction query. + Included []RestrictionQueryResponseIncludedItem `json:"included,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:"-"` +} + +// NewRestrictionQueryWithRelationshipsResponse instantiates a new RestrictionQueryWithRelationshipsResponse 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 NewRestrictionQueryWithRelationshipsResponse() *RestrictionQueryWithRelationshipsResponse { + this := RestrictionQueryWithRelationshipsResponse{} + return &this +} + +// NewRestrictionQueryWithRelationshipsResponseWithDefaults instantiates a new RestrictionQueryWithRelationshipsResponse 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 NewRestrictionQueryWithRelationshipsResponseWithDefaults() *RestrictionQueryWithRelationshipsResponse { + this := RestrictionQueryWithRelationshipsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationshipsResponse) GetData() RestrictionQueryWithRelationships { + if o == nil || o.Data == nil { + var ret RestrictionQueryWithRelationships + 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 *RestrictionQueryWithRelationshipsResponse) GetDataOk() (*RestrictionQueryWithRelationships, 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 *RestrictionQueryWithRelationshipsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given RestrictionQueryWithRelationships and assigns it to the Data field. +func (o *RestrictionQueryWithRelationshipsResponse) SetData(v RestrictionQueryWithRelationships) { + o.Data = &v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *RestrictionQueryWithRelationshipsResponse) GetIncluded() []RestrictionQueryResponseIncludedItem { + if o == nil || o.Included == nil { + var ret []RestrictionQueryResponseIncludedItem + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *RestrictionQueryWithRelationshipsResponse) GetIncludedOk() (*[]RestrictionQueryResponseIncludedItem, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *RestrictionQueryWithRelationshipsResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []RestrictionQueryResponseIncludedItem and assigns it to the Included field. +func (o *RestrictionQueryWithRelationshipsResponse) SetIncluded(v []RestrictionQueryResponseIncludedItem) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryWithRelationshipsResponse) 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.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *RestrictionQueryWithRelationshipsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RestrictionQueryWithRelationships `json:"data,omitempty"` + Included []RestrictionQueryResponseIncludedItem `json:"included,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", "included"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_restriction_query_without_relationships.go b/api/datadogV2/model_restriction_query_without_relationships.go new file mode 100644 index 00000000000..166df8dc485 --- /dev/null +++ b/api/datadogV2/model_restriction_query_without_relationships.go @@ -0,0 +1,181 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// RestrictionQueryWithoutRelationships Restriction query object returned by the API. +type RestrictionQueryWithoutRelationships struct { + // Attributes of the restriction query. + Attributes *RestrictionQueryAttributes `json:"attributes,omitempty"` + // ID of the restriction query. + Id *string `json:"id,omitempty"` + // Restriction queries type. + Type *string `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:"-"` +} + +// NewRestrictionQueryWithoutRelationships instantiates a new RestrictionQueryWithoutRelationships 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 NewRestrictionQueryWithoutRelationships() *RestrictionQueryWithoutRelationships { + this := RestrictionQueryWithoutRelationships{} + return &this +} + +// NewRestrictionQueryWithoutRelationshipsWithDefaults instantiates a new RestrictionQueryWithoutRelationships 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 NewRestrictionQueryWithoutRelationshipsWithDefaults() *RestrictionQueryWithoutRelationships { + this := RestrictionQueryWithoutRelationships{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *RestrictionQueryWithoutRelationships) GetAttributes() RestrictionQueryAttributes { + if o == nil || o.Attributes == nil { + var ret RestrictionQueryAttributes + 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 *RestrictionQueryWithoutRelationships) GetAttributesOk() (*RestrictionQueryAttributes, 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 *RestrictionQueryWithoutRelationships) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given RestrictionQueryAttributes and assigns it to the Attributes field. +func (o *RestrictionQueryWithoutRelationships) SetAttributes(v RestrictionQueryAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *RestrictionQueryWithoutRelationships) 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 *RestrictionQueryWithoutRelationships) 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 *RestrictionQueryWithoutRelationships) 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 *RestrictionQueryWithoutRelationships) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *RestrictionQueryWithoutRelationships) GetType() string { + if o == nil || o.Type == nil { + var ret string + 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 *RestrictionQueryWithoutRelationships) GetTypeOk() (*string, 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 *RestrictionQueryWithoutRelationships) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *RestrictionQueryWithoutRelationships) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryWithoutRelationships) 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.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 *RestrictionQueryWithoutRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *RestrictionQueryAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *string `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", "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 + 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_restriction_query_without_relationships_response.go b/api/datadogV2/model_restriction_query_without_relationships_response.go new file mode 100644 index 00000000000..80741160dbe --- /dev/null +++ b/api/datadogV2/model_restriction_query_without_relationships_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" +) + +// RestrictionQueryWithoutRelationshipsResponse Response containing information about a single restriction query. +type RestrictionQueryWithoutRelationshipsResponse struct { + // Restriction query object returned by the API. + Data *RestrictionQueryWithoutRelationships `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:"-"` +} + +// NewRestrictionQueryWithoutRelationshipsResponse instantiates a new RestrictionQueryWithoutRelationshipsResponse 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 NewRestrictionQueryWithoutRelationshipsResponse() *RestrictionQueryWithoutRelationshipsResponse { + this := RestrictionQueryWithoutRelationshipsResponse{} + return &this +} + +// NewRestrictionQueryWithoutRelationshipsResponseWithDefaults instantiates a new RestrictionQueryWithoutRelationshipsResponse 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 NewRestrictionQueryWithoutRelationshipsResponseWithDefaults() *RestrictionQueryWithoutRelationshipsResponse { + this := RestrictionQueryWithoutRelationshipsResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *RestrictionQueryWithoutRelationshipsResponse) GetData() RestrictionQueryWithoutRelationships { + if o == nil || o.Data == nil { + var ret RestrictionQueryWithoutRelationships + 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 *RestrictionQueryWithoutRelationshipsResponse) GetDataOk() (*RestrictionQueryWithoutRelationships, 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 *RestrictionQueryWithoutRelationshipsResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given RestrictionQueryWithoutRelationships and assigns it to the Data field. +func (o *RestrictionQueryWithoutRelationshipsResponse) SetData(v RestrictionQueryWithoutRelationships) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o RestrictionQueryWithoutRelationshipsResponse) 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 *RestrictionQueryWithoutRelationshipsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *RestrictionQueryWithoutRelationships `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/examples/v2/logs-restriction-queries/AddRoleToRestrictionQuery.go b/examples/v2/logs-restriction-queries/AddRoleToRestrictionQuery.go new file mode 100644 index 00000000000..b32a0995f2f --- /dev/null +++ b/examples/v2/logs-restriction-queries/AddRoleToRestrictionQuery.go @@ -0,0 +1,38 @@ +// Grant role to a restriction query returns "OK" 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + // there is a valid "role" in the system + RoleDataID := os.Getenv("ROLE_DATA_ID") + + body := datadogV2.RelationshipToRole{ + Data: &datadogV2.RelationshipToRoleData{ + Id: datadog.PtrString(RoleDataID), + Type: datadogV2.ROLESTYPE_ROLES.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.AddRoleToRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + r, err := api.AddRoleToRestrictionQuery(ctx, RestrictionQueryDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.AddRoleToRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/logs-restriction-queries/CreateRestrictionQuery.go b/examples/v2/logs-restriction-queries/CreateRestrictionQuery.go new file mode 100644 index 00000000000..f70119a745b --- /dev/null +++ b/examples/v2/logs-restriction-queries/CreateRestrictionQuery.go @@ -0,0 +1,38 @@ +// Create a restriction query returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.RestrictionQueryCreatePayload{ + Data: &datadogV2.RestrictionQueryCreateData{ + Attributes: &datadogV2.RestrictionQueryCreateAttributes{ + RestrictionQuery: "env:sandbox", + }, + Type: datadogV2.LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.CreateRestrictionQuery(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.CreateRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.CreateRestrictionQuery`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/DeleteRestrictionQuery.go b/examples/v2/logs-restriction-queries/DeleteRestrictionQuery.go new file mode 100644 index 00000000000..ae524e7b73b --- /dev/null +++ b/examples/v2/logs-restriction-queries/DeleteRestrictionQuery.go @@ -0,0 +1,29 @@ +// Delete a restriction query returns "OK" 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + r, err := api.DeleteRestrictionQuery(ctx, RestrictionQueryDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.DeleteRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/logs-restriction-queries/GetRestrictionQuery.go b/examples/v2/logs-restriction-queries/GetRestrictionQuery.go new file mode 100644 index 00000000000..6f00659446b --- /dev/null +++ b/examples/v2/logs-restriction-queries/GetRestrictionQuery.go @@ -0,0 +1,33 @@ +// Get a restriction query 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.GetRestrictionQuery(ctx, RestrictionQueryDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.GetRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.GetRestrictionQuery`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/GetRoleRestrictionQuery.go b/examples/v2/logs-restriction-queries/GetRoleRestrictionQuery.go new file mode 100644 index 00000000000..b75626534e2 --- /dev/null +++ b/examples/v2/logs-restriction-queries/GetRoleRestrictionQuery.go @@ -0,0 +1,33 @@ +// Get restriction query for a given role 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 "role" in the system + RoleDataID := os.Getenv("ROLE_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetRoleRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.GetRoleRestrictionQuery(ctx, RoleDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.GetRoleRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.GetRoleRestrictionQuery`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/ListRestrictionQueries.go b/examples/v2/logs-restriction-queries/ListRestrictionQueries.go new file mode 100644 index 00000000000..5556085c194 --- /dev/null +++ b/examples/v2/logs-restriction-queries/ListRestrictionQueries.go @@ -0,0 +1,30 @@ +// List restriction queries returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListRestrictionQueries", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.ListRestrictionQueries(ctx, *datadogV2.NewListRestrictionQueriesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.ListRestrictionQueries`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.ListRestrictionQueries`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/ListRestrictionQueryRoles.go b/examples/v2/logs-restriction-queries/ListRestrictionQueryRoles.go new file mode 100644 index 00000000000..6bb7a28142f --- /dev/null +++ b/examples/v2/logs-restriction-queries/ListRestrictionQueryRoles.go @@ -0,0 +1,33 @@ +// List roles for a restriction query 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListRestrictionQueryRoles", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.ListRestrictionQueryRoles(ctx, RestrictionQueryDataID, *datadogV2.NewListRestrictionQueryRolesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.ListRestrictionQueryRoles`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.ListRestrictionQueryRoles`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/ListUserRestrictionQueries.go b/examples/v2/logs-restriction-queries/ListUserRestrictionQueries.go new file mode 100644 index 00000000000..1dd1d3255fc --- /dev/null +++ b/examples/v2/logs-restriction-queries/ListUserRestrictionQueries.go @@ -0,0 +1,33 @@ +// Get all restriction queries for a given user 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 "user" in the system + UserDataID := os.Getenv("USER_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListUserRestrictionQueries", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.ListUserRestrictionQueries(ctx, UserDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.ListUserRestrictionQueries`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.ListUserRestrictionQueries`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/RemoveRoleFromRestrictionQuery.go b/examples/v2/logs-restriction-queries/RemoveRoleFromRestrictionQuery.go new file mode 100644 index 00000000000..66d3b857b46 --- /dev/null +++ b/examples/v2/logs-restriction-queries/RemoveRoleFromRestrictionQuery.go @@ -0,0 +1,38 @@ +// Revoke role from a restriction query returns "OK" 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + // there is a valid "role" in the system + RoleDataID := os.Getenv("ROLE_DATA_ID") + + body := datadogV2.RelationshipToRole{ + Data: &datadogV2.RelationshipToRoleData{ + Id: datadog.PtrString(RoleDataID), + Type: datadogV2.ROLESTYPE_ROLES.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.RemoveRoleFromRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + r, err := api.RemoveRoleFromRestrictionQuery(ctx, RestrictionQueryDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.RemoveRoleFromRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/logs-restriction-queries/ReplaceRestrictionQuery.go b/examples/v2/logs-restriction-queries/ReplaceRestrictionQuery.go new file mode 100644 index 00000000000..b4a8f34b72d --- /dev/null +++ b/examples/v2/logs-restriction-queries/ReplaceRestrictionQuery.go @@ -0,0 +1,41 @@ +// Replace a restriction query 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + body := datadogV2.RestrictionQueryUpdatePayload{ + Data: &datadogV2.RestrictionQueryUpdateData{ + Attributes: &datadogV2.RestrictionQueryUpdateAttributes{ + RestrictionQuery: "env:staging", + }, + Type: datadogV2.LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ReplaceRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.ReplaceRestrictionQuery(ctx, RestrictionQueryDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.ReplaceRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.ReplaceRestrictionQuery`:\n%s\n", responseContent) +} diff --git a/examples/v2/logs-restriction-queries/UpdateRestrictionQuery.go b/examples/v2/logs-restriction-queries/UpdateRestrictionQuery.go new file mode 100644 index 00000000000..ee7c95c8f98 --- /dev/null +++ b/examples/v2/logs-restriction-queries/UpdateRestrictionQuery.go @@ -0,0 +1,41 @@ +// Update a restriction query 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 "restriction_query" in the system + RestrictionQueryDataID := os.Getenv("RESTRICTION_QUERY_DATA_ID") + + body := datadogV2.RestrictionQueryUpdatePayload{ + Data: &datadogV2.RestrictionQueryUpdateData{ + Attributes: &datadogV2.RestrictionQueryUpdateAttributes{ + RestrictionQuery: "env:production", + }, + Type: datadogV2.LOGSRESTRICTIONQUERIESTYPE_LOGS_RESTRICTION_QUERIES.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateRestrictionQuery", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewLogsRestrictionQueriesApi(apiClient) + resp, r, err := api.UpdateRestrictionQuery(ctx, RestrictionQueryDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `LogsRestrictionQueriesApi.UpdateRestrictionQuery`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `LogsRestrictionQueriesApi.UpdateRestrictionQuery`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 6fedea1b018..4f9dcb43517 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -92,6 +92,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "LogsArchivesApi": reflect.ValueOf(datadogV2.NewLogsArchivesApi), "LogsCustomDestinationsApi": reflect.ValueOf(datadogV2.NewLogsCustomDestinationsApi), "LogsMetricsApi": reflect.ValueOf(datadogV2.NewLogsMetricsApi), + "LogsRestrictionQueriesApi": reflect.ValueOf(datadogV2.NewLogsRestrictionQueriesApi), "MetricsApi": reflect.ValueOf(datadogV2.NewMetricsApi), "MonitorsApi": reflect.ValueOf(datadogV2.NewMonitorsApi), "NetworkDeviceMonitoringApi": reflect.ValueOf(datadogV2.NewNetworkDeviceMonitoringApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..46f704ffe2a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:04.509Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..703205d5a8a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_Bad_Request_response.yaml @@ -0,0 +1,23 @@ +interactions: +- request: + body: | + {"test":"bad_request"} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"errors":["API input validation failed: {''_schema'': [{''detail'': ''Object + must include `data` key.'', ''source'': {''pointer'': ''/''}}]}"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.freeze new file mode 100644 index 00000000000..e7d3eb34c15 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:05.128Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.yaml new file mode 100644 index 00000000000..f1fdf8ba4f6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Create_a_restriction_query_returns_OK_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"restriction_query":"env:sandbox"},"type":"logs_restriction_queries"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2b5594f8-c4b3-11f0-a05d-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:05.370176+00:00","modified_at":"2025-11-18T19:17:05.370176+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2b5594f8-c4b3-11f0-a05d-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..606a5c297d1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:06.402Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..4605e1a5348 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id + response: + body: '{"errors":["uuid is not proper type"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.freeze new file mode 100644 index 00000000000..b407dce9fca --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:06.567Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.yaml new file mode 100644 index 00000000000..fd388c48713 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_Not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000 + response: + body: '{"errors":["Restriction query not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.freeze new file mode 100644 index 00000000000..233ffaffa5c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:06.720Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.yaml new file mode 100644 index 00000000000..39e3d6d3a39 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Delete_a_restriction_query_returns_OK_response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"restriction_query":"env:sandbox"},"type":"logs_restriction_queries"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2c373dc2-c4b3-11f0-8ca7-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:06.848316+00:00","modified_at":"2025-11-18T19:17:06.848316+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2c373dc2-c4b3-11f0-8ca7-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2c373dc2-c4b3-11f0-8ca7-da7ad0900002 + response: + body: '{"errors":["Restriction query not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..35466be5038 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:07.277Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..c290bf72abc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id + response: + body: '{"errors":["uuid is not proper type"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.freeze new file mode 100644 index 00000000000..27aff0c3f07 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:07.461Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.yaml new file mode 100644 index 00000000000..99bce8f6cb8 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_Not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000 + response: + body: '{"errors":["Restriction query not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.freeze new file mode 100644 index 00000000000..1f267748178 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:07.622Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.yaml new file mode 100644 index 00000000000..c6a63138491 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_a_restriction_query_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"restriction_query":"env:sandbox"},"type":"logs_restriction_queries"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2cc39998-c4b3-11f0-8b4b-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:07.768188+00:00","modified_at":"2025-11-18T19:17:07.768188+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2cc39998-c4b3-11f0-8b4b-da7ad0900002 + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2cc39998-c4b3-11f0-8b4b-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:07.768188+00:00","modified_at":"2025-11-18T19:17:07.768188+00:00"},"relationships":{"roles":{"data":[]}}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2cc39998-c4b3-11f0-8b4b-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..57b32bd8904 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:08.172Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..759b68eb91c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/user/malformed_id + response: + body: '{"errors":["uuid is not proper type"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.freeze new file mode 100644 index 00000000000..9ee4a5d5206 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:08.336Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.yaml new file mode 100644 index 00000000000..f44e382f45d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_all_restriction_queries_for_a_given_user_returns_Not_found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/user/00000000-0000-0000-0000-000000000000 + response: + body: '{"errors":["user with uuid 00000000-0000-0000-0000-000000000000 doesn''t + exist"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..57897532acf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:08.604Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..ad8831f75f2 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/malformed_id + response: + body: '{"errors":["Missing Role malformed_id"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.freeze new file mode 100644 index 00000000000..bd0df2da885 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:08.828Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.yaml new file mode 100644 index 00000000000..c1b674f6d92 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_Not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/00000000-0000-0000-0000-000000000000 + response: + body: '{"errors":["Missing Role 00000000-0000-0000-0000-000000000000"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.freeze new file mode 100644 index 00000000000..8dc9f697b0c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:08.994Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.yaml new file mode 100644 index 00000000000..2234b4e13f1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Get_restriction_query_for_a_given_role_returns_OK_response.yaml @@ -0,0 +1,56 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"name":"Test-Get_restriction_query_for_a_given_role_returns_OK_response-1763493428"},"type":"roles"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/roles + response: + body: '{"data":{"id":"2d925300-c4b3-11f0-a252-da7ad0900002","type":"roles","attributes":{"created_at":"2025-11-18T19:17:09.12367Z","modified_at":"2025-11-18T19:17:09.123777Z","name":"Test-Get_restriction_query_for_a_given_role_returns_OK_response-1763493428","team_count":0,"user_count":0},"relationships":{"permissions":{"data":[{"id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2","type":"permissions"},{"id":"4441648c-d8b1-11e9-a77a-1b899a04b304","type":"permissions"},{"id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0","type":"permissions"},{"id":"12efc20e-d36c-11eb-a9b8-da7ad0900002","type":"permissions"},{"id":"7605ef24-f376-11eb-b90b-da7ad0900002","type":"permissions"},{"id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002","type":"permissions"},{"id":"f8e941cf-e746-11ec-b22d-da7ad0900002","type":"permissions"},{"id":"6c5ad874-7aff-11ed-a5cd-da7ad0900002","type":"permissions"},{"id":"a8b4d6e8-4ea4-11ee-b482-da7ad0900002","type":"permissions"},{"id":"50c270de-69ee-11ee-9151-da7ad0900002","type":"permissions"}]}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/2d925300-c4b3-11f0-a252-da7ad0900002 + response: + body: '{"data":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/roles/2d925300-c4b3-11f0-a252-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..48cf494a95d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:09.440Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..d0da87342cd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Bad_Request_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"id":"3653d3c6-0c75-11ea-ad28-fb5701eabc7d","type":"roles"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id/roles + response: + body: '{"errors":["Role with id: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.freeze new file mode 100644 index 00000000000..f281a86a45c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:09.623Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.yaml new file mode 100644 index 00000000000..d8757dfea53 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_Not_found_response.yaml @@ -0,0 +1,22 @@ +interactions: +- request: + body: | + {"data":{"id":"3653d3c6-0c75-11ea-ad28-fb5701eabc7d","type":"roles"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000/roles + response: + body: '{"errors":["Role with id: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.freeze new file mode 100644 index 00000000000..ac88614fb58 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:09.783Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.yaml new file mode 100644 index 00000000000..dd770af8939 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_Grant_role_to_a_restriction_query_returns_OK_response.yaml @@ -0,0 +1,96 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"restriction_query":"env:sandbox"},"type":"logs_restriction_queries"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2e0a0abc-c4b3-11f0-9b1d-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:09.907646+00:00","modified_at":"2025-11-18T19:17:09.907646+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"name":"Test-Grant_role_to_a_restriction_query_returns_OK_response-1763493429"},"type":"roles"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/roles + response: + body: '{"data":{"id":"2e209fb6-c4b3-11f0-8483-da7ad0900002","type":"roles","attributes":{"created_at":"2025-11-18T19:17:10.056015Z","modified_at":"2025-11-18T19:17:10.056318Z","name":"Test-Grant_role_to_a_restriction_query_returns_OK_response-1763493429","team_count":0,"user_count":0},"relationships":{"permissions":{"data":[{"id":"d90f6830-d3d8-11e9-a77a-b3404e5e9ee2","type":"permissions"},{"id":"4441648c-d8b1-11e9-a77a-1b899a04b304","type":"permissions"},{"id":"417ba636-2dce-11eb-84c0-6bce5b0d9de0","type":"permissions"},{"id":"12efc20e-d36c-11eb-a9b8-da7ad0900002","type":"permissions"},{"id":"7605ef24-f376-11eb-b90b-da7ad0900002","type":"permissions"},{"id":"b6bf9ac6-9a59-11ec-8480-da7ad0900002","type":"permissions"},{"id":"f8e941cf-e746-11ec-b22d-da7ad0900002","type":"permissions"},{"id":"6c5ad874-7aff-11ed-a5cd-da7ad0900002","type":"permissions"},{"id":"a8b4d6e8-4ea4-11ee-b482-da7ad0900002","type":"permissions"},{"id":"50c270de-69ee-11ee-9151-da7ad0900002","type":"permissions"}]}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: | + {"data":{"id":"2e209fb6-c4b3-11f0-8483-da7ad0900002","type":"roles"}} + form: {} + headers: + Accept: + - '*/*' + Content-Type: + - application/json + id: 2 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2e0a0abc-c4b3-11f0-9b1d-da7ad0900002/roles + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/roles/2e209fb6-c4b3-11f0-8483-da7ad0900002 + 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/logs/config/restriction_queries/2e0a0abc-c4b3-11f0-9b1d-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.freeze new file mode 100644 index 00000000000..d227ca557fa --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:10.912Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.yaml new file mode 100644 index 00000000000..a8572b5acd0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_restriction_queries_returns_OK_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":[{"type":"logs_restriction_queries","id":"6358d012-be7e-11f0-8999-da7ad0900002","attributes":{"restriction_query":"env:production","created_at":"2025-11-10T21:44:09.039708+00:00","modified_at":"2025-11-10T21:44:09.164487+00:00"}}]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..0badf861112 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:11.052Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..a974e75791d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Bad_Request_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id/roles + response: + body: '{"errors":["uuid is not proper type"]}' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.freeze new file mode 100644 index 00000000000..358663320c3 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:11.231Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.yaml new file mode 100644 index 00000000000..27073951251 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_Not_found_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000/roles + response: + body: '{"errors":["Restriction query not found"]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.freeze new file mode 100644 index 00000000000..5e8d0cb60e0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-11-18T19:17:11.376Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.yaml new file mode 100644 index 00000000000..3ef05630367 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Logs_Restriction_Queries/Scenario_List_roles_for_a_restriction_query_returns_OK_response.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"restriction_query":"env:sandbox"},"type":"logs_restriction_queries"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries + response: + body: '{"data":{"type":"logs_restriction_queries","id":"2efc1406-c4b3-11f0-a6d9-da7ad0900002","attributes":{"restriction_query":"env:sandbox","created_at":"2025-11-18T19:17:11.492694+00:00","modified_at":"2025-11-18T19:17:11.492694+00:00"}}} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2efc1406-c4b3-11f0-a6d9-da7ad0900002/roles + response: + body: '{"data":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2efc1406-c4b3-11f0-a6d9-da7ad0900002 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - text/html; charset=utf-8 + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 198c7af1b51..ac2e142e019 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -679,6 +679,18 @@ "tag": "Logs Metrics", "operationId": "CreateLogsMetric" }, + { + "parameters": [ + { + "name": "body", + "value": "{\"data\": {\"attributes\": {\"restriction_query\": \"env:sandbox\"}, \"type\": \"logs_restriction_queries\"}}" + } + ], + "step": "there is a valid \"restriction_query\" in the system", + "key": "restriction_query", + "tag": "Logs Restriction Queries", + "operationId": "CreateRestrictionQuery" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/logs_restriction_queries.feature b/tests/scenarios/features/v2/logs_restriction_queries.feature new file mode 100644 index 00000000000..44d65b92fd5 --- /dev/null +++ b/tests/scenarios/features/v2/logs_restriction_queries.feature @@ -0,0 +1,287 @@ +@endpoint(logs-restriction-queries) @endpoint(logs-restriction-queries-v2) +Feature: Logs Restriction Queries + **Note: This endpoint is in public beta. If you have any feedback, contact + [Datadog support](https://docs.datadoghq.com/help/).** A Restriction + Query is a logs query that restricts which logs the `logs_read_data` + permission grants read access to. For users whose roles have Restriction + Queries, any log query they make only returns those log events that also + match one of their Restriction Queries. This is true whether the user + queries log events from any log-related feature, including the log + explorer, Live Tail, re-hydration, or a dashboard widget. Restriction + Queries currently only support use of the following components of log + events: - Reserved attributes - The log message - Tags To restrict read + access on log data, add a team tag to log events to indicate which teams + own them, and then scope Restriction Queries to the relevant values of the + team tag. Tags can be applied to log events in many ways, and a log event + can have multiple tags with the same key (like team) and different values. + This means the same log event can be visible to roles whose restriction + queries are scoped to different team values. See [How to Set Up RBAC for + Logs](https://docs.datadoghq.com/logs/guide/logs-rbac/?tab=api#restrict- + access-to-logs) for details on how to add restriction queries. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "LogsRestrictionQueries" API + + @skip-go @skip-java @skip-python @skip-ruby @skip-rust @skip-terraform-config @skip-typescript @skip-validation @team:DataDog/logs-app + Scenario: Create a restriction query returns "Bad Request" response + Given operation "CreateRestrictionQuery" enabled + And new "CreateRestrictionQuery" request + And body with value {"test": "bad_request"} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-app + Scenario: Create a restriction query returns "OK" response + Given operation "CreateRestrictionQuery" enabled + And new "CreateRestrictionQuery" request + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 200 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Delete a restriction query returns "Bad Request" response + Given operation "DeleteRestrictionQuery" enabled + And new "DeleteRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + When the request is sent + Then the response status is 400 Bad Request + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Delete a restriction query returns "Not found" response + Given operation "DeleteRestrictionQuery" enabled + And new "DeleteRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-app + Scenario: Delete a restriction query returns "OK" response + Given operation "DeleteRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And new "DeleteRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + When the request is sent + Then the response status is 204 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Get a restriction query returns "Bad Request" response + Given operation "GetRestrictionQuery" enabled + And new "GetRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + When the request is sent + Then the response status is 400 Bad Request + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Get a restriction query returns "Not found" response + Given operation "GetRestrictionQuery" enabled + And new "GetRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-app + Scenario: Get a restriction query returns "OK" response + Given operation "GetRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And new "GetRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + When the request is sent + Then the response status is 200 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Get all restriction queries for a given user returns "Bad Request" response + Given operation "ListUserRestrictionQueries" enabled + And new "ListUserRestrictionQueries" request + And request contains "user_id" parameter with value "malformed_id" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-app + Scenario: Get all restriction queries for a given user returns "Not found" response + Given operation "ListUserRestrictionQueries" enabled + And new "ListUserRestrictionQueries" request + And request contains "user_id" parameter with value "00000000-0000-0000-0000-000000000000" + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/logs-app + Scenario: Get all restriction queries for a given user returns "OK" response + Given operation "ListUserRestrictionQueries" enabled + And there is a valid "user" in the system + And new "ListUserRestrictionQueries" request + And request contains "user_id" parameter from "user.data.id" + When the request is sent + Then the response status is 200 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Get restriction query for a given role returns "Bad Request" response + Given operation "GetRoleRestrictionQuery" enabled + And new "GetRoleRestrictionQuery" request + And request contains "role_id" parameter with value "malformed_id" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-app + Scenario: Get restriction query for a given role returns "Not found" response + Given operation "GetRoleRestrictionQuery" enabled + And new "GetRoleRestrictionQuery" request + And request contains "role_id" parameter with value "00000000-0000-0000-0000-000000000000" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/logs-app + Scenario: Get restriction query for a given role returns "OK" response + Given operation "GetRoleRestrictionQuery" enabled + And there is a valid "role" in the system + And new "GetRoleRestrictionQuery" request + And request contains "role_id" parameter from "role.data.id" + When the request is sent + Then the response status is 200 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Grant role to a restriction query returns "Bad Request" response + Given operation "AddRoleToRestrictionQuery" enabled + And new "AddRoleToRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} + When the request is sent + Then the response status is 404 Not found + + @skip-terraform-config @team:DataDog/logs-app + Scenario: Grant role to a restriction query returns "Not found" response + Given operation "AddRoleToRestrictionQuery" enabled + And new "AddRoleToRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-app + Scenario: Grant role to a restriction query returns "OK" response + Given operation "AddRoleToRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And there is a valid "role" in the system + And new "AddRoleToRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles"}} + When the request is sent + Then the response status is 204 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: List restriction queries returns "OK" response + Given operation "ListRestrictionQueries" enabled + And new "ListRestrictionQueries" request + When the request is sent + Then the response status is 200 OK + + @skip-terraform-config @team:DataDog/logs-app + Scenario: List roles for a restriction query returns "Bad Request" response + Given operation "ListRestrictionQueryRoles" enabled + And new "ListRestrictionQueryRoles" request + And request contains "restriction_query_id" parameter with value "malformed_id" + When the request is sent + Then the response status is 400 Bad Request + + @skip-terraform-config @team:DataDog/logs-app + Scenario: List roles for a restriction query returns "Not found" response + Given operation "ListRestrictionQueryRoles" enabled + And new "ListRestrictionQueryRoles" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + When the request is sent + Then the response status is 404 Not found + + @team:DataDog/logs-app + Scenario: List roles for a restriction query returns "OK" response + Given operation "ListRestrictionQueryRoles" enabled + And there is a valid "restriction_query" in the system + And new "ListRestrictionQueryRoles" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + When the request is sent + Then the response status is 200 OK + + @skip @team:DataDog/logs-app + Scenario: Replace a restriction query returns "Bad Request" response + Given operation "ReplaceRestrictionQuery" enabled + And new "ReplaceRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/logs-app + Scenario: Replace a restriction query returns "Not found" response + Given operation "ReplaceRestrictionQuery" enabled + And new "ReplaceRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 404 Not found + + @skip @team:DataDog/logs-app + Scenario: Replace a restriction query returns "OK" response + Given operation "ReplaceRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And new "ReplaceRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + And body with value {"data": {"attributes": {"restriction_query": "env:staging"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 200 OK + + @skip @skip-terraform-config @team:DataDog/logs-app + Scenario: Revoke role from a restriction query returns "Bad Request" response + Given operation "RemoveRoleFromRestrictionQuery" enabled + And new "RemoveRoleFromRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @skip-terraform-config @team:DataDog/logs-app + Scenario: Revoke role from a restriction query returns "Not found" response + Given operation "RemoveRoleFromRestrictionQuery" enabled + And new "RemoveRoleFromRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + And body with value {"data": {"id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d", "type": "roles"}} + When the request is sent + Then the response status is 404 Not found + + @skip @team:DataDog/logs-app + Scenario: Revoke role from a restriction query returns "OK" response + Given operation "RemoveRoleFromRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And there is a valid "role" in the system + And new "RemoveRoleFromRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + And body with value {"data": {"id": "{{ role.data.id }}", "type": "roles"}} + When the request is sent + Then the response status is 204 OK + + @skip @skip-terraform-config @team:DataDog/logs-app + Scenario: Update a restriction query returns "Bad Request" response + Given operation "UpdateRestrictionQuery" enabled + And new "UpdateRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "malformed_id" + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 400 Bad Request + + @skip @skip-terraform-config @team:DataDog/logs-app + Scenario: Update a restriction query returns "Not found" response + Given operation "UpdateRestrictionQuery" enabled + And new "UpdateRestrictionQuery" request + And request contains "restriction_query_id" parameter with value "00000000-0000-0000-0000-000000000000" + And body with value {"data": {"attributes": {"restriction_query": "env:sandbox"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 404 Not found + + @skip @team:DataDog/logs-app + Scenario: Update a restriction query returns "OK" response + Given operation "UpdateRestrictionQuery" enabled + And there is a valid "restriction_query" in the system + And new "UpdateRestrictionQuery" request + And request contains "restriction_query_id" parameter from "restriction_query.data.id" + And body with value {"data": {"attributes": {"restriction_query": "env:production"}, "type": "logs_restriction_queries"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e630..fefb1b32bb3 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2443,6 +2443,79 @@ "type": "idempotent" } }, + "ListRestrictionQueries": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, + "CreateRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "operationId": "DeleteRestrictionQuery", + "parameters": [ + { + "name": "restriction_query_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "GetRoleRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, + "ListUserRestrictionQueries": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, + "DeleteRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "idempotent" + } + }, + "GetRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, + "UpdateRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "idempotent" + } + }, + "ReplaceRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "idempotent" + } + }, + "RemoveRoleFromRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "idempotent" + } + }, + "ListRestrictionQueryRoles": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, + "AddRoleToRestrictionQuery": { + "tag": "Logs Restriction Queries", + "undo": { + "type": "safe" + } + }, "ListLogsGet": { "tag": "Logs", "undo": {