diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9bceb7154..6bc8997cf 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: @@ -41410,6 +41440,7 @@ components: type: object RelationshipToUserTeamPermissionData: description: Related user team permission data + nullable: true properties: id: description: The ID of the user team permission @@ -41838,6 +41869,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: @@ -51804,7 +52020,11 @@ components: items: description: String identifier of the module type: string + nullable: true type: array + is_managed: + description: Whether the team is managed from an external source + type: boolean link_count: description: The number of links belonging to the team format: int32 @@ -51836,6 +52056,7 @@ components: items: description: String identifier of the module type: string + nullable: true type: array required: - handle @@ -52016,6 +52237,211 @@ components: required: - data type: object + TeamHierarchyLink: + description: Team hierarchy link + properties: + attributes: + $ref: '#/components/schemas/TeamHierarchyLinkAttributes' + id: + description: The team hierarchy link's identifier + example: b8626d7e-cedd-11eb-abf5-da7ad0900001 + type: string + relationships: + $ref: '#/components/schemas/TeamHierarchyLinkRelationships' + type: + $ref: '#/components/schemas/TeamHierarchyLinkType' + required: + - attributes + - id + - type + type: object + TeamHierarchyLinkAttributes: + description: Team hierarchy link attributes + properties: + created_at: + description: Timestamp when the team hierarchy link was created + example: '' + format: date-time + type: string + provisioned_by: + description: The provisioner of the team hierarchy link + example: system + type: string + required: + - provisioned_by + - created_at + type: object + TeamHierarchyLinkCreate: + description: Data provided when creating a team hierarchy link + properties: + relationships: + $ref: '#/components/schemas/TeamHierarchyLinkCreateRelationships' + type: + $ref: '#/components/schemas/TeamHierarchyLinkType' + required: + - relationships + - type + type: object + TeamHierarchyLinkCreateRelationships: + description: The related teams that will be connected by the team hierarchy + link + properties: + parent_team: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeamRelationship' + sub_team: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeamRelationship' + required: + - parent_team + - sub_team + type: object + TeamHierarchyLinkCreateRequest: + description: Request to create a team hierarchy link + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkCreate' + required: + - data + type: object + TeamHierarchyLinkCreateTeam: + description: This schema defines the attributes about each team that has to + be provided when creating a team hierarchy link + properties: + id: + description: The team's identifier + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: string + type: + $ref: '#/components/schemas/TeamType' + required: + - id + - type + type: object + TeamHierarchyLinkCreateTeamRelationship: + description: Data about each team that will be connected by the team hierarchy + link + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkCreateTeam' + required: + - data + type: object + TeamHierarchyLinkRelationships: + description: Team hierarchy link relationships + properties: + parent_team: + $ref: '#/components/schemas/TeamHierarchyLinkTeamRelationship' + sub_team: + $ref: '#/components/schemas/TeamHierarchyLinkTeamRelationship' + required: + - parent_team + - sub_team + type: object + TeamHierarchyLinkResponse: + description: Team hierarchy link response + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLink' + included: + description: Included teams + items: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + type: array + links: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseLinks' + type: object + TeamHierarchyLinkTeam: + description: Team hierarchy links connect different teams. This represents team + objects that are connected by the team hierarchy link. + properties: + attributes: + $ref: '#/components/schemas/TeamHierarchyLinkTeamAttributes' + id: + description: The team's identifier + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: string + type: + $ref: '#/components/schemas/TeamType' + required: + - id + - type + type: object + TeamHierarchyLinkTeamAttributes: + description: Team hierarchy links connect different teams. This represents attributes + from teams that are connected by the team hierarchy link. + properties: + avatar: + description: The team's avatar + nullable: true + type: string + banner: + description: The team's banner + format: int64 + type: integer + handle: + description: The team's handle + example: team-handle + type: string + is_managed: + description: Whether the team is managed + type: boolean + is_open_membership: + description: Whether the team has open membership + type: boolean + link_count: + description: The number of links for the team + format: int64 + type: integer + name: + description: The team's name + example: Team Name + type: string + summary: + description: The team's summary + nullable: true + type: string + user_count: + description: The number of users in the team + format: int64 + type: integer + required: + - handle + - name + type: object + TeamHierarchyLinkTeamRelationship: + description: Team hierarchy link team relationship + properties: + data: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + required: + - data + type: object + TeamHierarchyLinkType: + default: team_hierarchy_links + description: Team hierarchy link type + enum: + - team_hierarchy_links + example: team_hierarchy_links + type: string + x-enum-varnames: + - TEAM_HIERARCHY_LINKS + TeamHierarchyLinksResponse: + description: Team hierarchy links response + properties: + data: + description: Team hierarchy links response data + items: + $ref: '#/components/schemas/TeamHierarchyLink' + type: array + included: + description: Included teams + items: + $ref: '#/components/schemas/TeamHierarchyLinkTeam' + type: array + links: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseLinks' + meta: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseMeta' + type: object TeamIncluded: description: Included resources related to the team oneOf: @@ -52895,6 +53321,76 @@ components: - LINK_COUNT - TEAM_LINKS - USER_TEAM_PERMISSIONS + TeamsHierarchyLinksResponseLinks: + description: When querying team hierarchy links, a set of links for navigation + between different pages is included + properties: + first: + description: Link to the first page. + nullable: true + type: string + last: + description: Link to the last page. + nullable: true + type: string + next: + description: Link to the next page. + nullable: true + type: string + prev: + description: Link to the previous page. + nullable: true + type: string + self: + description: Link to the current object. + type: string + type: object + TeamsHierarchyLinksResponseMeta: + description: Metadata that is included in the response when querying the team + hierarchy links + properties: + page: + $ref: '#/components/schemas/TeamsHierarchyLinksResponseMetaPage' + type: object + TeamsHierarchyLinksResponseMetaPage: + description: Metadata related to paging information that is included in the + response when querying the team hierarchy links + properties: + first_number: + description: First page number. + format: int64 + type: integer + last_number: + description: Last page number. + format: int64 + type: integer + next_number: + description: Next page number. + format: int64 + nullable: true + type: integer + number: + description: Page number. + format: int64 + type: integer + prev_number: + description: Previous page number. + format: int64 + nullable: true + type: integer + size: + description: Page size. + format: int64 + type: integer + total: + description: Total number of results. + format: int64 + type: integer + type: + description: Pagination type. + example: number_size + type: string + type: object TeamsResponse: description: Response with multiple teams properties: @@ -70264,6 +70760,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. @@ -81999,6 +82976,170 @@ paths: permissions: - teams_read - teams_manage + /api/v2/team-hierarchy-links: + get: + description: List all team hierarchy links that match the provided filters. + operationId: ListTeamHierarchyLinks + parameters: + - $ref: '#/components/parameters/PageNumber' + - $ref: '#/components/parameters/PageSize' + - description: Filter by parent team ID + in: query + name: filter[parent_team] + required: false + schema: + type: string + - description: Filter by sub team ID + in: query + name: filter[sub_team] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinksResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get team hierarchy links + tags: + - Teams + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data + x-permission: + operator: OR + permissions: + - teams_read + post: + description: Create a new team hierarchy link between a parent team and a sub + team. + operationId: AddTeamHierarchyLink + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Conflict + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + - teams_manage + summary: Create a team hierarchy link + tags: + - Teams + x-permission: + operator: AND + permissions: + - teams_read + - teams_manage + /api/v2/team-hierarchy-links/{link_id}: + delete: + description: Remove a team hierarchy link by the given link_id. + operationId: RemoveTeamHierarchyLink + parameters: + - description: The team hierarchy link's identifier + in: path + name: link_id + required: true + schema: + type: string + responses: + '204': + description: No Content + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + - teams_manage + summary: Remove a team hierarchy link + tags: + - Teams + x-permission: + operator: AND + permissions: + - teams_read + - teams_manage + get: + description: Get a single team hierarchy link for the given link_id. + operationId: GetTeamHierarchyLink + parameters: + - description: The team hierarchy link's identifier + in: path + name: link_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TeamHierarchyLinkResponse' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: API error response. + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get a team hierarchy link + tags: + - Teams + x-permission: + operator: OR + permissions: + - teams_read /api/v2/team/connections: delete: description: Delete multiple team connections. @@ -82273,7 +83414,13 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/{super_team_id}/member_teams: get: - description: Get all member teams. + deprecated: true + description: 'Get all member teams. + + + **Note**: This API is deprecated. For team hierarchy relationships (parent-child + + teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`.' operationId: ListMemberTeams parameters: - description: None @@ -82326,14 +83473,20 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: + deprecated: true description: 'Add a member team. Adds the team given by the `id` in the body as a member team of the super - team.' + team. + + + **Note**: This API is deprecated. For creating team hierarchy links, use the + team hierarchy links API: `POST /api/v2/team-hierarchy-links`.' operationId: AddMemberTeam parameters: - description: None @@ -82373,12 +83526,18 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/team/{super_team_id}/member_teams/{member_team_id}: delete: - description: Remove a super team's member team identified by `member_team_id`. + deprecated: true + description: 'Remove a super team''s member team identified by `member_team_id`. + + + **Note**: This API is deprecated. For deleting team hierarchy links, use the + team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`.' operationId: RemoveMemberTeam parameters: - description: None @@ -82418,6 +83577,7 @@ paths: operator: OR permissions: - teams_read + x-sunset: '2026-06-01' x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -85210,6 +86370,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/examples/v2_logs-restriction-queries_AddRoleToRestrictionQuery.rs b/examples/v2_logs-restriction-queries_AddRoleToRestrictionQuery.rs new file mode 100644 index 000000000..6dbbd2afe --- /dev/null +++ b/examples/v2_logs-restriction-queries_AddRoleToRestrictionQuery.rs @@ -0,0 +1,31 @@ +// Grant role to a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; +use datadog_api_client::datadogV2::model::RelationshipToRole; +use datadog_api_client::datadogV2::model::RelationshipToRoleData; +use datadog_api_client::datadogV2::model::RolesType; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + + // there is a valid "role" in the system + let role_data_id = std::env::var("ROLE_DATA_ID").unwrap(); + let body = RelationshipToRole::new().data( + RelationshipToRoleData::new() + .id(role_data_id.clone()) + .type_(RolesType::ROLES), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.AddRoleToRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .add_role_to_restriction_query(restriction_query_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_CreateRestrictionQuery.rs b/examples/v2_logs-restriction-queries_CreateRestrictionQuery.rs new file mode 100644 index 000000000..9e2a79eae --- /dev/null +++ b/examples/v2_logs-restriction-queries_CreateRestrictionQuery.rs @@ -0,0 +1,27 @@ +// Create a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; +use datadog_api_client::datadogV2::model::LogsRestrictionQueriesType; +use datadog_api_client::datadogV2::model::RestrictionQueryCreateAttributes; +use datadog_api_client::datadogV2::model::RestrictionQueryCreateData; +use datadog_api_client::datadogV2::model::RestrictionQueryCreatePayload; + +#[tokio::main] +async fn main() { + let body = RestrictionQueryCreatePayload::new().data( + RestrictionQueryCreateData::new() + .attributes(RestrictionQueryCreateAttributes::new( + "env:sandbox".to_string(), + )) + .type_(LogsRestrictionQueriesType::LOGS_RESTRICTION_QUERIES), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api.create_restriction_query(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_DeleteRestrictionQuery.rs b/examples/v2_logs-restriction-queries_DeleteRestrictionQuery.rs new file mode 100644 index 000000000..a70b1634f --- /dev/null +++ b/examples/v2_logs-restriction-queries_DeleteRestrictionQuery.rs @@ -0,0 +1,20 @@ +// Delete a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .delete_restriction_query(restriction_query_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_GetRestrictionQuery.rs b/examples/v2_logs-restriction-queries_GetRestrictionQuery.rs new file mode 100644 index 000000000..a28e09fe3 --- /dev/null +++ b/examples/v2_logs-restriction-queries_GetRestrictionQuery.rs @@ -0,0 +1,20 @@ +// Get a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .get_restriction_query(restriction_query_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_GetRoleRestrictionQuery.rs b/examples/v2_logs-restriction-queries_GetRoleRestrictionQuery.rs new file mode 100644 index 000000000..188849bf9 --- /dev/null +++ b/examples/v2_logs-restriction-queries_GetRoleRestrictionQuery.rs @@ -0,0 +1,18 @@ +// Get restriction query for a given role returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "role" in the system + let role_data_id = std::env::var("ROLE_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetRoleRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api.get_role_restriction_query(role_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_ListRestrictionQueries.rs b/examples/v2_logs-restriction-queries_ListRestrictionQueries.rs new file mode 100644 index 000000000..d43079712 --- /dev/null +++ b/examples/v2_logs-restriction-queries_ListRestrictionQueries.rs @@ -0,0 +1,19 @@ +// List restriction queries returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::ListRestrictionQueriesOptionalParams; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListRestrictionQueries", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .list_restriction_queries(ListRestrictionQueriesOptionalParams::default()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_ListRestrictionQueryRoles.rs b/examples/v2_logs-restriction-queries_ListRestrictionQueryRoles.rs new file mode 100644 index 000000000..779add7ad --- /dev/null +++ b/examples/v2_logs-restriction-queries_ListRestrictionQueryRoles.rs @@ -0,0 +1,24 @@ +// List roles for a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::ListRestrictionQueryRolesOptionalParams; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListRestrictionQueryRoles", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .list_restriction_query_roles( + restriction_query_data_id.clone(), + ListRestrictionQueryRolesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_ListUserRestrictionQueries.rs b/examples/v2_logs-restriction-queries_ListUserRestrictionQueries.rs new file mode 100644 index 000000000..305fdbdea --- /dev/null +++ b/examples/v2_logs-restriction-queries_ListUserRestrictionQueries.rs @@ -0,0 +1,20 @@ +// Get all restriction queries for a given user returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "user" in the system + let user_data_id = std::env::var("USER_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListUserRestrictionQueries", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .list_user_restriction_queries(user_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_RemoveRoleFromRestrictionQuery.rs b/examples/v2_logs-restriction-queries_RemoveRoleFromRestrictionQuery.rs new file mode 100644 index 000000000..492443be4 --- /dev/null +++ b/examples/v2_logs-restriction-queries_RemoveRoleFromRestrictionQuery.rs @@ -0,0 +1,31 @@ +// Revoke role from a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; +use datadog_api_client::datadogV2::model::RelationshipToRole; +use datadog_api_client::datadogV2::model::RelationshipToRoleData; +use datadog_api_client::datadogV2::model::RolesType; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + + // there is a valid "role" in the system + let role_data_id = std::env::var("ROLE_DATA_ID").unwrap(); + let body = RelationshipToRole::new().data( + RelationshipToRoleData::new() + .id(role_data_id.clone()) + .type_(RolesType::ROLES), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.RemoveRoleFromRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .remove_role_from_restriction_query(restriction_query_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_ReplaceRestrictionQuery.rs b/examples/v2_logs-restriction-queries_ReplaceRestrictionQuery.rs new file mode 100644 index 000000000..5caf7389e --- /dev/null +++ b/examples/v2_logs-restriction-queries_ReplaceRestrictionQuery.rs @@ -0,0 +1,31 @@ +// Replace a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; +use datadog_api_client::datadogV2::model::LogsRestrictionQueriesType; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdateAttributes; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdateData; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdatePayload; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + let body = RestrictionQueryUpdatePayload::new().data( + RestrictionQueryUpdateData::new() + .attributes(RestrictionQueryUpdateAttributes::new( + "env:staging".to_string(), + )) + .type_(LogsRestrictionQueriesType::LOGS_RESTRICTION_QUERIES), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ReplaceRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .replace_restriction_query(restriction_query_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_logs-restriction-queries_UpdateRestrictionQuery.rs b/examples/v2_logs-restriction-queries_UpdateRestrictionQuery.rs new file mode 100644 index 000000000..181d94c81 --- /dev/null +++ b/examples/v2_logs-restriction-queries_UpdateRestrictionQuery.rs @@ -0,0 +1,31 @@ +// Update a restriction query returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI; +use datadog_api_client::datadogV2::model::LogsRestrictionQueriesType; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdateAttributes; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdateData; +use datadog_api_client::datadogV2::model::RestrictionQueryUpdatePayload; + +#[tokio::main] +async fn main() { + // there is a valid "restriction_query" in the system + let restriction_query_data_id = std::env::var("RESTRICTION_QUERY_DATA_ID").unwrap(); + let body = RestrictionQueryUpdatePayload::new().data( + RestrictionQueryUpdateData::new() + .attributes(RestrictionQueryUpdateAttributes::new( + "env:production".to_string(), + )) + .type_(LogsRestrictionQueriesType::LOGS_RESTRICTION_QUERIES), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateRestrictionQuery", true); + let api = LogsRestrictionQueriesAPI::with_config(configuration); + let resp = api + .update_restriction_query(restriction_query_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_AddTeamHierarchyLink.rs b/examples/v2_teams_AddTeamHierarchyLink.rs new file mode 100644 index 000000000..96cc215bd --- /dev/null +++ b/examples/v2_teams_AddTeamHierarchyLink.rs @@ -0,0 +1,40 @@ +// Create a team hierarchy link returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreate; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRelationships; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateRequest; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeam; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship; +use datadog_api_client::datadogV2::model::TeamHierarchyLinkType; +use datadog_api_client::datadogV2::model::TeamType; + +#[tokio::main] +async fn main() { + // there is a valid "dd_team" in the system + let dd_team_data_id = std::env::var("DD_TEAM_DATA_ID").unwrap(); + + // there is a valid "dd_team_2" in the system + let dd_team_2_data_id = std::env::var("DD_TEAM_2_DATA_ID").unwrap(); + let body = TeamHierarchyLinkCreateRequest::new(TeamHierarchyLinkCreate::new( + TeamHierarchyLinkCreateRelationships::new( + TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new( + dd_team_data_id.clone(), + TeamType::TEAM, + )), + TeamHierarchyLinkCreateTeamRelationship::new(TeamHierarchyLinkCreateTeam::new( + dd_team_2_data_id.clone(), + TeamType::TEAM, + )), + ), + TeamHierarchyLinkType::TEAM_HIERARCHY_LINKS, + )); + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api.add_team_hierarchy_link(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_GetTeamHierarchyLink.rs b/examples/v2_teams_GetTeamHierarchyLink.rs new file mode 100644 index 000000000..251d1dbe1 --- /dev/null +++ b/examples/v2_teams_GetTeamHierarchyLink.rs @@ -0,0 +1,19 @@ +// Get a team hierarchy link returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + // there is a valid "team_hierarchy_link" in the system + let team_hierarchy_link_data_id = std::env::var("TEAM_HIERARCHY_LINK_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api + .get_team_hierarchy_link(team_hierarchy_link_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_ListTeamHierarchyLinks.rs b/examples/v2_teams_ListTeamHierarchyLinks.rs new file mode 100644 index 000000000..8aa10624f --- /dev/null +++ b/examples/v2_teams_ListTeamHierarchyLinks.rs @@ -0,0 +1,31 @@ +// Get team hierarchy links returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::ListTeamHierarchyLinksOptionalParams; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + // there is a valid "team_hierarchy_link" in the system + let team_hierarchy_link_data_relationships_parent_team_data_id = + std::env::var("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_PARENT_TEAM_DATA_ID").unwrap(); + let team_hierarchy_link_data_relationships_sub_team_data_id = + std::env::var("TEAM_HIERARCHY_LINK_DATA_RELATIONSHIPS_SUB_TEAM_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api + .list_team_hierarchy_links( + ListTeamHierarchyLinksOptionalParams::default() + .filter_parent_team( + team_hierarchy_link_data_relationships_parent_team_data_id.clone(), + ) + .filter_sub_team(team_hierarchy_link_data_relationships_sub_team_data_id.clone()) + .page_number(0) + .page_size(100), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_teams_ListTeamHierarchyLinks_3360757486.rs b/examples/v2_teams_ListTeamHierarchyLinks_3360757486.rs new file mode 100644 index 000000000..0b30bfaaf --- /dev/null +++ b/examples/v2_teams_ListTeamHierarchyLinks_3360757486.rs @@ -0,0 +1,22 @@ +// Get team hierarchy links returns "OK" response with pagination +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::ListTeamHierarchyLinksOptionalParams; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; +use futures_util::pin_mut; +use futures_util::stream::StreamExt; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let response = api + .list_team_hierarchy_links_with_pagination(ListTeamHierarchyLinksOptionalParams::default()); + pin_mut!(response); + while let Some(resp) = response.next().await { + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } + } +} diff --git a/examples/v2_teams_RemoveTeamHierarchyLink.rs b/examples/v2_teams_RemoveTeamHierarchyLink.rs new file mode 100644 index 000000000..3b4d60fca --- /dev/null +++ b/examples/v2_teams_RemoveTeamHierarchyLink.rs @@ -0,0 +1,19 @@ +// Remove a team hierarchy link returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_teams::TeamsAPI; + +#[tokio::main] +async fn main() { + // there is a valid "team_hierarchy_link" in the system + let team_hierarchy_link_data_id = std::env::var("TEAM_HIERARCHY_LINK_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = TeamsAPI::with_config(configuration); + let resp = api + .remove_team_hierarchy_link(team_hierarchy_link_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 5c3264b0a..1ad54d180 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -218,6 +218,17 @@ impl Default for Configuration { ("v2.update_incident_notification_template".to_owned(), false), ("v2.update_incident_todo".to_owned(), false), ("v2.update_incident_type".to_owned(), false), + ("v2.add_role_to_restriction_query".to_owned(), false), + ("v2.create_restriction_query".to_owned(), false), + ("v2.delete_restriction_query".to_owned(), false), + ("v2.get_restriction_query".to_owned(), false), + ("v2.get_role_restriction_query".to_owned(), false), + ("v2.list_restriction_queries".to_owned(), false), + ("v2.list_restriction_query_roles".to_owned(), false), + ("v2.list_user_restriction_queries".to_owned(), false), + ("v2.remove_role_from_restriction_query".to_owned(), false), + ("v2.replace_restriction_query".to_owned(), false), + ("v2.update_restriction_query".to_owned(), false), ("v2.create_monitor_user_template".to_owned(), false), ("v2.delete_monitor_user_template".to_owned(), false), ("v2.get_monitor_user_template".to_owned(), false), diff --git a/src/datadogV2/api/api_logs_restriction_queries.rs b/src/datadogV2/api/api_logs_restriction_queries.rs new file mode 100644 index 000000000..6e986a658 --- /dev/null +++ b/src/datadogV2/api/api_logs_restriction_queries.rs @@ -0,0 +1,1759 @@ +// 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. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// ListRestrictionQueriesOptionalParams is a struct for passing parameters to the method [`LogsRestrictionQueriesAPI::list_restriction_queries`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListRestrictionQueriesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Specific page number to return. + pub page_number: Option, +} + +impl ListRestrictionQueriesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } +} + +/// ListRestrictionQueryRolesOptionalParams is a struct for passing parameters to the method [`LogsRestrictionQueriesAPI::list_restriction_query_roles`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListRestrictionQueryRolesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Specific page number to return. + pub page_number: Option, +} + +impl ListRestrictionQueryRolesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } +} + +/// AddRoleToRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::add_role_to_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddRoleToRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::create_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::delete_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::get_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetRoleRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::get_role_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetRoleRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListRestrictionQueriesError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::list_restriction_queries`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListRestrictionQueriesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListRestrictionQueryRolesError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::list_restriction_query_roles`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListRestrictionQueryRolesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListUserRestrictionQueriesError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::list_user_restriction_queries`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListUserRestrictionQueriesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// RemoveRoleFromRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::remove_role_from_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RemoveRoleFromRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ReplaceRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::replace_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ReplaceRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateRestrictionQueryError is a struct for typed errors of method [`LogsRestrictionQueriesAPI::update_restriction_query`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateRestrictionQueryError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// **Note: This endpoint is in public beta. If you have any feedback, contact [Datadog support]().** +/// +/// 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]() for details on how to add restriction queries. +#[derive(Debug, Clone)] +pub struct LogsRestrictionQueriesAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for LogsRestrictionQueriesAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl LogsRestrictionQueriesAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// 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. + pub async fn add_role_to_restriction_query( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RelationshipToRole, + ) -> Result<(), datadog::Error> { + match self + .add_role_to_restriction_query_with_http_info(restriction_query_id, body) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// 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. + pub async fn add_role_to_restriction_query_with_http_info( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RelationshipToRole, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.add_role_to_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.add_role_to_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create a new restriction query for your organization. + pub async fn create_restriction_query( + &self, + body: crate::datadogV2::model::RestrictionQueryCreatePayload, + ) -> Result< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + datadog::Error, + > { + match self.create_restriction_query_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new restriction query for your organization. + pub async fn create_restriction_query_with_http_info( + &self, + body: crate::datadogV2::model::RestrictionQueryCreatePayload, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a restriction query. + pub async fn delete_restriction_query( + &self, + restriction_query_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_restriction_query_with_http_info(restriction_query_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a restriction query. + pub async fn delete_restriction_query_with_http_info( + &self, + restriction_query_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a restriction query in the organization specified by the restriction query's `restriction_query_id`. + pub async fn get_restriction_query( + &self, + restriction_query_id: String, + ) -> Result< + crate::datadogV2::model::RestrictionQueryWithRelationshipsResponse, + datadog::Error, + > { + match self + .get_restriction_query_with_http_info(restriction_query_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a restriction query in the organization specified by the restriction query's `restriction_query_id`. + pub async fn get_restriction_query_with_http_info( + &self, + restriction_query_id: String, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::RestrictionQueryWithRelationshipsResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::RestrictionQueryWithRelationshipsResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get restriction query for a given role. + pub async fn get_role_restriction_query( + &self, + role_id: String, + ) -> Result< + crate::datadogV2::model::RestrictionQueryListResponse, + datadog::Error, + > { + match self + .get_role_restriction_query_with_http_info(role_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get restriction query for a given role. + pub async fn get_role_restriction_query_with_http_info( + &self, + role_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_role_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_role_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/role/{role_id}", + local_configuration.get_operation_host(operation_id), + role_id = datadog::urlencode(role_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Returns all restriction queries, including their names and IDs. + pub async fn list_restriction_queries( + &self, + params: ListRestrictionQueriesOptionalParams, + ) -> Result< + crate::datadogV2::model::RestrictionQueryListResponse, + datadog::Error, + > { + match self.list_restriction_queries_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Returns all restriction queries, including their names and IDs. + pub async fn list_restriction_queries_with_http_info( + &self, + params: ListRestrictionQueriesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_restriction_queries"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_restriction_queries' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Returns all roles that have a given restriction query. + pub async fn list_restriction_query_roles( + &self, + restriction_query_id: String, + params: ListRestrictionQueryRolesOptionalParams, + ) -> Result< + crate::datadogV2::model::RestrictionQueryRolesResponse, + datadog::Error, + > { + match self + .list_restriction_query_roles_with_http_info(restriction_query_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Returns all roles that have a given restriction query. + pub async fn list_restriction_query_roles_with_http_info( + &self, + restriction_query_id: String, + params: ListRestrictionQueryRolesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_restriction_query_roles"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_restriction_query_roles' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get all restriction queries for a given user. + pub async fn list_user_restriction_queries( + &self, + user_id: String, + ) -> Result< + crate::datadogV2::model::RestrictionQueryListResponse, + datadog::Error, + > { + match self + .list_user_restriction_queries_with_http_info(user_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get all restriction queries for a given user. + pub async fn list_user_restriction_queries_with_http_info( + &self, + user_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_user_restriction_queries"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_user_restriction_queries' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/user/{user_id}", + local_configuration.get_operation_host(operation_id), + user_id = datadog::urlencode(user_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Removes a role from a restriction query. + pub async fn remove_role_from_restriction_query( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RelationshipToRole, + ) -> Result<(), datadog::Error> { + match self + .remove_role_from_restriction_query_with_http_info(restriction_query_id, body) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Removes a role from a restriction query. + pub async fn remove_role_from_restriction_query_with_http_info( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RelationshipToRole, + ) -> Result, datadog::Error> + { + let local_configuration = &self.config; + let operation_id = "v2.remove_role_from_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.remove_role_from_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}/roles", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Replace a restriction query. + pub async fn replace_restriction_query( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RestrictionQueryUpdatePayload, + ) -> Result< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + datadog::Error, + > { + match self + .replace_restriction_query_with_http_info(restriction_query_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Replace a restriction query. + pub async fn replace_restriction_query_with_http_info( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RestrictionQueryUpdatePayload, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.replace_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.replace_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Edit a restriction query. + pub async fn update_restriction_query( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RestrictionQueryUpdatePayload, + ) -> Result< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + datadog::Error, + > { + match self + .update_restriction_query_with_http_info(restriction_query_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Edit a restriction query. + pub async fn update_restriction_query_with_http_info( + &self, + restriction_query_id: String, + body: crate::datadogV2::model::RestrictionQueryUpdatePayload, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_restriction_query"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_restriction_query' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/logs/config/restriction_queries/{restriction_query_id}", + local_configuration.get_operation_host(operation_id), + restriction_query_id = datadog::urlencode(restriction_query_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::< + crate::datadogV2::model::RestrictionQueryWithoutRelationshipsResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/api_teams.rs b/src/datadogV2/api/api_teams.rs index edad90efc..76b007a60 100644 --- a/src/datadogV2/api/api_teams.rs +++ b/src/datadogV2/api/api_teams.rs @@ -80,6 +80,43 @@ impl ListMemberTeamsOptionalParams { } } +/// ListTeamHierarchyLinksOptionalParams is a struct for passing parameters to the method [`TeamsAPI::list_team_hierarchy_links`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListTeamHierarchyLinksOptionalParams { + /// Specific page number to return. + pub page_number: Option, + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Filter by parent team ID + pub filter_parent_team: Option, + /// Filter by sub team ID + pub filter_sub_team: Option, +} + +impl ListTeamHierarchyLinksOptionalParams { + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } + /// Size for a given page. The maximum allowed value is 100. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Filter by parent team ID + pub fn filter_parent_team(mut self, value: String) -> Self { + self.filter_parent_team = Some(value); + self + } + /// Filter by sub team ID + pub fn filter_sub_team(mut self, value: String) -> Self { + self.filter_sub_team = Some(value); + self + } +} + /// ListTeamsOptionalParams is a struct for passing parameters to the method [`TeamsAPI::list_teams`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -146,6 +183,14 @@ pub enum AddMemberTeamError { UnknownValue(serde_json::Value), } +/// AddTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::add_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AddTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateTeamError is a struct for typed errors of method [`TeamsAPI::create_team`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -202,6 +247,14 @@ pub enum GetTeamError { UnknownValue(serde_json::Value), } +/// GetTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::get_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetTeamLinkError is a struct for typed errors of method [`TeamsAPI::get_team_link`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -258,6 +311,14 @@ pub enum ListMemberTeamsError { UnknownValue(serde_json::Value), } +/// ListTeamHierarchyLinksError is a struct for typed errors of method [`TeamsAPI::list_team_hierarchy_links`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListTeamHierarchyLinksError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListTeamsError is a struct for typed errors of method [`TeamsAPI::list_teams`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -274,6 +335,14 @@ pub enum RemoveMemberTeamError { UnknownValue(serde_json::Value), } +/// RemoveTeamHierarchyLinkError is a struct for typed errors of method [`TeamsAPI::remove_team_hierarchy_link`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RemoveTeamHierarchyLinkError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// SyncTeamsError is a struct for typed errors of method [`TeamsAPI::sync_teams`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -381,6 +450,8 @@ impl TeamsAPI { /// Add a member team. /// Adds the team given by the `id` in the body as a member team of the super team. + /// + /// **Note**: This API is deprecated. For creating team hierarchy links, use the team hierarchy links API: `POST /api/v2/team-hierarchy-links`. pub async fn add_member_team( &self, super_team_id: String, @@ -397,6 +468,8 @@ impl TeamsAPI { /// Add a member team. /// Adds the team given by the `id` in the body as a member team of the super team. + /// + /// **Note**: This API is deprecated. For creating team hierarchy links, use the team hierarchy links API: `POST /api/v2/team-hierarchy-links`. pub async fn add_member_team_with_http_info( &self, super_team_id: String, @@ -528,6 +601,160 @@ impl TeamsAPI { } } + /// Create a new team hierarchy link between a parent team and a sub team. + pub async fn add_team_hierarchy_link( + &self, + body: crate::datadogV2::model::TeamHierarchyLinkCreateRequest, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinkResponse, + datadog::Error, + > { + match self.add_team_hierarchy_link_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new team hierarchy link between a parent team and a sub team. + pub async fn add_team_hierarchy_link_with_http_info( + &self, + body: crate::datadogV2::model::TeamHierarchyLinkCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.add_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Create a new team. /// User IDs passed through the `users` relationship field are added to the team. pub async fn create_team( @@ -1364,6 +1591,115 @@ impl TeamsAPI { } } + /// Get a single team hierarchy link for the given link_id. + pub async fn get_team_hierarchy_link( + &self, + link_id: String, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinkResponse, + datadog::Error, + > { + match self.get_team_hierarchy_link_with_http_info(link_id).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a single team hierarchy link for the given link_id. + pub async fn get_team_hierarchy_link_with_http_info( + &self, + link_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links/{link_id}", + local_configuration.get_operation_host(operation_id), + link_id = datadog::urlencode(link_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get a single link for a team. pub async fn get_team_link( &self, @@ -2079,6 +2415,9 @@ impl TeamsAPI { } /// Get all member teams. + /// + /// **Note**: This API is deprecated. For team hierarchy relationships (parent-child + /// teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`. pub async fn list_member_teams( &self, super_team_id: String, @@ -2137,6 +2476,9 @@ impl TeamsAPI { } /// Get all member teams. + /// + /// **Note**: This API is deprecated. For team hierarchy relationships (parent-child + /// teams), use the team hierarchy links API: `GET /api/v2/team-hierarchy-links`. pub async fn list_member_teams_with_http_info( &self, super_team_id: String, @@ -2255,6 +2597,174 @@ impl TeamsAPI { } } + /// List all team hierarchy links that match the provided filters. + pub async fn list_team_hierarchy_links( + &self, + params: ListTeamHierarchyLinksOptionalParams, + ) -> Result< + crate::datadogV2::model::TeamHierarchyLinksResponse, + datadog::Error, + > { + match self.list_team_hierarchy_links_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + pub fn list_team_hierarchy_links_with_pagination( + &self, + mut params: ListTeamHierarchyLinksOptionalParams, + ) -> impl Stream< + Item = Result< + crate::datadogV2::model::TeamHierarchyLink, + datadog::Error, + >, + > + '_ { + try_stream! { + let mut page_size: i64 = 10; + if params.page_size.is_none() { + params.page_size = Some(page_size); + } else { + page_size = params.page_size.unwrap().clone(); + } + if params.page_number.is_none() { + params.page_number = Some(0); + } + loop { + let resp = self.list_team_hierarchy_links(params.clone()).await?; + let Some(data) = resp.data else { break }; + + let r = data; + let count = r.len(); + for team in r { + yield team; + } + + if count < page_size as usize { + break; + } + params.page_number = Some(params.page_number.unwrap() + 1); + } + } + } + + /// List all team hierarchy links that match the provided filters. + pub async fn list_team_hierarchy_links_with_http_info( + &self, + params: ListTeamHierarchyLinksOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_team_hierarchy_links"; + + // unbox and build optional parameters + let page_number = params.page_number; + let page_size = params.page_size; + let filter_parent_team = params.filter_parent_team; + let filter_sub_team = params.filter_sub_team; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_parent_team { + local_req_builder = + local_req_builder.query(&[("filter[parent_team]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_sub_team { + local_req_builder = + local_req_builder.query(&[("filter[sub_team]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// Get all teams. /// Can be used to search for teams using the `filter[keyword]` and `filter[me]` query parameters. pub async fn list_teams( @@ -2439,6 +2949,8 @@ impl TeamsAPI { } /// Remove a super team's member team identified by `member_team_id`. + /// + /// **Note**: This API is deprecated. For deleting team hierarchy links, use the team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`. pub async fn remove_member_team( &self, super_team_id: String, @@ -2454,6 +2966,8 @@ impl TeamsAPI { } /// Remove a super team's member team identified by `member_team_id`. + /// + /// **Note**: This API is deprecated. For deleting team hierarchy links, use the team hierarchy links API: `DELETE /api/v2/team-hierarchy-links/{link_id}`. pub async fn remove_member_team_with_http_info( &self, super_team_id: String, @@ -2540,6 +3054,97 @@ impl TeamsAPI { } } + /// Remove a team hierarchy link by the given link_id. + pub async fn remove_team_hierarchy_link( + &self, + link_id: String, + ) -> Result<(), datadog::Error> { + match self + .remove_team_hierarchy_link_with_http_info(link_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Remove a team hierarchy link by the given link_id. + pub async fn remove_team_hierarchy_link_with_http_info( + &self, + link_id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.remove_team_hierarchy_link"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/team-hierarchy-links/{link_id}", + local_configuration.get_operation_host(operation_id), + link_id = datadog::urlencode(link_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + /// This endpoint attempts to link your existing Datadog teams with GitHub teams by matching their names. /// It evaluates all current Datadog teams and compares them against teams in the GitHub organization /// connected to your Datadog account, based on Datadog Team handle and GitHub Team slug diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 7bbcc20df..781193222 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -48,6 +48,7 @@ pub mod api_logs; pub mod api_logs_archives; pub mod api_logs_custom_destinations; pub mod api_logs_metrics; +pub mod api_logs_restriction_queries; pub mod api_metrics; pub mod api_microsoft_teams_integration; pub mod api_monitors; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 693245a42..923ec2506 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -49,6 +49,7 @@ pub use self::api::api_logs; pub use self::api::api_logs_archives; pub use self::api::api_logs_custom_destinations; pub use self::api::api_logs_metrics; +pub use self::api::api_logs_restriction_queries; pub use self::api::api_metrics; pub use self::api::api_microsoft_teams_integration; pub use self::api::api_monitors; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 19b16a61f..a95f0e302 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3564,6 +3564,42 @@ pub mod model_logs_metric_update_attributes; pub use self::model_logs_metric_update_attributes::LogsMetricUpdateAttributes; pub mod model_logs_metric_update_compute; pub use self::model_logs_metric_update_compute::LogsMetricUpdateCompute; +pub mod model_restriction_query_list_response; +pub use self::model_restriction_query_list_response::RestrictionQueryListResponse; +pub mod model_restriction_query_without_relationships; +pub use self::model_restriction_query_without_relationships::RestrictionQueryWithoutRelationships; +pub mod model_restriction_query_attributes; +pub use self::model_restriction_query_attributes::RestrictionQueryAttributes; +pub mod model_restriction_query_create_payload; +pub use self::model_restriction_query_create_payload::RestrictionQueryCreatePayload; +pub mod model_restriction_query_create_data; +pub use self::model_restriction_query_create_data::RestrictionQueryCreateData; +pub mod model_restriction_query_create_attributes; +pub use self::model_restriction_query_create_attributes::RestrictionQueryCreateAttributes; +pub mod model_logs_restriction_queries_type; +pub use self::model_logs_restriction_queries_type::LogsRestrictionQueriesType; +pub mod model_restriction_query_without_relationships_response; +pub use self::model_restriction_query_without_relationships_response::RestrictionQueryWithoutRelationshipsResponse; +pub mod model_restriction_query_with_relationships_response; +pub use self::model_restriction_query_with_relationships_response::RestrictionQueryWithRelationshipsResponse; +pub mod model_restriction_query_with_relationships; +pub use self::model_restriction_query_with_relationships::RestrictionQueryWithRelationships; +pub mod model_user_relationships; +pub use self::model_user_relationships::UserRelationships; +pub mod model_restriction_query_role; +pub use self::model_restriction_query_role::RestrictionQueryRole; +pub mod model_restriction_query_role_attribute; +pub use self::model_restriction_query_role_attribute::RestrictionQueryRoleAttribute; +pub mod model_restriction_query_response_included_item; +pub use self::model_restriction_query_response_included_item::RestrictionQueryResponseIncludedItem; +pub mod model_restriction_query_update_payload; +pub use self::model_restriction_query_update_payload::RestrictionQueryUpdatePayload; +pub mod model_restriction_query_update_data; +pub use self::model_restriction_query_update_data::RestrictionQueryUpdateData; +pub mod model_restriction_query_update_attributes; +pub use self::model_restriction_query_update_attributes::RestrictionQueryUpdateAttributes; +pub mod model_restriction_query_roles_response; +pub use self::model_restriction_query_roles_response::RestrictionQueryRolesResponse; pub mod model_logs_sort; pub use self::model_logs_sort::LogsSort; pub mod model_logs_list_response; @@ -6120,8 +6156,6 @@ pub mod model_service_account_create_data; pub use self::model_service_account_create_data::ServiceAccountCreateData; pub mod model_service_account_create_attributes; pub use self::model_service_account_create_attributes::ServiceAccountCreateAttributes; -pub mod model_user_relationships; -pub use self::model_user_relationships::UserRelationships; pub mod model_user_response; pub use self::model_user_response::UserResponse; pub mod model_partial_application_key_response; @@ -6656,6 +6690,40 @@ pub mod model_team_create_relationships; pub use self::model_team_create_relationships::TeamCreateRelationships; pub mod model_team_response; pub use self::model_team_response::TeamResponse; +pub mod model_team_hierarchy_links_response; +pub use self::model_team_hierarchy_links_response::TeamHierarchyLinksResponse; +pub mod model_team_hierarchy_link; +pub use self::model_team_hierarchy_link::TeamHierarchyLink; +pub mod model_team_hierarchy_link_attributes; +pub use self::model_team_hierarchy_link_attributes::TeamHierarchyLinkAttributes; +pub mod model_team_hierarchy_link_relationships; +pub use self::model_team_hierarchy_link_relationships::TeamHierarchyLinkRelationships; +pub mod model_team_hierarchy_link_team_relationship; +pub use self::model_team_hierarchy_link_team_relationship::TeamHierarchyLinkTeamRelationship; +pub mod model_team_hierarchy_link_team; +pub use self::model_team_hierarchy_link_team::TeamHierarchyLinkTeam; +pub mod model_team_hierarchy_link_team_attributes; +pub use self::model_team_hierarchy_link_team_attributes::TeamHierarchyLinkTeamAttributes; +pub mod model_team_hierarchy_link_type; +pub use self::model_team_hierarchy_link_type::TeamHierarchyLinkType; +pub mod model_teams_hierarchy_links_response_links; +pub use self::model_teams_hierarchy_links_response_links::TeamsHierarchyLinksResponseLinks; +pub mod model_teams_hierarchy_links_response_meta; +pub use self::model_teams_hierarchy_links_response_meta::TeamsHierarchyLinksResponseMeta; +pub mod model_teams_hierarchy_links_response_meta_page; +pub use self::model_teams_hierarchy_links_response_meta_page::TeamsHierarchyLinksResponseMetaPage; +pub mod model_team_hierarchy_link_create_request; +pub use self::model_team_hierarchy_link_create_request::TeamHierarchyLinkCreateRequest; +pub mod model_team_hierarchy_link_create; +pub use self::model_team_hierarchy_link_create::TeamHierarchyLinkCreate; +pub mod model_team_hierarchy_link_create_relationships; +pub use self::model_team_hierarchy_link_create_relationships::TeamHierarchyLinkCreateRelationships; +pub mod model_team_hierarchy_link_create_team_relationship; +pub use self::model_team_hierarchy_link_create_team_relationship::TeamHierarchyLinkCreateTeamRelationship; +pub mod model_team_hierarchy_link_create_team; +pub use self::model_team_hierarchy_link_create_team::TeamHierarchyLinkCreateTeam; +pub mod model_team_hierarchy_link_response; +pub use self::model_team_hierarchy_link_response::TeamHierarchyLinkResponse; pub mod model_team_connection_delete_request; pub use self::model_team_connection_delete_request::TeamConnectionDeleteRequest; pub mod model_team_connection_delete_request_data_item; diff --git a/src/datadogV2/model/model_logs_restriction_queries_type.rs b/src/datadogV2/model/model_logs_restriction_queries_type.rs new file mode 100644 index 000000000..e57dde39a --- /dev/null +++ b/src/datadogV2/model/model_logs_restriction_queries_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum LogsRestrictionQueriesType { + LOGS_RESTRICTION_QUERIES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for LogsRestrictionQueriesType { + fn to_string(&self) -> String { + match self { + Self::LOGS_RESTRICTION_QUERIES => String::from("logs_restriction_queries"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for LogsRestrictionQueriesType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for LogsRestrictionQueriesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "logs_restriction_queries" => Self::LOGS_RESTRICTION_QUERIES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_relationship_to_user_team_permission.rs b/src/datadogV2/model/model_relationship_to_user_team_permission.rs index 2c2bf338b..25639baf7 100644 --- a/src/datadogV2/model/model_relationship_to_user_team_permission.rs +++ b/src/datadogV2/model/model_relationship_to_user_team_permission.rs @@ -12,8 +12,8 @@ use std::fmt::{self, Formatter}; #[derive(Clone, Debug, PartialEq, Serialize)] pub struct RelationshipToUserTeamPermission { /// Related user team permission data - #[serde(rename = "data")] - pub data: Option, + #[serde(rename = "data", default, with = "::serde_with::rust::double_option")] + pub data: Option>, /// Links attributes. #[serde(rename = "links")] pub links: Option, @@ -36,7 +36,7 @@ impl RelationshipToUserTeamPermission { pub fn data( mut self, - value: crate::datadogV2::model::RelationshipToUserTeamPermissionData, + value: Option, ) -> Self { self.data = Some(value); self @@ -80,7 +80,7 @@ impl<'de> Deserialize<'de> for RelationshipToUserTeamPermission { M: MapAccess<'a>, { let mut data: Option< - crate::datadogV2::model::RelationshipToUserTeamPermissionData, + Option, > = None; let mut links: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -92,9 +92,6 @@ impl<'de> Deserialize<'de> for RelationshipToUserTeamPermission { while let Some((k, v)) = map.next_entry::()? { match k.as_str() { "data" => { - if v.is_null() { - continue; - } data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "links" => { diff --git a/src/datadogV2/model/model_restriction_query_attributes.rs b/src/datadogV2/model/model_restriction_query_attributes.rs new file mode 100644 index 000000000..58924aa1d --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_attributes.rs @@ -0,0 +1,211 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryAttributes { + /// Creation time of the restriction query. + #[serde(rename = "created_at")] + pub created_at: Option>, + /// Email of the user who last modified this restriction query. + #[serde(rename = "last_modifier_email")] + pub last_modifier_email: Option, + /// Name of the user who last modified this restriction query. + #[serde(rename = "last_modifier_name")] + pub last_modifier_name: Option, + /// Time of last restriction query modification. + #[serde(rename = "modified_at")] + pub modified_at: Option>, + /// The query that defines the restriction. Only the content matching the query can be returned. + #[serde(rename = "restriction_query")] + pub restriction_query: Option, + /// Number of roles associated with this restriction query. + #[serde(rename = "role_count")] + pub role_count: Option, + /// Number of users associated with this restriction query. + #[serde(rename = "user_count")] + pub user_count: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryAttributes { + pub fn new() -> RestrictionQueryAttributes { + RestrictionQueryAttributes { + created_at: None, + last_modifier_email: None, + last_modifier_name: None, + modified_at: None, + restriction_query: None, + role_count: None, + user_count: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn created_at(mut self, value: chrono::DateTime) -> Self { + self.created_at = Some(value); + self + } + + pub fn last_modifier_email(mut self, value: String) -> Self { + self.last_modifier_email = Some(value); + self + } + + pub fn last_modifier_name(mut self, value: String) -> Self { + self.last_modifier_name = Some(value); + self + } + + pub fn modified_at(mut self, value: chrono::DateTime) -> Self { + self.modified_at = Some(value); + self + } + + pub fn restriction_query(mut self, value: String) -> Self { + self.restriction_query = Some(value); + self + } + + pub fn role_count(mut self, value: i64) -> Self { + self.role_count = Some(value); + self + } + + pub fn user_count(mut self, value: i64) -> Self { + self.user_count = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryAttributesVisitor; + impl<'a> Visitor<'a> for RestrictionQueryAttributesVisitor { + type Value = RestrictionQueryAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut last_modifier_email: Option = None; + let mut last_modifier_name: Option = None; + let mut modified_at: Option> = None; + let mut restriction_query: Option = None; + let mut role_count: Option = None; + let mut user_count: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + if v.is_null() { + continue; + } + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modifier_email" => { + if v.is_null() { + continue; + } + last_modifier_email = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modifier_name" => { + if v.is_null() { + continue; + } + last_modifier_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + if v.is_null() { + continue; + } + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "restriction_query" => { + if v.is_null() { + continue; + } + restriction_query = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "role_count" => { + if v.is_null() { + continue; + } + role_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_count" => { + if v.is_null() { + continue; + } + user_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryAttributes { + created_at, + last_modifier_email, + last_modifier_name, + modified_at, + restriction_query, + role_count, + user_count, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_create_attributes.rs b/src/datadogV2/model/model_restriction_query_create_attributes.rs new file mode 100644 index 000000000..b195920b9 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_create_attributes.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the created restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryCreateAttributes { + /// The restriction query. + #[serde(rename = "restriction_query")] + pub restriction_query: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryCreateAttributes { + pub fn new(restriction_query: String) -> RestrictionQueryCreateAttributes { + RestrictionQueryCreateAttributes { + restriction_query, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryCreateAttributesVisitor; + impl<'a> Visitor<'a> for RestrictionQueryCreateAttributesVisitor { + type Value = RestrictionQueryCreateAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut restriction_query: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "restriction_query" => { + restriction_query = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let restriction_query = restriction_query + .ok_or_else(|| M::Error::missing_field("restriction_query"))?; + + let content = RestrictionQueryCreateAttributes { + restriction_query, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_create_data.rs b/src/datadogV2/model/model_restriction_query_create_data.rs new file mode 100644 index 000000000..3dd5ab424 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_create_data.rs @@ -0,0 +1,135 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data related to the creation of a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryCreateData { + /// Attributes of the created restriction query. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Restriction query resource type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryCreateData { + pub fn new() -> RestrictionQueryCreateData { + RestrictionQueryCreateData { + attributes: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::RestrictionQueryCreateAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::LogsRestrictionQueriesType) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryCreateData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryCreateDataVisitor; + impl<'a> Visitor<'a> for RestrictionQueryCreateDataVisitor { + type Value = RestrictionQueryCreateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::RestrictionQueryCreateAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::LogsRestrictionQueriesType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_create_payload.rs b/src/datadogV2/model/model_restriction_query_create_payload.rs new file mode 100644 index 000000000..e44ca06c0 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_create_payload.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Create a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryCreatePayload { + /// Data related to the creation of a restriction query. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryCreatePayload { + pub fn new() -> RestrictionQueryCreatePayload { + RestrictionQueryCreatePayload { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::RestrictionQueryCreateData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryCreatePayload { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryCreatePayload { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryCreatePayloadVisitor; + impl<'a> Visitor<'a> for RestrictionQueryCreatePayloadVisitor { + type Value = RestrictionQueryCreatePayload; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryCreatePayload { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryCreatePayloadVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_list_response.rs b/src/datadogV2/model/model_restriction_query_list_response.rs new file mode 100644 index 000000000..11c01fd79 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_list_response.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing information about multiple restriction queries. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryListResponse { + /// Array of returned restriction queries. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryListResponse { + pub fn new() -> RestrictionQueryListResponse { + RestrictionQueryListResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryListResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryListResponseVisitor; + impl<'a> Visitor<'a> for RestrictionQueryListResponseVisitor { + type Value = RestrictionQueryListResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_response_included_item.rs b/src/datadogV2/model/model_restriction_query_response_included_item.rs new file mode 100644 index 000000000..67668e989 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_response_included_item.rs @@ -0,0 +1,35 @@ +// 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. +use serde::{Deserialize, Deserializer, Serialize}; + +/// An object related to a restriction query. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum RestrictionQueryResponseIncludedItem { + RestrictionQueryRole(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for RestrictionQueryResponseIncludedItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::>( + value.clone(), + ) { + if !_v._unparsed { + return Ok(RestrictionQueryResponseIncludedItem::RestrictionQueryRole( + _v, + )); + } + } + + return Ok(RestrictionQueryResponseIncludedItem::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_restriction_query_role.rs b/src/datadogV2/model/model_restriction_query_role.rs new file mode 100644 index 000000000..3369e7ffb --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_role.rs @@ -0,0 +1,125 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Partial role object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryRole { + /// Attributes of the role for a restriction query. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::RestrictionQueryRoleAttribute, + /// ID of the role. + #[serde(rename = "id")] + pub id: String, + /// Roles type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::RolesType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryRole { + pub fn new( + attributes: crate::datadogV2::model::RestrictionQueryRoleAttribute, + id: String, + type_: crate::datadogV2::model::RolesType, + ) -> RestrictionQueryRole { + RestrictionQueryRole { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryRole { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryRoleVisitor; + impl<'a> Visitor<'a> for RestrictionQueryRoleVisitor { + type Value = RestrictionQueryRole; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::RolesType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = RestrictionQueryRole { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryRoleVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_role_attribute.rs b/src/datadogV2/model/model_restriction_query_role_attribute.rs new file mode 100644 index 000000000..7519f8cbb --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_role_attribute.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the role for a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryRoleAttribute { + /// The role name. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryRoleAttribute { + pub fn new() -> RestrictionQueryRoleAttribute { + RestrictionQueryRoleAttribute { + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryRoleAttribute { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryRoleAttribute { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryRoleAttributeVisitor; + impl<'a> Visitor<'a> for RestrictionQueryRoleAttributeVisitor { + type Value = RestrictionQueryRoleAttribute; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut name: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryRoleAttribute { + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryRoleAttributeVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_roles_response.rs b/src/datadogV2/model/model_restriction_query_roles_response.rs new file mode 100644 index 000000000..df4537d59 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_roles_response.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing information about roles attached to a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryRolesResponse { + /// Array of roles. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryRolesResponse { + pub fn new() -> RestrictionQueryRolesResponse { + RestrictionQueryRolesResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryRolesResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryRolesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryRolesResponseVisitor; + impl<'a> Visitor<'a> for RestrictionQueryRolesResponseVisitor { + type Value = RestrictionQueryRolesResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryRolesResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryRolesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_update_attributes.rs b/src/datadogV2/model/model_restriction_query_update_attributes.rs new file mode 100644 index 000000000..85d1c01e7 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_update_attributes.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of the edited restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryUpdateAttributes { + /// The restriction query. + #[serde(rename = "restriction_query")] + pub restriction_query: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryUpdateAttributes { + pub fn new(restriction_query: String) -> RestrictionQueryUpdateAttributes { + RestrictionQueryUpdateAttributes { + restriction_query, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryUpdateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryUpdateAttributesVisitor; + impl<'a> Visitor<'a> for RestrictionQueryUpdateAttributesVisitor { + type Value = RestrictionQueryUpdateAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut restriction_query: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "restriction_query" => { + restriction_query = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let restriction_query = restriction_query + .ok_or_else(|| M::Error::missing_field("restriction_query"))?; + + let content = RestrictionQueryUpdateAttributes { + restriction_query, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryUpdateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_update_data.rs b/src/datadogV2/model/model_restriction_query_update_data.rs new file mode 100644 index 000000000..86087a025 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_update_data.rs @@ -0,0 +1,135 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data related to the update of a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryUpdateData { + /// Attributes of the edited restriction query. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Restriction query resource type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryUpdateData { + pub fn new() -> RestrictionQueryUpdateData { + RestrictionQueryUpdateData { + attributes: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::RestrictionQueryUpdateAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::LogsRestrictionQueriesType) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryUpdateData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryUpdateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryUpdateDataVisitor; + impl<'a> Visitor<'a> for RestrictionQueryUpdateDataVisitor { + type Value = RestrictionQueryUpdateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::RestrictionQueryUpdateAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::LogsRestrictionQueriesType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryUpdateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryUpdateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_update_payload.rs b/src/datadogV2/model/model_restriction_query_update_payload.rs new file mode 100644 index 000000000..b25b33f56 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_update_payload.rs @@ -0,0 +1,105 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Update a restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryUpdatePayload { + /// Data related to the update of a restriction query. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryUpdatePayload { + pub fn new() -> RestrictionQueryUpdatePayload { + RestrictionQueryUpdatePayload { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::RestrictionQueryUpdateData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryUpdatePayload { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryUpdatePayload { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryUpdatePayloadVisitor; + impl<'a> Visitor<'a> for RestrictionQueryUpdatePayloadVisitor { + type Value = RestrictionQueryUpdatePayload; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryUpdatePayload { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryUpdatePayloadVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_with_relationships.rs b/src/datadogV2/model/model_restriction_query_with_relationships.rs new file mode 100644 index 000000000..5a3758fa7 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_with_relationships.rs @@ -0,0 +1,169 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Restriction query object returned by the API. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryWithRelationships { + /// Attributes of the restriction query. + #[serde(rename = "attributes")] + pub attributes: Option, + /// ID of the restriction query. + #[serde(rename = "id")] + pub id: Option, + /// Relationships of the user object. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Restriction query resource type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryWithRelationships { + pub fn new() -> RestrictionQueryWithRelationships { + RestrictionQueryWithRelationships { + attributes: None, + id: None, + relationships: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::RestrictionQueryAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn relationships(mut self, value: crate::datadogV2::model::UserRelationships) -> Self { + self.relationships = Some(value); + self + } + + pub fn type_(mut self, value: crate::datadogV2::model::LogsRestrictionQueriesType) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryWithRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryWithRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryWithRelationshipsVisitor; + impl<'a> Visitor<'a> for RestrictionQueryWithRelationshipsVisitor { + type Value = RestrictionQueryWithRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut relationships: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::LogsRestrictionQueriesType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryWithRelationships { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryWithRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_with_relationships_response.rs b/src/datadogV2/model/model_restriction_query_with_relationships_response.rs new file mode 100644 index 000000000..39cb0c378 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_with_relationships_response.rs @@ -0,0 +1,131 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing information about a single restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryWithRelationshipsResponse { + /// Restriction query object returned by the API. + #[serde(rename = "data")] + pub data: Option, + /// Array of objects related to the restriction query. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryWithRelationshipsResponse { + pub fn new() -> RestrictionQueryWithRelationshipsResponse { + RestrictionQueryWithRelationshipsResponse { + data: None, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::RestrictionQueryWithRelationships, + ) -> Self { + self.data = Some(value); + self + } + + pub fn included( + mut self, + value: Vec, + ) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryWithRelationshipsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryWithRelationshipsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryWithRelationshipsResponseVisitor; + impl<'a> Visitor<'a> for RestrictionQueryWithRelationshipsResponseVisitor { + type Value = RestrictionQueryWithRelationshipsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut included: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryWithRelationshipsResponse { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryWithRelationshipsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_without_relationships.rs b/src/datadogV2/model/model_restriction_query_without_relationships.rs new file mode 100644 index 000000000..b1d9282bb --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_without_relationships.rs @@ -0,0 +1,143 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Restriction query object returned by the API. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryWithoutRelationships { + /// Attributes of the restriction query. + #[serde(rename = "attributes")] + pub attributes: Option, + /// ID of the restriction query. + #[serde(rename = "id")] + pub id: Option, + /// Restriction queries type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryWithoutRelationships { + pub fn new() -> RestrictionQueryWithoutRelationships { + RestrictionQueryWithoutRelationships { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::RestrictionQueryAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryWithoutRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryWithoutRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryWithoutRelationshipsVisitor; + impl<'a> Visitor<'a> for RestrictionQueryWithoutRelationshipsVisitor { + type Value = RestrictionQueryWithoutRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryWithoutRelationships { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryWithoutRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_restriction_query_without_relationships_response.rs b/src/datadogV2/model/model_restriction_query_without_relationships_response.rs new file mode 100644 index 000000000..fe8a46af4 --- /dev/null +++ b/src/datadogV2/model/model_restriction_query_without_relationships_response.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing information about a single restriction query. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RestrictionQueryWithoutRelationshipsResponse { + /// Restriction query object returned by the API. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RestrictionQueryWithoutRelationshipsResponse { + pub fn new() -> RestrictionQueryWithoutRelationshipsResponse { + RestrictionQueryWithoutRelationshipsResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::RestrictionQueryWithoutRelationships, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RestrictionQueryWithoutRelationshipsResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RestrictionQueryWithoutRelationshipsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RestrictionQueryWithoutRelationshipsResponseVisitor; + impl<'a> Visitor<'a> for RestrictionQueryWithoutRelationshipsResponseVisitor { + type Value = RestrictionQueryWithoutRelationshipsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::RestrictionQueryWithoutRelationships, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = RestrictionQueryWithoutRelationshipsResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RestrictionQueryWithoutRelationshipsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_team_attributes.rs b/src/datadogV2/model/model_team_attributes.rs index acbbf8f09..5309f7052 100644 --- a/src/datadogV2/model/model_team_attributes.rs +++ b/src/datadogV2/model/model_team_attributes.rs @@ -31,8 +31,15 @@ pub struct TeamAttributes { #[serde(rename = "handle")] pub handle: String, /// Collection of hidden modules for the team - #[serde(rename = "hidden_modules")] - pub hidden_modules: Option>, + #[serde( + rename = "hidden_modules", + default, + with = "::serde_with::rust::double_option" + )] + pub hidden_modules: Option>>, + /// Whether the team is managed from an external source + #[serde(rename = "is_managed")] + pub is_managed: Option, /// The number of links belonging to the team #[serde(rename = "link_count")] pub link_count: Option, @@ -53,8 +60,12 @@ pub struct TeamAttributes { #[serde(rename = "user_count")] pub user_count: Option, /// Collection of visible modules for the team - #[serde(rename = "visible_modules")] - pub visible_modules: Option>, + #[serde( + rename = "visible_modules", + default, + with = "::serde_with::rust::double_option" + )] + pub visible_modules: Option>>, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -71,6 +82,7 @@ impl TeamAttributes { description: None, handle, hidden_modules: None, + is_managed: None, link_count: None, modified_at: None, name, @@ -102,11 +114,16 @@ impl TeamAttributes { self } - pub fn hidden_modules(mut self, value: Vec) -> Self { + pub fn hidden_modules(mut self, value: Option>) -> Self { self.hidden_modules = Some(value); self } + pub fn is_managed(mut self, value: bool) -> Self { + self.is_managed = Some(value); + self + } + pub fn link_count(mut self, value: i32) -> Self { self.link_count = Some(value); self @@ -127,7 +144,7 @@ impl TeamAttributes { self } - pub fn visible_modules(mut self, value: Vec) -> Self { + pub fn visible_modules(mut self, value: Option>) -> Self { self.visible_modules = Some(value); self } @@ -163,13 +180,14 @@ impl<'de> Deserialize<'de> for TeamAttributes { let mut created_at: Option> = None; let mut description: Option> = None; let mut handle: Option = None; - let mut hidden_modules: Option> = None; + let mut hidden_modules: Option>> = None; + let mut is_managed: Option = None; let mut link_count: Option = None; let mut modified_at: Option> = None; let mut name: Option = None; let mut summary: Option> = None; let mut user_count: Option = None; - let mut visible_modules: Option> = None; + let mut visible_modules: Option>> = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -198,11 +216,14 @@ impl<'de> Deserialize<'de> for TeamAttributes { handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "hidden_modules" => { + hidden_modules = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_managed" => { if v.is_null() { continue; } - hidden_modules = - Some(serde_json::from_value(v).map_err(M::Error::custom)?); + is_managed = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "link_count" => { if v.is_null() { @@ -230,9 +251,6 @@ impl<'de> Deserialize<'de> for TeamAttributes { user_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } "visible_modules" => { - if v.is_null() { - continue; - } visible_modules = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } @@ -253,6 +271,7 @@ impl<'de> Deserialize<'de> for TeamAttributes { description, handle, hidden_modules, + is_managed, link_count, modified_at, name, diff --git a/src/datadogV2/model/model_team_hierarchy_link.rs b/src/datadogV2/model/model_team_hierarchy_link.rs new file mode 100644 index 000000000..5b43cb0a5 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link.rs @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLink { + /// Team hierarchy link attributes + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::TeamHierarchyLinkAttributes, + /// The team hierarchy link's identifier + #[serde(rename = "id")] + pub id: String, + /// Team hierarchy link relationships + #[serde(rename = "relationships")] + pub relationships: Option, + /// Team hierarchy link type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamHierarchyLinkType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLink { + pub fn new( + attributes: crate::datadogV2::model::TeamHierarchyLinkAttributes, + id: String, + type_: crate::datadogV2::model::TeamHierarchyLinkType, + ) -> TeamHierarchyLink { + TeamHierarchyLink { + attributes, + id, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::TeamHierarchyLinkRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLink { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkVisitor { + type Value = TeamHierarchyLink; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::TeamHierarchyLinkRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamHierarchyLinkType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLink { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_attributes.rs b/src/datadogV2/model/model_team_hierarchy_link_attributes.rs new file mode 100644 index 000000000..df885885c --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_attributes.rs @@ -0,0 +1,107 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy link attributes +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkAttributes { + /// Timestamp when the team hierarchy link was created + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The provisioner of the team hierarchy link + #[serde(rename = "provisioned_by")] + pub provisioned_by: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkAttributes { + pub fn new( + created_at: chrono::DateTime, + provisioned_by: String, + ) -> TeamHierarchyLinkAttributes { + TeamHierarchyLinkAttributes { + created_at, + provisioned_by, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkAttributesVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkAttributesVisitor { + type Value = TeamHierarchyLinkAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut provisioned_by: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "provisioned_by" => { + provisioned_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let provisioned_by = + provisioned_by.ok_or_else(|| M::Error::missing_field("provisioned_by"))?; + + let content = TeamHierarchyLinkAttributes { + created_at, + provisioned_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create.rs b/src/datadogV2/model/model_team_hierarchy_link_create.rs new file mode 100644 index 000000000..fbae68103 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create.rs @@ -0,0 +1,117 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data provided when creating a team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreate { + /// The related teams that will be connected by the team hierarchy link + #[serde(rename = "relationships")] + pub relationships: crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + /// Team hierarchy link type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamHierarchyLinkType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreate { + pub fn new( + relationships: crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + type_: crate::datadogV2::model::TeamHierarchyLinkType, + ) -> TeamHierarchyLinkCreate { + TeamHierarchyLinkCreate { + relationships, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkCreate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateVisitor { + type Value = TeamHierarchyLinkCreate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut relationships: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateRelationships, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "relationships" => { + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamHierarchyLinkType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let relationships = + relationships.ok_or_else(|| M::Error::missing_field("relationships"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLinkCreate { + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs b/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs new file mode 100644 index 000000000..fe2d3f5a7 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The related teams that will be connected by the team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateRelationships { + /// Data about each team that will be connected by the team hierarchy link + #[serde(rename = "parent_team")] + pub parent_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + /// Data about each team that will be connected by the team hierarchy link + #[serde(rename = "sub_team")] + pub sub_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateRelationships { + pub fn new( + parent_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + sub_team: crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + ) -> TeamHierarchyLinkCreateRelationships { + TeamHierarchyLinkCreateRelationships { + parent_team, + sub_team, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkCreateRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateRelationshipsVisitor { + type Value = TeamHierarchyLinkCreateRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut parent_team: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + > = None; + let mut sub_team: Option< + crate::datadogV2::model::TeamHierarchyLinkCreateTeamRelationship, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "parent_team" => { + parent_team = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sub_team" => { + sub_team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let parent_team = + parent_team.ok_or_else(|| M::Error::missing_field("parent_team"))?; + let sub_team = sub_team.ok_or_else(|| M::Error::missing_field("sub_team"))?; + + let content = TeamHierarchyLinkCreateRelationships { + parent_team, + sub_team, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_request.rs b/src/datadogV2/model/model_team_hierarchy_link_create_request.rs new file mode 100644 index 000000000..3cf5b0336 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_request.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request to create a team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateRequest { + /// Data provided when creating a team hierarchy link + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkCreate, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateRequest { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkCreate, + ) -> TeamHierarchyLinkCreateRequest { + TeamHierarchyLinkCreateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateRequestVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateRequestVisitor { + type Value = TeamHierarchyLinkCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TeamHierarchyLinkCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_team.rs b/src/datadogV2/model/model_team_hierarchy_link_create_team.rs new file mode 100644 index 000000000..305063ab6 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_team.rs @@ -0,0 +1,113 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// This schema defines the attributes about each team that has to be provided when creating a team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateTeam { + /// The team's identifier + #[serde(rename = "id")] + pub id: String, + /// Team type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateTeam { + pub fn new( + id: String, + type_: crate::datadogV2::model::TeamType, + ) -> TeamHierarchyLinkCreateTeam { + TeamHierarchyLinkCreateTeam { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkCreateTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateTeamVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateTeamVisitor { + type Value = TeamHierarchyLinkCreateTeam; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLinkCreateTeam { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.rs b/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.rs new file mode 100644 index 000000000..f52d98149 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_create_team_relationship.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data about each team that will be connected by the team hierarchy link +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkCreateTeamRelationship { + /// This schema defines the attributes about each team that has to be provided when creating a team hierarchy link + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkCreateTeam, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkCreateTeamRelationship { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkCreateTeam, + ) -> TeamHierarchyLinkCreateTeamRelationship { + TeamHierarchyLinkCreateTeamRelationship { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkCreateTeamRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkCreateTeamRelationshipVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkCreateTeamRelationshipVisitor { + type Value = TeamHierarchyLinkCreateTeamRelationship; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TeamHierarchyLinkCreateTeamRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkCreateTeamRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_relationships.rs b/src/datadogV2/model/model_team_hierarchy_link_relationships.rs new file mode 100644 index 000000000..0e9ffaf4a --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy link relationships +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkRelationships { + /// Team hierarchy link team relationship + #[serde(rename = "parent_team")] + pub parent_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + /// Team hierarchy link team relationship + #[serde(rename = "sub_team")] + pub sub_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkRelationships { + pub fn new( + parent_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + sub_team: crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + ) -> TeamHierarchyLinkRelationships { + TeamHierarchyLinkRelationships { + parent_team, + sub_team, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkRelationshipsVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkRelationshipsVisitor { + type Value = TeamHierarchyLinkRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut parent_team: Option< + crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + > = None; + let mut sub_team: Option< + crate::datadogV2::model::TeamHierarchyLinkTeamRelationship, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "parent_team" => { + parent_team = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "sub_team" => { + sub_team = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let parent_team = + parent_team.ok_or_else(|| M::Error::missing_field("parent_team"))?; + let sub_team = sub_team.ok_or_else(|| M::Error::missing_field("sub_team"))?; + + let content = TeamHierarchyLinkRelationships { + parent_team, + sub_team, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_response.rs b/src/datadogV2/model/model_team_hierarchy_link_response.rs new file mode 100644 index 000000000..5d60ce153 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_response.rs @@ -0,0 +1,144 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy link response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkResponse { + /// Team hierarchy link + #[serde(rename = "data")] + pub data: Option, + /// Included teams + #[serde(rename = "included")] + pub included: Option>, + /// When querying team hierarchy links, a set of links for navigation between different pages is included + #[serde(rename = "links")] + pub links: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkResponse { + pub fn new() -> TeamHierarchyLinkResponse { + TeamHierarchyLinkResponse { + data: None, + included: None, + links: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TeamHierarchyLink) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn links( + mut self, + value: crate::datadogV2::model::TeamsHierarchyLinksResponseLinks, + ) -> Self { + self.links = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamHierarchyLinkResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkResponseVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkResponseVisitor { + type Value = TeamHierarchyLinkResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut included: Option> = + None; + let mut links: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "links" => { + if v.is_null() { + continue; + } + links = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamHierarchyLinkResponse { + data, + included, + links, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team.rs b/src/datadogV2/model/model_team_hierarchy_link_team.rs new file mode 100644 index 000000000..9979bbea4 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team.rs @@ -0,0 +1,132 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy links connect different teams. This represents team objects that are connected by the team hierarchy link. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeam { + /// Team hierarchy links connect different teams. This represents attributes from teams that are connected by the team hierarchy link. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The team's identifier + #[serde(rename = "id")] + pub id: String, + /// Team type + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TeamType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeam { + pub fn new(id: String, type_: crate::datadogV2::model::TeamType) -> TeamHierarchyLinkTeam { + TeamHierarchyLinkTeam { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::TeamHierarchyLinkTeamAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkTeam { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamVisitor { + type Value = TeamHierarchyLinkTeam; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::TeamHierarchyLinkTeamAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TeamType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TeamHierarchyLinkTeam { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs b/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs new file mode 100644 index 000000000..8f397d08d --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team_attributes.rs @@ -0,0 +1,220 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy links connect different teams. This represents attributes from teams that are connected by the team hierarchy link. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeamAttributes { + /// The team's avatar + #[serde(rename = "avatar", default, with = "::serde_with::rust::double_option")] + pub avatar: Option>, + /// The team's banner + #[serde(rename = "banner")] + pub banner: Option, + /// The team's handle + #[serde(rename = "handle")] + pub handle: String, + /// Whether the team is managed + #[serde(rename = "is_managed")] + pub is_managed: Option, + /// Whether the team has open membership + #[serde(rename = "is_open_membership")] + pub is_open_membership: Option, + /// The number of links for the team + #[serde(rename = "link_count")] + pub link_count: Option, + /// The team's name + #[serde(rename = "name")] + pub name: String, + /// The team's summary + #[serde( + rename = "summary", + default, + with = "::serde_with::rust::double_option" + )] + pub summary: Option>, + /// The number of users in the team + #[serde(rename = "user_count")] + pub user_count: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeamAttributes { + pub fn new(handle: String, name: String) -> TeamHierarchyLinkTeamAttributes { + TeamHierarchyLinkTeamAttributes { + avatar: None, + banner: None, + handle, + is_managed: None, + is_open_membership: None, + link_count: None, + name, + summary: None, + user_count: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn avatar(mut self, value: Option) -> Self { + self.avatar = Some(value); + self + } + + pub fn banner(mut self, value: i64) -> Self { + self.banner = Some(value); + self + } + + pub fn is_managed(mut self, value: bool) -> Self { + self.is_managed = Some(value); + self + } + + pub fn is_open_membership(mut self, value: bool) -> Self { + self.is_open_membership = Some(value); + self + } + + pub fn link_count(mut self, value: i64) -> Self { + self.link_count = Some(value); + self + } + + pub fn summary(mut self, value: Option) -> Self { + self.summary = Some(value); + self + } + + pub fn user_count(mut self, value: i64) -> Self { + self.user_count = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkTeamAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamAttributesVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamAttributesVisitor { + type Value = TeamHierarchyLinkTeamAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut avatar: Option> = None; + let mut banner: Option = None; + let mut handle: Option = None; + let mut is_managed: Option = None; + let mut is_open_membership: Option = None; + let mut link_count: Option = None; + let mut name: Option = None; + let mut summary: Option> = None; + let mut user_count: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "avatar" => { + avatar = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "banner" => { + if v.is_null() { + continue; + } + banner = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "handle" => { + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_managed" => { + if v.is_null() { + continue; + } + is_managed = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "is_open_membership" => { + if v.is_null() { + continue; + } + is_open_membership = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "link_count" => { + if v.is_null() { + continue; + } + link_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "summary" => { + summary = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_count" => { + if v.is_null() { + continue; + } + user_count = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let handle = handle.ok_or_else(|| M::Error::missing_field("handle"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = TeamHierarchyLinkTeamAttributes { + avatar, + banner, + handle, + is_managed, + is_open_membership, + link_count, + name, + summary, + user_count, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_team_relationship.rs b/src/datadogV2/model/model_team_hierarchy_link_team_relationship.rs new file mode 100644 index 000000000..a8a12641f --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_team_relationship.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy link team relationship +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinkTeamRelationship { + /// Team hierarchy links connect different teams. This represents team objects that are connected by the team hierarchy link. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::TeamHierarchyLinkTeam, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinkTeamRelationship { + pub fn new( + data: crate::datadogV2::model::TeamHierarchyLinkTeam, + ) -> TeamHierarchyLinkTeamRelationship { + TeamHierarchyLinkTeamRelationship { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkTeamRelationship { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinkTeamRelationshipVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinkTeamRelationshipVisitor { + type Value = TeamHierarchyLinkTeamRelationship; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TeamHierarchyLinkTeamRelationship { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinkTeamRelationshipVisitor) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_link_type.rs b/src/datadogV2/model/model_team_hierarchy_link_type.rs new file mode 100644 index 000000000..845d2f52e --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_link_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TeamHierarchyLinkType { + TEAM_HIERARCHY_LINKS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TeamHierarchyLinkType { + fn to_string(&self) -> String { + match self { + Self::TEAM_HIERARCHY_LINKS => String::from("team_hierarchy_links"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TeamHierarchyLinkType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinkType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "team_hierarchy_links" => Self::TEAM_HIERARCHY_LINKS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_team_hierarchy_links_response.rs b/src/datadogV2/model/model_team_hierarchy_links_response.rs new file mode 100644 index 000000000..43af32094 --- /dev/null +++ b/src/datadogV2/model/model_team_hierarchy_links_response.rs @@ -0,0 +1,162 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Team hierarchy links response +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamHierarchyLinksResponse { + /// Team hierarchy links response data + #[serde(rename = "data")] + pub data: Option>, + /// Included teams + #[serde(rename = "included")] + pub included: Option>, + /// When querying team hierarchy links, a set of links for navigation between different pages is included + #[serde(rename = "links")] + pub links: Option, + /// Metadata that is included in the response when querying the team hierarchy links + #[serde(rename = "meta")] + pub meta: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamHierarchyLinksResponse { + pub fn new() -> TeamHierarchyLinksResponse { + TeamHierarchyLinksResponse { + data: None, + included: None, + links: None, + meta: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn links( + mut self, + value: crate::datadogV2::model::TeamsHierarchyLinksResponseLinks, + ) -> Self { + self.links = Some(value); + self + } + + pub fn meta(mut self, value: crate::datadogV2::model::TeamsHierarchyLinksResponseMeta) -> Self { + self.meta = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamHierarchyLinksResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamHierarchyLinksResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamHierarchyLinksResponseVisitor; + impl<'a> Visitor<'a> for TeamHierarchyLinksResponseVisitor { + type Value = TeamHierarchyLinksResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut included: Option> = + None; + let mut links: Option = + None; + let mut meta: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "links" => { + if v.is_null() { + continue; + } + links = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "meta" => { + if v.is_null() { + continue; + } + meta = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamHierarchyLinksResponse { + data, + included, + links, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamHierarchyLinksResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs new file mode 100644 index 000000000..a7b1e2fd4 --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_links.rs @@ -0,0 +1,161 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// When querying team hierarchy links, a set of links for navigation between different pages is included +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseLinks { + /// Link to the first page. + #[serde(rename = "first", default, with = "::serde_with::rust::double_option")] + pub first: Option>, + /// Link to the last page. + #[serde(rename = "last", default, with = "::serde_with::rust::double_option")] + pub last: Option>, + /// Link to the next page. + #[serde(rename = "next", default, with = "::serde_with::rust::double_option")] + pub next: Option>, + /// Link to the previous page. + #[serde(rename = "prev", default, with = "::serde_with::rust::double_option")] + pub prev: Option>, + /// Link to the current object. + #[serde(rename = "self")] + pub self_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseLinks { + pub fn new() -> TeamsHierarchyLinksResponseLinks { + TeamsHierarchyLinksResponseLinks { + first: None, + last: None, + next: None, + prev: None, + self_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn first(mut self, value: Option) -> Self { + self.first = Some(value); + self + } + + pub fn last(mut self, value: Option) -> Self { + self.last = Some(value); + self + } + + pub fn next(mut self, value: Option) -> Self { + self.next = Some(value); + self + } + + pub fn prev(mut self, value: Option) -> Self { + self.prev = Some(value); + self + } + + pub fn self_(mut self, value: String) -> Self { + self.self_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamsHierarchyLinksResponseLinks { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseLinks { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseLinksVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseLinksVisitor { + type Value = TeamsHierarchyLinksResponseLinks; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut first: Option> = None; + let mut last: Option> = None; + let mut next: Option> = None; + let mut prev: Option> = None; + let mut self_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "first" => { + first = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last" => { + last = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next" => { + next = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "prev" => { + prev = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "self" => { + if v.is_null() { + continue; + } + self_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamsHierarchyLinksResponseLinks { + first, + last, + next, + prev, + self_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseLinksVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs new file mode 100644 index 000000000..c4aad50c0 --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_meta.rs @@ -0,0 +1,109 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Metadata that is included in the response when querying the team hierarchy links +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseMeta { + /// Metadata related to paging information that is included in the response when querying the team hierarchy links + #[serde(rename = "page")] + pub page: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseMeta { + pub fn new() -> TeamsHierarchyLinksResponseMeta { + TeamsHierarchyLinksResponseMeta { + page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn page( + mut self, + value: crate::datadogV2::model::TeamsHierarchyLinksResponseMetaPage, + ) -> Self { + self.page = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamsHierarchyLinksResponseMeta { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseMetaVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseMetaVisitor { + type Value = TeamsHierarchyLinksResponseMeta; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut page: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "page" => { + if v.is_null() { + continue; + } + page = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamsHierarchyLinksResponseMeta { + page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs b/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs new file mode 100644 index 000000000..d2acb3368 --- /dev/null +++ b/src/datadogV2/model/model_teams_hierarchy_links_response_meta_page.rs @@ -0,0 +1,230 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Metadata related to paging information that is included in the response when querying the team hierarchy links +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TeamsHierarchyLinksResponseMetaPage { + /// First page number. + #[serde(rename = "first_number")] + pub first_number: Option, + /// Last page number. + #[serde(rename = "last_number")] + pub last_number: Option, + /// Next page number. + #[serde( + rename = "next_number", + default, + with = "::serde_with::rust::double_option" + )] + pub next_number: Option>, + /// Page number. + #[serde(rename = "number")] + pub number: Option, + /// Previous page number. + #[serde( + rename = "prev_number", + default, + with = "::serde_with::rust::double_option" + )] + pub prev_number: Option>, + /// Page size. + #[serde(rename = "size")] + pub size: Option, + /// Total number of results. + #[serde(rename = "total")] + pub total: Option, + /// Pagination type. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TeamsHierarchyLinksResponseMetaPage { + pub fn new() -> TeamsHierarchyLinksResponseMetaPage { + TeamsHierarchyLinksResponseMetaPage { + first_number: None, + last_number: None, + next_number: None, + number: None, + prev_number: None, + size: None, + total: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn first_number(mut self, value: i64) -> Self { + self.first_number = Some(value); + self + } + + pub fn last_number(mut self, value: i64) -> Self { + self.last_number = Some(value); + self + } + + pub fn next_number(mut self, value: Option) -> Self { + self.next_number = Some(value); + self + } + + pub fn number(mut self, value: i64) -> Self { + self.number = Some(value); + self + } + + pub fn prev_number(mut self, value: Option) -> Self { + self.prev_number = Some(value); + self + } + + pub fn size(mut self, value: i64) -> Self { + self.size = Some(value); + self + } + + pub fn total(mut self, value: i64) -> Self { + self.total = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TeamsHierarchyLinksResponseMetaPage { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TeamsHierarchyLinksResponseMetaPage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TeamsHierarchyLinksResponseMetaPageVisitor; + impl<'a> Visitor<'a> for TeamsHierarchyLinksResponseMetaPageVisitor { + type Value = TeamsHierarchyLinksResponseMetaPage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut first_number: Option = None; + let mut last_number: Option = None; + let mut next_number: Option> = None; + let mut number: Option = None; + let mut prev_number: Option> = None; + let mut size: Option = None; + let mut total: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "first_number" => { + if v.is_null() { + continue; + } + first_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_number" => { + if v.is_null() { + continue; + } + last_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "next_number" => { + next_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "number" => { + if v.is_null() { + continue; + } + number = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "prev_number" => { + prev_number = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "size" => { + if v.is_null() { + continue; + } + size = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "total" => { + if v.is_null() { + continue; + } + total = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = TeamsHierarchyLinksResponseMetaPage { + first_number, + last_number, + next_number, + number, + prev_number, + size, + total, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TeamsHierarchyLinksResponseMetaPageVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..46f704ffe --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:04.509Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.json new file mode 100644 index 000000000..3a4a26e57 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"test\":\"bad_request\"}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"errors\":[\"API input validation failed: {'_schema': [{'detail': 'Object must include `data` key.', 'source': {'pointer': '/'}}]}\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:04 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.frozen new file mode 100644 index 000000000..e7d3eb34c --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:05.128Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.json new file mode 100644 index 000000000..9cfda99e1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Create-a-restriction-query-returns-OK-response.json @@ -0,0 +1,67 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"restriction_query\":\"env:sandbox\"},\"type\":\"logs_restriction_queries\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:05 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2b5594f8-c4b3-11f0-a05d-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:05 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..606a5c297 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:06.402Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.json new file mode 100644 index 000000000..a513d543a --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id" + }, + "response": { + "body": { + "string": "{\"errors\":[\"uuid is not proper type\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:06 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.frozen new file mode 100644 index 000000000..b407dce9f --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:06.567Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.json new file mode 100644 index 000000000..bf354b68b --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-Not-found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Restriction query not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:06 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.frozen new file mode 100644 index 000000000..233ffaffa --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:06.720Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.json new file mode 100644 index 000000000..11efbd4db --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Delete-a-restriction-query-returns-OK-response.json @@ -0,0 +1,95 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"restriction_query\":\"env:sandbox\"},\"type\":\"logs_restriction_queries\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:06 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2c373dc2-c4b3-11f0-8ca7-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:06 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2c373dc2-c4b3-11f0-8ca7-da7ad0900002" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Restriction query not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:06 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..35466be50 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:07.277Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.json new file mode 100644 index 000000000..0ff6f9807 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id" + }, + "response": { + "body": { + "string": "{\"errors\":[\"uuid is not proper type\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.frozen new file mode 100644 index 000000000..27aff0c3f --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:07.461Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.json new file mode 100644 index 000000000..1b6b78d5a --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-Not-found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Restriction query not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.frozen new file mode 100644 index 000000000..1f2677481 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:07.622Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.json new file mode 100644 index 000000000..2129b1aa4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-a-restriction-query-returns-OK-response.json @@ -0,0 +1,95 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"restriction_query\":\"env:sandbox\"},\"type\":\"logs_restriction_queries\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2cc39998-c4b3-11f0-8b4b-da7ad0900002" + }, + "response": { + "body": { + "string": "{\"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\":[]}}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2cc39998-c4b3-11f0-8b4b-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..57b32bd89 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:08.172Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.json new file mode 100644 index 000000000..f0a687871 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/user/malformed_id" + }, + "response": { + "body": { + "string": "{\"errors\":[\"uuid is not proper type\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.frozen new file mode 100644 index 000000000..9ee4a5d52 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:08.336Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.json new file mode 100644 index 000000000..162148e14 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-all-restriction-queries-for-a-given-user-returns-Not-found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/user/00000000-0000-0000-0000-000000000000" + }, + "response": { + "body": { + "string": "{\"errors\":[\"user with uuid 00000000-0000-0000-0000-000000000000 doesn't exist\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..57897532a --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:08.604Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.json new file mode 100644 index 000000000..89aa278d9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/malformed_id" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Missing Role malformed_id\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.frozen new file mode 100644 index 000000000..bd0df2da8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:08.828Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.json new file mode 100644 index 000000000..c2bafb343 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-Not-found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/00000000-0000-0000-0000-000000000000" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Missing Role 00000000-0000-0000-0000-000000000000\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.frozen new file mode 100644 index 000000000..8dc9f697b --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:08.994Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.json new file mode 100644 index 000000000..d5123e7d7 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Get-restriction-query-for-a-given-role-returns-OK-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"name\":\"Test-Get_restriction_query_for_a_given_role_returns_OK_response-1763493428\"},\"type\":\"roles\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/roles" + }, + "response": { + "body": { + "string": "{\"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\"}]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/role/2d925300-c4b3-11f0-a252-da7ad0900002" + }, + "response": { + "body": { + "string": "{\"data\":[]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/roles/2d925300-c4b3-11f0-a252-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..48cf494a9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:09.440Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.json new file mode 100644 index 000000000..428aaf18b --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"id\":\"3653d3c6-0c75-11ea-ad28-fb5701eabc7d\",\"type\":\"roles\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "*/*" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id/roles" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Role with id: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.frozen new file mode 100644 index 000000000..f281a86a4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:09.623Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.json new file mode 100644 index 000000000..e1a934584 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-Not-found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"id\":\"3653d3c6-0c75-11ea-ad28-fb5701eabc7d\",\"type\":\"roles\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "*/*" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000/roles" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Role with id: 3653d3c6-0c75-11ea-ad28-fb5701eabc7d not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.frozen new file mode 100644 index 000000000..ac88614fb --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:09.783Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.json new file mode 100644 index 000000000..742c469bb --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/Grant-role-to-a-restriction-query-returns-OK-response.json @@ -0,0 +1,159 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"restriction_query\":\"env:sandbox\"},\"type\":\"logs_restriction_queries\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"name\":\"Test-Grant_role_to_a_restriction_query_returns_OK_response-1763493429\"},\"type\":\"roles\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/roles" + }, + "response": { + "body": { + "string": "{\"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\"}]}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"id\":\"2e209fb6-c4b3-11f0-8483-da7ad0900002\",\"type\":\"roles\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "*/*" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2e0a0abc-c4b3-11f0-9b1d-da7ad0900002/roles" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/roles/2e209fb6-c4b3-11f0-8483-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2e0a0abc-c4b3-11f0-9b1d-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:09 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.frozen new file mode 100644 index 000000000..d227ca557 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:10.912Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.json new file mode 100644 index 000000000..e864d1763 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-restriction-queries-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:10 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..0badf8611 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:11.052Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.json new file mode 100644 index 000000000..c814086b3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/malformed_id/roles" + }, + "response": { + "body": { + "string": "{\"errors\":[\"uuid is not proper type\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.frozen new file mode 100644 index 000000000..358663320 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:11.231Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.json new file mode 100644 index 000000000..3991cb18f --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-Not-found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/00000000-0000-0000-0000-000000000000/roles" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Restriction query not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.frozen new file mode 100644 index 000000000..5e8d0cb60 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-18T19:17:11.376Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.json b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.json new file mode 100644 index 000000000..279552ee8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/logs_restriction_queries/List-roles-for-a-restriction-query-returns-OK-response.json @@ -0,0 +1,95 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"restriction_query\":\"env:sandbox\"},\"type\":\"logs_restriction_queries\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries" + }, + "response": { + "body": { + "string": "{\"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\"}}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:11 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2efc1406-c4b3-11f0-a6d9-da7ad0900002/roles" + }, + "response": { + "body": { + "string": "{\"data\":[]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:11 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/logs/config/restriction_queries/2efc1406-c4b3-11f0-a6d9-da7ad0900002" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": { + "Content-Type": [ + "text/html; charset=utf-8" + ] + }, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 18 Nov 2025 19:17:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.frozen b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.frozen new file mode 100644 index 000000000..5ca151ab8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.frozen @@ -0,0 +1 @@ +2025-11-24T14:29:58.684Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.json b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.json new file mode 100644 index 000000000..8ec08328a --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-CREATED-response.json @@ -0,0 +1,179 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-34095e00d70ee50a\",\"name\":\"test-name-34095e00d70ee50a\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"551c947a-0f0f-4ff0-8c41-0ceddabe3551\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":3,\"created_at\":\"2025-11-24T14:29:59.195740+00:00\",\"description\":null,\"handle\":\"test-handle-34095e00d70ee50a\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T14:29:59.195740+00:00\",\"name\":\"test-name-34095e00d70ee50a\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/551c947a-0f0f-4ff0-8c41-0ceddabe3551/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/551c947a-0f0f-4ff0-8c41-0ceddabe3551/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-34095e00d70ee50a\",\"name\":\"test-name-2-34095e00d70ee50a\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"e1c6ab08-0325-4df7-aea1-6bec76692d55\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":14,\"created_at\":\"2025-11-24T14:29:59.754699+00:00\",\"description\":null,\"handle\":\"test-handle-2-34095e00d70ee50a\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T14:29:59.754699+00:00\",\"name\":\"test-name-2-34095e00d70ee50a\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/e1c6ab08-0325-4df7-aea1-6bec76692d55/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/e1c6ab08-0325-4df7-aea1-6bec76692d55/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"551c947a-0f0f-4ff0-8c41-0ceddabe3551\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"e1c6ab08-0325-4df7-aea1-6bec76692d55\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"c53bed14-1c0a-4895-b845-1c04be086ba0\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T14:30:00.032477595Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"551c947a-0f0f-4ff0-8c41-0ceddabe3551\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"e1c6ab08-0325-4df7-aea1-6bec76692d55\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"551c947a-0f0f-4ff0-8c41-0ceddabe3551\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":3,\"handle\":\"test-handle-34095e00d70ee50a\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-34095e00d70ee50a\",\"summary\":null,\"user_count\":0}},{\"id\":\"e1c6ab08-0325-4df7-aea1-6bec76692d55\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":14,\"handle\":\"test-handle-2-34095e00d70ee50a\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-34095e00d70ee50a\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/c53bed14-1c0a-4895-b845-1c04be086ba0" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/e1c6ab08-0325-4df7-aea1-6bec76692d55" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/551c947a-0f0f-4ff0-8c41-0ceddabe3551" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 14:29:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.frozen b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.frozen new file mode 100644 index 000000000..4da94657e --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.frozen @@ -0,0 +1 @@ +2025-11-24T17:06:46.856Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.json b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.json new file mode 100644 index 000000000..243ecc4ff --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-Conflict-response.json @@ -0,0 +1,213 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-6c891437b748aea8\",\"name\":\"test-name-6c891437b748aea8\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":0,\"created_at\":\"2025-11-24T17:06:47.453319+00:00\",\"description\":null,\"handle\":\"test-handle-6c891437b748aea8\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:06:47.453319+00:00\",\"name\":\"test-name-6c891437b748aea8\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-6c891437b748aea8\",\"name\":\"test-name-2-6c891437b748aea8\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"21296c73-c9e2-4889-a33f-417d2974b2bd\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":2,\"created_at\":\"2025-11-24T17:06:48.020887+00:00\",\"description\":null,\"handle\":\"test-handle-2-6c891437b748aea8\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:06:48.020887+00:00\",\"name\":\"test-name-2-6c891437b748aea8\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/21296c73-c9e2-4889-a33f-417d2974b2bd/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/21296c73-c9e2-4889-a33f-417d2974b2bd/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"21296c73-c9e2-4889-a33f-417d2974b2bd\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"e980108e-d535-4bdf-84ca-5e8f84a68480\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:06:48.279316439Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"21296c73-c9e2-4889-a33f-417d2974b2bd\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":0,\"handle\":\"test-handle-6c891437b748aea8\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-6c891437b748aea8\",\"summary\":null,\"user_count\":0}},{\"id\":\"21296c73-c9e2-4889-a33f-417d2974b2bd\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":2,\"handle\":\"test-handle-2-6c891437b748aea8\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-6c891437b748aea8\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"21296c73-c9e2-4889-a33f-417d2974b2bd\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Conflict: could not add team 21296c73-c9e2-4889-a33f-417d2974b2bd as a member team of team 4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87 in org 321813: team hierarchy link between super team 4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87 and member team 21296c73-c9e2-4889-a33f-417d2974b2bd already exists in org 321813\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 409, + "message": "Conflict" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/e980108e-d535-4bdf-84ca-5e8f84a68480" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/21296c73-c9e2-4889-a33f-417d2974b2bd" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/4a9a1845-0ba7-4a6f-a34d-6e72a4ffda87" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:06:46 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.frozen new file mode 100644 index 000000000..bf8a8d4fa --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-24T16:01:16.053Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.json b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.json new file mode 100644 index 000000000..30d4385f0 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-OK-response.json @@ -0,0 +1,179 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-4d8084da4dfa4ed8\",\"name\":\"test-name-4d8084da4dfa4ed8\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d5b049f4-59f1-474d-ad98-5a7342a8961f\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":11,\"created_at\":\"2025-11-24T16:01:16.149673+00:00\",\"description\":null,\"handle\":\"test-handle-4d8084da4dfa4ed8\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T16:01:16.149673+00:00\",\"name\":\"test-name-4d8084da4dfa4ed8\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/d5b049f4-59f1-474d-ad98-5a7342a8961f/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/d5b049f4-59f1-474d-ad98-5a7342a8961f/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-4d8084da4dfa4ed8\",\"name\":\"test-name-2-4d8084da4dfa4ed8\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"790428f6-10bc-427d-bf36-f53ca3c197e0\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":4,\"created_at\":\"2025-11-24T16:01:16.315013+00:00\",\"description\":null,\"handle\":\"test-handle-2-4d8084da4dfa4ed8\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T16:01:16.315013+00:00\",\"name\":\"test-name-2-4d8084da4dfa4ed8\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/790428f6-10bc-427d-bf36-f53ca3c197e0/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/790428f6-10bc-427d-bf36-f53ca3c197e0/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"d5b049f4-59f1-474d-ad98-5a7342a8961f\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"790428f6-10bc-427d-bf36-f53ca3c197e0\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"6cf86539-2c6e-497e-8cef-0b285ff05514\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T16:01:16.460042023Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"d5b049f4-59f1-474d-ad98-5a7342a8961f\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"790428f6-10bc-427d-bf36-f53ca3c197e0\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"d5b049f4-59f1-474d-ad98-5a7342a8961f\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":11,\"handle\":\"test-handle-4d8084da4dfa4ed8\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-4d8084da4dfa4ed8\",\"summary\":null,\"user_count\":0}},{\"id\":\"790428f6-10bc-427d-bf36-f53ca3c197e0\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":4,\"handle\":\"test-handle-2-4d8084da4dfa4ed8\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-4d8084da4dfa4ed8\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/6cf86539-2c6e-497e-8cef-0b285ff05514" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/790428f6-10bc-427d-bf36-f53ca3c197e0" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/d5b049f4-59f1-474d-ad98-5a7342a8961f" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 16:01:16 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.frozen b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.frozen new file mode 100644 index 000000000..e4ed51cc8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.frozen @@ -0,0 +1 @@ +2025-11-24T15:48:39.900Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.json b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.json new file mode 100644 index 000000000..9ef6bef93 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Create-a-team-hierarchy-link-returns-SUCCESS-response.json @@ -0,0 +1,179 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-a75ee0b8b483d66f\",\"name\":\"test-name-a75ee0b8b483d66f\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":3,\"created_at\":\"2025-11-24T15:48:40.359260+00:00\",\"description\":null,\"handle\":\"test-handle-a75ee0b8b483d66f\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T15:48:40.359261+00:00\",\"name\":\"test-name-a75ee0b8b483d66f\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-a75ee0b8b483d66f\",\"name\":\"test-name-2-a75ee0b8b483d66f\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"2d096572-eb6a-4579-ba38-b4247cf75e17\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":8,\"created_at\":\"2025-11-24T15:48:40.893488+00:00\",\"description\":null,\"handle\":\"test-handle-2-a75ee0b8b483d66f\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T15:48:40.893488+00:00\",\"name\":\"test-name-2-a75ee0b8b483d66f\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/2d096572-eb6a-4579-ba38-b4247cf75e17/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/2d096572-eb6a-4579-ba38-b4247cf75e17/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"2d096572-eb6a-4579-ba38-b4247cf75e17\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"fb94d43b-fe10-4c5f-ae7c-4ad745428651\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T15:48:41.150923395Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"2d096572-eb6a-4579-ba38-b4247cf75e17\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":3,\"handle\":\"test-handle-a75ee0b8b483d66f\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-a75ee0b8b483d66f\",\"summary\":null,\"user_count\":0}},{\"id\":\"2d096572-eb6a-4579-ba38-b4247cf75e17\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":8,\"handle\":\"test-handle-2-a75ee0b8b483d66f\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-a75ee0b8b483d66f\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/fb94d43b-fe10-4c5f-ae7c-4ad745428651" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/2d096572-eb6a-4579-ba38-b4247cf75e17" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/b85e63cd-1d9f-4b71-a47c-f5a99d4a4afd" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 15:48:39 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.frozen b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.frozen new file mode 100644 index 000000000..21b6221c0 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.frozen @@ -0,0 +1 @@ +2025-11-24T13:19:11.816Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.json b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.json new file mode 100644 index 000000000..790fff8c8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-API-error-response-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/aaa11111-aa11-aa11-aaaa-aaaaaa111111" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Not Found: team hierarchy link not found (linkId=aaa11111-aa11-aa11-aaaa-aaaaaa111111)\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 24 Nov 2025 13:19:11 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.frozen new file mode 100644 index 000000000..be8e0fd4a --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-24T17:07:09.212Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.json b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.json new file mode 100644 index 000000000..a46e83455 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-a-team-hierarchy-link-returns-OK-response.json @@ -0,0 +1,207 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-ae3e76a23be3747a\",\"name\":\"test-name-ae3e76a23be3747a\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":11,\"created_at\":\"2025-11-24T17:07:09.817794+00:00\",\"description\":null,\"handle\":\"test-handle-ae3e76a23be3747a\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:07:09.817794+00:00\",\"name\":\"test-name-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/fafeac94-42b4-4469-91e8-0ae5ca3f564b/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/fafeac94-42b4-4469-91e8-0ae5ca3f564b/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-ae3e76a23be3747a\",\"name\":\"test-name-2-ae3e76a23be3747a\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":4,\"created_at\":\"2025-11-24T17:07:10.381761+00:00\",\"description\":null,\"handle\":\"test-handle-2-ae3e76a23be3747a\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:07:10.381761+00:00\",\"name\":\"test-name-2-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/196bcc55-bd30-4cfd-8549-b3d255a0517b/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/196bcc55-bd30-4cfd-8549-b3d255a0517b/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"5401e712-de1b-4deb-ac35-2c6ee1943ad0\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:07:10.643798843Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":11,\"handle\":\"test-handle-ae3e76a23be3747a\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0}},{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":4,\"handle\":\"test-handle-2-ae3e76a23be3747a\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/5401e712-de1b-4deb-ac35-2c6ee1943ad0" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"5401e712-de1b-4deb-ac35-2c6ee1943ad0\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:07:10.643799Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\"}}}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/team-hierarchy-links/5401e712-de1b-4deb-ac35-2c6ee1943ad0\"},\"included\":[{\"id\":\"196bcc55-bd30-4cfd-8549-b3d255a0517b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":4,\"handle\":\"test-handle-2-ae3e76a23be3747a\",\"is_managed\":false,\"is_open_membership\":true,\"link_count\":0,\"name\":\"test-name-2-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0}},{\"id\":\"fafeac94-42b4-4469-91e8-0ae5ca3f564b\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":11,\"handle\":\"test-handle-ae3e76a23be3747a\",\"is_managed\":false,\"is_open_membership\":true,\"link_count\":0,\"name\":\"test-name-ae3e76a23be3747a\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/5401e712-de1b-4deb-ac35-2c6ee1943ad0" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/196bcc55-bd30-4cfd-8549-b3d255a0517b" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/fafeac94-42b4-4469-91e8-0ae5ca3f564b" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:07:09 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.frozen new file mode 100644 index 000000000..1d3731961 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-11-24T17:18:13.180Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.json b/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.json new file mode 100644 index 000000000..fc294aa14 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Get-team-hierarchy-links-returns-OK-response.json @@ -0,0 +1,207 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-ab0ee85594ae1dfd\",\"name\":\"test-name-ab0ee85594ae1dfd\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":6,\"created_at\":\"2025-11-24T17:18:13.814865+00:00\",\"description\":null,\"handle\":\"test-handle-ab0ee85594ae1dfd\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:18:13.814865+00:00\",\"name\":\"test-name-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/d1baf3de-7316-43b5-8582-dc887acc26ef/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/d1baf3de-7316-43b5-8582-dc887acc26ef/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-ab0ee85594ae1dfd\",\"name\":\"test-name-2-ab0ee85594ae1dfd\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":13,\"created_at\":\"2025-11-24T17:18:14.383042+00:00\",\"description\":null,\"handle\":\"test-handle-2-ab0ee85594ae1dfd\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:18:14.383042+00:00\",\"name\":\"test-name-2-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/61b0ab36-c1e5-47fd-898a-ba9bfc860e9d/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/61b0ab36-c1e5-47fd-898a-ba9bfc860e9d/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"61509612-5bb0-42c5-a16e-bf4920acf473\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:18:14.635205462Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":6,\"handle\":\"test-handle-ab0ee85594ae1dfd\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0}},{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":13,\"handle\":\"test-handle-2-ab0ee85594ae1dfd\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links?filter%5Bparent_team%5D=d1baf3de-7316-43b5-8582-dc887acc26ef&filter%5Bsub_team%5D=61b0ab36-c1e5-47fd-898a-ba9bfc860e9d&page%5Bnumber%5D=0&page%5Bsize%5D=100" + }, + "response": { + "body": { + "string": "{\"data\":[{\"id\":\"61509612-5bb0-42c5-a16e-bf4920acf473\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:18:14.635205Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\"}}}}],\"meta\":{\"page\":{\"type\":\"number_size\",\"number\":0,\"size\":100,\"total\":1,\"first_number\":0,\"prev_number\":null,\"next_number\":null,\"last_number\":0}},\"links\":{\"self\":\"https://api.datadoghq.com/api/v2/team-hierarchy-links?filter%5Bparent_team%5D=d1baf3de-7316-43b5-8582-dc887acc26ef\\u0026filter%5Bsub_team%5D=61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\\u0026page%5Bnumber%5D=0\\u0026page%5Bsize%5D=100\",\"first\":\"https://api.datadoghq.com/api/v2/team-hierarchy-links?filter[parent_team]=d1baf3de-7316-43b5-8582-dc887acc26ef\\u0026filter[sub_team]=61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\\u0026page[number]=0\\u0026page[size]=100\",\"last\":\"https://api.datadoghq.com/api/v2/team-hierarchy-links?filter[parent_team]=d1baf3de-7316-43b5-8582-dc887acc26ef\\u0026filter[sub_team]=61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\\u0026page[number]=0\\u0026page[size]=100\"},\"included\":[{\"id\":\"61b0ab36-c1e5-47fd-898a-ba9bfc860e9d\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":13,\"handle\":\"test-handle-2-ab0ee85594ae1dfd\",\"is_managed\":false,\"is_open_membership\":true,\"link_count\":0,\"name\":\"test-name-2-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0}},{\"id\":\"d1baf3de-7316-43b5-8582-dc887acc26ef\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":6,\"handle\":\"test-handle-ab0ee85594ae1dfd\",\"is_managed\":false,\"is_open_membership\":true,\"link_count\":0,\"name\":\"test-name-ab0ee85594ae1dfd\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/61509612-5bb0-42c5-a16e-bf4920acf473" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/61b0ab36-c1e5-47fd-898a-ba9bfc860e9d" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/d1baf3de-7316-43b5-8582-dc887acc26ef" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:18:13 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.frozen b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.frozen new file mode 100644 index 000000000..73f686747 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.frozen @@ -0,0 +1 @@ +2025-11-24T13:14:20.481Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.json b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.json new file mode 100644 index 000000000..b5ca8c318 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-API-error-response-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/aaa11111-aa11-aa11-aaaa-aaaaaa111111" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Not Found: link with id aaa11111-aa11-aa11-aaaa-aaaaaa111111 not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 24 Nov 2025 13:14:20 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.frozen b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.frozen new file mode 100644 index 000000000..be1311ed7 --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-11-24T17:08:01.196Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.json b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.json new file mode 100644 index 000000000..78149960d --- /dev/null +++ b/tests/scenarios/cassettes/v2/teams/Remove-a-team-hierarchy-link-returns-No-Content-response.json @@ -0,0 +1,207 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-db31819631324305\",\"name\":\"test-name-db31819631324305\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"eaf01981-6b63-41ba-b49f-30449c50e865\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":10,\"created_at\":\"2025-11-24T17:08:01.930314+00:00\",\"description\":null,\"handle\":\"test-handle-db31819631324305\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:08:01.930314+00:00\",\"name\":\"test-name-db31819631324305\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/eaf01981-6b63-41ba-b49f-30449c50e865/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/eaf01981-6b63-41ba-b49f-30449c50e865/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"handle\":\"test-handle-2-db31819631324305\",\"name\":\"test-name-2-db31819631324305\"},\"type\":\"team\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"120aeb27-ca42-4e38-a9e4-6497b8f9407c\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":6,\"created_at\":\"2025-11-24T17:08:02.174211+00:00\",\"description\":null,\"handle\":\"test-handle-2-db31819631324305\",\"hidden_modules\":null,\"is_managed\":false,\"link_count\":0,\"modified_at\":\"2025-11-24T17:08:02.174211+00:00\",\"name\":\"test-name-2-db31819631324305\",\"summary\":null,\"user_count\":0,\"visible_modules\":null},\"relationships\":{\"team_links\":{\"data\":[],\"links\":{\"related\":\"/api/v2/team/120aeb27-ca42-4e38-a9e4-6497b8f9407c/links\"}},\"user_team_permissions\":{\"data\":null,\"links\":{\"related\":\"/api/v2/team/120aeb27-ca42-4e38-a9e4-6497b8f9407c/permission-settings\"}}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"eaf01981-6b63-41ba-b49f-30449c50e865\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"120aeb27-ca42-4e38-a9e4-6497b8f9407c\",\"type\":\"team\"}}},\"type\":\"team_hierarchy_links\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"185446b8-1e88-419c-b266-3933f1411b6e\",\"type\":\"team_hierarchy_links\",\"attributes\":{\"created_at\":\"2025-11-24T17:08:02.736655421Z\",\"provisioned_by\":\"\"},\"relationships\":{\"parent_team\":{\"data\":{\"id\":\"eaf01981-6b63-41ba-b49f-30449c50e865\",\"type\":\"team\"}},\"sub_team\":{\"data\":{\"id\":\"120aeb27-ca42-4e38-a9e4-6497b8f9407c\",\"type\":\"team\"}}}},\"included\":[{\"id\":\"eaf01981-6b63-41ba-b49f-30449c50e865\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":10,\"handle\":\"test-handle-db31819631324305\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-db31819631324305\",\"summary\":null,\"user_count\":0}},{\"id\":\"120aeb27-ca42-4e38-a9e4-6497b8f9407c\",\"type\":\"team\",\"attributes\":{\"avatar\":null,\"banner\":6,\"handle\":\"test-handle-2-db31819631324305\",\"is_managed\":false,\"is_open_membership\":false,\"link_count\":0,\"name\":\"test-name-2-db31819631324305\",\"summary\":null,\"user_count\":0}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/185446b8-1e88-419c-b266-3933f1411b6e" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team-hierarchy-links/185446b8-1e88-419c-b266-3933f1411b6e" + }, + "response": { + "body": { + "string": "{\"errors\":[\"Not Found: link with id 185446b8-1e88-419c-b266-3933f1411b6e not found\"]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/120aeb27-ca42-4e38-a9e4-6497b8f9407c" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/team/eaf01981-6b63-41ba-b49f-30449c50e865" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Mon, 24 Nov 2025 17:08:01 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 198c7af1b..6c6d3bf98 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": [ { @@ -1169,6 +1181,30 @@ "tag": "Teams", "operationId": "CreateTeam" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"handle\": \"test-handle-2-{{ unique_hash }}\",\n \"name\": \"test-name-2-{{ unique_hash }}\"\n },\n \"type\": \"team\"\n }\n}" + } + ], + "step": "there is a valid \"dd_team_2\" in the system", + "key": "dd_team_2", + "tag": "Teams", + "operationId": "CreateTeam" + }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"team_hierarchy_links\",\n \"relationships\": {\n \"parent_team\": {\n \"data\": {\n \"id\": \"{{ dd_team.data.id }}\",\n \"type\": \"team\"\n }\n },\n \"sub_team\": {\n \"data\": {\n \"id\": \"{{ dd_team_2.data.id }}\",\n \"type\": \"team\"\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"team_hierarchy_link\" in the system", + "key": "team_hierarchy_link", + "tag": "Teams", + "operationId": "AddTeamHierarchyLink" + }, { "source": "data.data[0]", "step": "there is a valid \"team_connection\" in the system", 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 000000000..44d65b92f --- /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/teams.feature b/tests/scenarios/features/v2/teams.feature index bf11bd031..faa1ca088 100644 --- a/tests/scenarios/features/v2/teams.feature +++ b/tests/scenarios/features/v2/teams.feature @@ -43,6 +43,25 @@ Feature: Teams When the request is sent Then the response status is 200 Represents a user's association to a team + @team:DataDog/aaa-omg + Scenario: Create a team hierarchy link returns "Conflict" response + Given new "AddTeamHierarchyLink" request + And there is a valid "dd_team" in the system + And there is a valid "dd_team_2" in the system + And there is a valid "team_hierarchy_link" in the system + And body with value {"data": {"relationships": {"parent_team": {"data": {"id": "{{team_hierarchy_link.data.relationships.parent_team.data.id}}", "type": "team"}}, "sub_team": {"data": {"id": "{{team_hierarchy_link.data.relationships.sub_team.data.id}}", "type": "team"}}}, "type": "team_hierarchy_links"}} + When the request is sent + Then the response status is 409 Conflict + + @team:DataDog/aaa-omg + Scenario: Create a team hierarchy link returns "OK" response + Given new "AddTeamHierarchyLink" request + And there is a valid "dd_team" in the system + And there is a valid "dd_team_2" in the system + And body with value {"data": {"relationships": {"parent_team": {"data": {"id": "{{dd_team.data.id}}", "type": "team"}}, "sub_team": {"data": {"id": "{{dd_team_2.data.id}}", "type": "team"}}}, "type": "team_hierarchy_links"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/aaa-omg Scenario: Create a team link returns "API error response." response Given new "CreateTeamLink" request @@ -96,6 +115,28 @@ Feature: Teams And the response "data.attributes.visible_modules" is equal to ["m1","m2"] And the response "data.attributes.hidden_modules" is equal to ["m3"] + @team:DataDog/aaa-omg + Scenario: Get a team hierarchy link returns "API error response." response + Given new "GetTeamHierarchyLink" request + And request contains "link_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 API error response. + + @team:DataDog/aaa-omg + Scenario: Get a team hierarchy link returns "OK" response + Given new "GetTeamHierarchyLink" request + And there is a valid "dd_team" in the system + And there is a valid "dd_team_2" in the system + And there is a valid "team_hierarchy_link" in the system + And request contains "link_id" parameter from "team_hierarchy_link.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" is equal to "{{ team_hierarchy_link.data.id }}" + And the response "data.relationships.parent_team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "data.relationships.sub_team.data.id" is equal to "{{ dd_team_2.data.id }}" + And the response "included" has item with field "id" with value "{{ dd_team.data.id }}" + And the response "included" has item with field "id" with value "{{ dd_team_2.data.id }}" + @team:DataDog/aaa-omg Scenario: Get a team link returns "API error response." response Given new "GetTeamLink" request @@ -211,6 +252,31 @@ Feature: Teams When the request is sent Then the response status is 200 OK + @team:DataDog/aaa-omg + Scenario: Get team hierarchy links returns "OK" response + Given new "ListTeamHierarchyLinks" request + And there is a valid "dd_team" in the system + And there is a valid "dd_team_2" in the system + And there is a valid "team_hierarchy_link" in the system + And request contains "filter[parent_team]" parameter from "team_hierarchy_link.data.relationships.parent_team.data.id" + And request contains "filter[sub_team]" parameter from "team_hierarchy_link.data.relationships.sub_team.data.id" + And request contains "page[number]" parameter with value 0 + And request contains "page[size]" parameter with value 100 + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].id" is equal to "{{ team_hierarchy_link.data.id }}" + And the response "data[0].relationships.parent_team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "data[0].relationships.sub_team.data.id" is equal to "{{ dd_team_2.data.id }}" + And the response "included" has item with field "id" with value "{{ dd_team.data.id }}" + And the response "included" has item with field "id" with value "{{ dd_team_2.data.id }}" + + @generated @skip @team:DataDog/aaa-omg @with-pagination + Scenario: Get team hierarchy links returns "OK" response with pagination + Given new "ListTeamHierarchyLinks" request + When the request with pagination is sent + Then the response status is 200 OK + @team:DataDog/aaa-omg Scenario: Get team memberships returns "API error response." response Given new "GetTeamMemberships" request @@ -293,6 +359,23 @@ Feature: Teams When the request is sent Then the response status is 204 No Content + @team:DataDog/aaa-omg + Scenario: Remove a team hierarchy link returns "API error response." response + Given new "RemoveTeamHierarchyLink" request + And request contains "link_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" + When the request is sent + Then the response status is 404 API error response. + + @team:DataDog/aaa-omg + Scenario: Remove a team hierarchy link returns "No Content" response + Given new "RemoveTeamHierarchyLink" request + And there is a valid "dd_team" in the system + And there is a valid "dd_team_2" in the system + And there is a valid "team_hierarchy_link" in the system + And request contains "link_id" parameter from "team_hierarchy_link.data.id" + When the request is sent + Then the response status is 204 No Content + @team:DataDog/aaa-omg Scenario: Remove a team link returns "API error response." response Given new "DeleteTeamLink" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 3799e64e6..7c226bf60 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": { @@ -4345,6 +4418,37 @@ "type": "unsafe" } }, + "ListTeamHierarchyLinks": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, + "AddTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "operationId": "RemoveTeamHierarchyLink", + "parameters": [ + { + "name": "link_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "RemoveTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "type": "idempotent" + } + }, + "GetTeamHierarchyLink": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, "DeleteTeamConnections": { "tag": "Team Connections", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 4f9cae93a..925d69993 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -110,6 +110,8 @@ pub struct ApiInstances { pub v2_api_logs_custom_destinations: Option, pub v2_api_logs_metrics: Option, + pub v2_api_logs_restriction_queries: + Option, pub v2_api_metrics: Option, pub v2_api_monitors: Option, pub v2_api_network_device_monitoring: @@ -773,6 +775,12 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "LogsRestrictionQueries" => { + world.api_instances.v2_api_logs_restriction_queries = Some(datadogV2::api_logs_restriction_queries::LogsRestrictionQueriesAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone() + )); + } "NetworkDeviceMonitoring" => { world.api_instances.v2_api_network_device_monitoring = Some(datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI::with_client_and_config( world.config.clone(), @@ -3478,6 +3486,50 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateLogsMetric".into(), test_v2_update_logs_metric); + world.function_mappings.insert( + "v2.ListRestrictionQueries".into(), + test_v2_list_restriction_queries, + ); + world.function_mappings.insert( + "v2.CreateRestrictionQuery".into(), + test_v2_create_restriction_query, + ); + world.function_mappings.insert( + "v2.GetRoleRestrictionQuery".into(), + test_v2_get_role_restriction_query, + ); + world.function_mappings.insert( + "v2.ListUserRestrictionQueries".into(), + test_v2_list_user_restriction_queries, + ); + world.function_mappings.insert( + "v2.DeleteRestrictionQuery".into(), + test_v2_delete_restriction_query, + ); + world.function_mappings.insert( + "v2.GetRestrictionQuery".into(), + test_v2_get_restriction_query, + ); + world.function_mappings.insert( + "v2.UpdateRestrictionQuery".into(), + test_v2_update_restriction_query, + ); + world.function_mappings.insert( + "v2.ReplaceRestrictionQuery".into(), + test_v2_replace_restriction_query, + ); + world.function_mappings.insert( + "v2.RemoveRoleFromRestrictionQuery".into(), + test_v2_remove_role_from_restriction_query, + ); + world.function_mappings.insert( + "v2.ListRestrictionQueryRoles".into(), + test_v2_list_restriction_query_roles, + ); + world.function_mappings.insert( + "v2.AddRoleToRestrictionQuery".into(), + test_v2_add_role_to_restriction_query, + ); world.function_mappings.insert( "v2.ListTagConfigurations".into(), test_v2_list_tag_configurations, @@ -4253,6 +4305,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.CreateTeam".into(), test_v2_create_team); + world.function_mappings.insert( + "v2.ListTeamHierarchyLinks".into(), + test_v2_list_team_hierarchy_links, + ); + world.function_mappings.insert( + "v2.ListTeamHierarchyLinksWithPagination".into(), + test_v2_list_team_hierarchy_links_with_pagination, + ); + world.function_mappings.insert( + "v2.AddTeamHierarchyLink".into(), + test_v2_add_team_hierarchy_link, + ); + world.function_mappings.insert( + "v2.RemoveTeamHierarchyLink".into(), + test_v2_remove_team_hierarchy_link, + ); + world.function_mappings.insert( + "v2.GetTeamHierarchyLink".into(), + test_v2_get_team_hierarchy_link, + ); world .function_mappings .insert("v2.GetTeamSync".into(), test_v2_get_team_sync); @@ -26027,6 +26099,350 @@ fn test_v2_update_logs_metric(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_logs_restriction_queries::ListRestrictionQueriesOptionalParams::default(); + params.page_size = page_size; + params.page_number = page_number; + let response = match block_on(api.list_restriction_queries_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_restriction_query_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_role_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let role_id = serde_json::from_value(_parameters.get("role_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_role_restriction_query_with_http_info(role_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_list_user_restriction_queries( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let user_id = serde_json::from_value(_parameters.get("user_id").unwrap().clone()).unwrap(); + let response = match block_on(api.list_user_restriction_queries_with_http_info(user_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_restriction_query_with_http_info(restriction_query_id)) + { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_restriction_query(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_restriction_query_with_http_info(restriction_query_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = + match block_on(api.update_restriction_query_with_http_info(restriction_query_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_replace_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = + match block_on(api.replace_restriction_query_with_http_info(restriction_query_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_remove_role_from_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on( + api.remove_role_from_restriction_query_with_http_info(restriction_query_id, body), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_list_restriction_query_roles( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_logs_restriction_queries::ListRestrictionQueryRolesOptionalParams::default(); + params.page_size = page_size; + params.page_number = page_number; + let response = match block_on( + api.list_restriction_query_roles_with_http_info(restriction_query_id, params), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_add_role_to_restriction_query( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_logs_restriction_queries + .as_ref() + .expect("api instance not found"); + let restriction_query_id = + serde_json::from_value(_parameters.get("restriction_query_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on( + api.add_role_to_restriction_query_with_http_info(restriction_query_id, body), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_tag_configurations(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances @@ -32726,6 +33142,181 @@ fn test_v2_create_team(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_parent_team = _parameters + .get("filter[parent_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sub_team = _parameters + .get("filter[sub_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_teams::ListTeamHierarchyLinksOptionalParams::default(); + params.page_number = page_number; + params.page_size = page_size; + params.filter_parent_team = filter_parent_team; + params.filter_sub_team = filter_sub_team; + let response = match block_on(api.list_team_hierarchy_links_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} +fn test_v2_list_team_hierarchy_links_with_pagination( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_parent_team = _parameters + .get("filter[parent_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let filter_sub_team = _parameters + .get("filter[sub_team]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_teams::ListTeamHierarchyLinksOptionalParams::default(); + params.page_number = page_number; + params.page_size = page_size; + params.filter_parent_team = filter_parent_team; + params.filter_sub_team = filter_sub_team; + let response = api.list_team_hierarchy_links_with_pagination(params); + let mut result = Vec::new(); + + block_on(async { + pin_mut!(response); + + while let Some(resp) = response.next().await { + match resp { + Ok(response) => { + result.push(response); + } + Err(error) => { + return match error { + Error::ResponseError(e) => { + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {}", error), + }; + } + } + } + }); + world.response.object = serde_json::to_value(result).unwrap(); + world.response.code = 200; +} + +fn test_v2_add_team_hierarchy_link(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.add_team_hierarchy_link_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_remove_team_hierarchy_link( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let link_id = serde_json::from_value(_parameters.get("link_id").unwrap().clone()).unwrap(); + let response = match block_on(api.remove_team_hierarchy_link_with_http_info(link_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_team_hierarchy_link(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_teams + .as_ref() + .expect("api instance not found"); + let link_id = serde_json::from_value(_parameters.get("link_id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_team_hierarchy_link_with_http_info(link_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_get_team_sync(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances