diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index aa57375c89..3673b7d402 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -130111,6 +130111,360 @@ components: meta: $ref: "#/components/schemas/TeamsHierarchyLinksResponseMeta" type: object + TeamHierarchyMember: + description: A user relationship to the requested team. + properties: + attributes: + $ref: "#/components/schemas/TeamHierarchyMemberAttributes" + id: + description: Relationship identifier containing the team UUID and user UUID. + example: UserTeamRelationship:692e8073-12c4-4c71-8408-5090bd44c9c8:00000000-0000-0000-0000-000000000001 + type: string + relationships: + $ref: "#/components/schemas/TeamHierarchyMemberRelationships" + type: + $ref: "#/components/schemas/TeamHierarchyMemberType" + required: + - id + - type + - attributes + - relationships + type: object + TeamHierarchyMemberAttributes: + description: Membership attributes relative to the requested team. + properties: + direct_role: + description: "Role on the requested team: admin or member. Null for inherited members." + example: member + nullable: true + pattern: ^(admin|member)$ + type: string + is_direct: + description: Whether the user belongs directly to the requested team. + example: true + type: boolean + provisioned_by: + description: Membership provisioner. Null for inherited members. + example: manual + nullable: true + type: string + provisioned_by_id: + description: Identifier supplied by the membership provisioner. Null when unavailable or for inherited members. + example: + nullable: true + type: string + required: + - is_direct + - direct_role + - provisioned_by + - provisioned_by_id + type: object + TeamHierarchyMemberIncluded: + description: An included user or the requested team, distinguished by resource type. + oneOf: + - $ref: "#/components/schemas/TeamHierarchyMemberUser" + - $ref: "#/components/schemas/TeamHierarchyMemberTeam" + TeamHierarchyMemberRelationships: + description: User and requested team linkage. + properties: + team: + $ref: "#/components/schemas/TeamHierarchyMemberTeamRelationship" + user: + $ref: "#/components/schemas/TeamHierarchyMemberUserRelationship" + required: + - user + - team + type: object + TeamHierarchyMemberTeam: + description: The requested team, included at most once. Descendant teams are not included. + properties: + attributes: + $ref: "#/components/schemas/TeamHierarchyMemberTeamAttributes" + id: + description: UUID of the requested team. + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + format: uuid + type: string + type: + $ref: "#/components/schemas/TeamHierarchyMemberTeamType" + required: + - id + - type + type: object + TeamHierarchyMemberTeamAttributes: + description: Available attributes of the requested team. + properties: + handle: + description: Handle of the team. + example: platform + type: string + name: + description: Name of the team. + example: Platform + type: string + type: object + TeamHierarchyMemberTeamData: + description: Team resource identifier. + properties: + id: + description: UUID of the team. + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + format: uuid + type: string + type: + $ref: "#/components/schemas/TeamHierarchyMemberTeamType" + required: + - id + - type + type: object + TeamHierarchyMemberTeamRelationship: + description: Linkage to the requested team. + properties: + data: + $ref: "#/components/schemas/TeamHierarchyMemberTeamData" + required: + - data + type: object + TeamHierarchyMemberTeamType: + default: teams + description: Requested team resource type. + enum: + - teams + example: teams + type: string + x-enum-varnames: + - TEAMS + TeamHierarchyMemberType: + default: user_team_relationship + description: Team hierarchy membership resource type. + enum: + - user_team_relationship + example: user_team_relationship + type: string + x-enum-varnames: + - USER_TEAM_RELATIONSHIP + TeamHierarchyMemberUser: + description: A user included in the hierarchy members response. + properties: + attributes: + $ref: "#/components/schemas/UserAttributes" + id: + description: UUID of the user. + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + type: + $ref: "#/components/schemas/UsersType" + required: + - id + - type + - attributes + type: object + TeamHierarchyMemberUserData: + description: User resource identifier. + properties: + id: + description: UUID of the user. + example: 00000000-0000-0000-0000-000000000001 + format: uuid + type: string + type: + $ref: "#/components/schemas/UsersType" + required: + - id + - type + type: object + TeamHierarchyMemberUserRelationship: + description: Linkage to the user. + properties: + data: + $ref: "#/components/schemas/TeamHierarchyMemberUserData" + required: + - data + type: object + TeamHierarchyMembersNumberPage: + description: Pagination metadata using number and size. + properties: + first_number: + description: First page number. + example: 0 + format: int64 + type: integer + last_number: + description: Last page number. Null when unavailable. + example: 0 + format: int64 + nullable: true + type: integer + next_number: + description: Next page number. Null when unavailable. + example: + format: int64 + nullable: true + type: integer + number: + description: Current zero-based page number. + example: 0 + format: int64 + type: integer + prev_number: + description: Previous page number. Null when unavailable. + example: + format: int64 + nullable: true + type: integer + size: + description: Maximum number of members per page. + example: 100 + format: int64 + type: integer + total: + description: Total number of members matching the filters. + example: 2 + format: int64 + type: integer + type: + $ref: "#/components/schemas/TeamHierarchyMembersNumberPageType" + required: + - type + - number + - size + - total + - first_number + - prev_number + - next_number + - last_number + type: object + TeamHierarchyMembersNumberPageType: + default: number_size + description: Pagination mode. + enum: + - number_size + example: number_size + type: string + x-enum-varnames: + - NUMBER_SIZE + TeamHierarchyMembersOffsetPage: + description: Pagination metadata using offset and limit. + properties: + first_offset: + description: First offset. + example: 0 + format: int64 + type: integer + last_offset: + description: Last offset. Null when unavailable. + example: 0 + format: int64 + nullable: true + type: integer + limit: + description: Maximum number of members per page. + example: 100 + format: int64 + type: integer + next_offset: + description: Next offset. Null when unavailable. + example: + format: int64 + nullable: true + type: integer + offset: + description: Current offset. + example: 0 + format: int64 + type: integer + prev_offset: + description: Previous offset. Null when unavailable. + example: + format: int64 + nullable: true + type: integer + total: + description: Total number of members matching the filters. + example: 2 + format: int64 + type: integer + type: + $ref: "#/components/schemas/TeamHierarchyMembersOffsetPageType" + required: + - type + - offset + - limit + - total + - first_offset + - prev_offset + - next_offset + - last_offset + type: object + TeamHierarchyMembersOffsetPageType: + default: offset_limit + description: Pagination mode. + enum: + - offset_limit + example: offset_limit + type: string + x-enum-varnames: + - OFFSET_LIMIT + TeamHierarchyMembersPage: + description: Pagination metadata for the selected pagination mode. + oneOf: + - $ref: "#/components/schemas/TeamHierarchyMembersOffsetPage" + - $ref: "#/components/schemas/TeamHierarchyMembersNumberPage" + TeamHierarchyMembersResponse: + description: Direct and inherited members of the requested team. + properties: + data: + description: One relationship per user. + items: + $ref: "#/components/schemas/TeamHierarchyMember" + type: array + included: + description: Requested users and the team. May be absent when the result is empty, even if requested. + items: + $ref: "#/components/schemas/TeamHierarchyMemberIncluded" + type: array + links: + $ref: "#/components/schemas/TeamHierarchyMembersResponseLinks" + meta: + $ref: "#/components/schemas/TeamHierarchyMembersResponseMeta" + required: + - data + - meta + - links + type: object + TeamHierarchyMembersResponseLinks: + description: Page navigation links. Unavailable links are omitted. + properties: + first: + description: First page URL. + example: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + type: string + last: + description: Last page URL. + example: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + type: string + next: + description: Next page URL. + example: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + type: string + prev: + description: Previous page URL. + example: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + type: string + self: + description: Current page URL. + example: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + type: string + type: object + TeamHierarchyMembersResponseMeta: + description: Pagination metadata for the filtered members. + properties: + page: + $ref: "#/components/schemas/TeamHierarchyMembersPage" + required: + - page + type: object TeamIncluded: description: Included resources related to the team oneOf: @@ -243616,6 +243970,267 @@ paths: operator: OR permissions: - teams_read + /api/v2/team/{team_id}/members: + get: + description: |- + List the direct and inherited members of a team, deduplicated by user. + Members of descendant teams are included unless `filter[is_direct_only]` is true. + Datadog support users are always excluded. + + Use `page[number]` and `page[size]` to paginate through the results. + Invalid query parameters return a JSON:API error with status 400. + Invalid or unknown team UUIDs return status 404. + operationId: GetTeamHierarchyMembers + parameters: + - description: UUID of the requested root team. + in: path + name: team_id + required: true + schema: + example: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: string + - description: Return only direct members. By default, members inherited from descendant teams are also returned. + in: query + name: filter[is_direct_only] + required: false + schema: + default: false + example: false + type: boolean + - description: Include service accounts. Datadog support users are always excluded. + in: query + name: filter[include_service_accounts] + required: false + schema: + default: true + example: true + type: boolean + - description: Filter by a case-insensitive substring of the user name, handle, or email. + in: query + name: filter[keyword] + required: false + schema: + example: alice + type: string + - description: "Comma-separated resources to include: `user` and `team`. The included team is the requested team." + in: query + name: include + required: false + schema: + example: user,team + type: string + - description: "Comma-separated sort fields: `name`, `handle`, `is_direct`, and `provisioned_by`. Fields are applied in order, each optionally prefixed with `-` for descending order. By default, team admins come first, followed by other direct members, then inherited members, sorted by name within each group." + in: query + name: sort + required: false + schema: + example: is_direct,-name + type: string + - description: Zero-based page number. Negative values become 0. Defaults to 0. + in: query + name: page[number] + required: false + schema: + default: 0 + example: 0 + format: int64 + type: integer + - description: Members per page, from 1 to 100. Values outside this range use the default of 100. + in: query + name: page[size] + required: false + schema: + default: 100 + example: 100 + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + summary: Direct and inherited members with number pagination + value: + data: + - attributes: + direct_role: admin + is_direct: true + provisioned_by: manual + provisioned_by_id: + id: UserTeamRelationship:692e8073-12c4-4c71-8408-5090bd44c9c8:00000000-0000-0000-0000-000000000001 + relationships: + team: + data: + id: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: teams + user: + data: + id: 00000000-0000-0000-0000-000000000001 + type: users + type: user_team_relationship + - attributes: + direct_role: + is_direct: false + provisioned_by: + provisioned_by_id: + id: UserTeamRelationship:692e8073-12c4-4c71-8408-5090bd44c9c8:00000000-0000-0000-0000-000000000002 + relationships: + team: + data: + id: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: teams + user: + data: + id: 00000000-0000-0000-0000-000000000002 + type: users + type: user_team_relationship + links: + first: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + last: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + self: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + meta: + page: + first_number: 0 + last_number: 0 + next_number: + number: 0 + prev_number: + size: 100 + total: 2 + type: number_size + empty: + summary: No matching members, with included resources omitted + value: + data: [] + links: + first: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + last: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + self: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?page%5Bnumber%5D=0&page%5Bsize%5D=100 + meta: + page: + first_number: 0 + last_number: 0 + next_number: + number: 0 + prev_number: + size: 100 + total: 0 + type: number_size + included_resources: + summary: Users and the team with number pagination + value: + data: + - attributes: + direct_role: admin + is_direct: true + provisioned_by: manual + provisioned_by_id: + id: UserTeamRelationship:692e8073-12c4-4c71-8408-5090bd44c9c8:00000000-0000-0000-0000-000000000001 + relationships: + team: + data: + id: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: teams + user: + data: + id: 00000000-0000-0000-0000-000000000001 + type: users + type: user_team_relationship + - attributes: + direct_role: + is_direct: false + provisioned_by: + provisioned_by_id: + id: UserTeamRelationship:692e8073-12c4-4c71-8408-5090bd44c9c8:00000000-0000-0000-0000-000000000002 + relationships: + team: + data: + id: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: teams + user: + data: + id: 00000000-0000-0000-0000-000000000002 + type: users + type: user_team_relationship + included: + - attributes: + email: alice@example.com + handle: alice@example.com + name: Alice + title: + id: 00000000-0000-0000-0000-000000000001 + type: users + - attributes: + email: bob@example.com + handle: bob@example.com + name: + title: + id: 00000000-0000-0000-0000-000000000002 + type: users + - attributes: + handle: platform + name: Platform + id: 692e8073-12c4-4c71-8408-5090bd44c9c8 + type: teams + links: + first: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?include=user%2Cteam&page%5Bnumber%5D=0&page%5Bsize%5D=100 + last: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?include=user%2Cteam&page%5Bnumber%5D=0&page%5Bsize%5D=100 + self: https://api.datadoghq.com/api/v2/team/692e8073-12c4-4c71-8408-5090bd44c9c8/members?include=user%2Cteam&page%5Bnumber%5D=0&page%5Bsize%5D=100 + meta: + page: + first_number: 0 + last_number: 0 + next_number: + number: 0 + prev_number: + size: 100 + total: 2 + type: number_size + schema: + $ref: "#/components/schemas/TeamHierarchyMembersResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - teams_read + summary: Get team hierarchy members + tags: + - Teams + x-pagination: + limitParam: page[size] + pageParam: page[number] + resultsPath: data + x-permission: + operator: OR + permissions: + - teams_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/team/{team_id}/memberships: get: description: Get a paginated list of members for a team diff --git a/examples/v2/teams/GetTeamHierarchyMembers.py b/examples/v2/teams/GetTeamHierarchyMembers.py new file mode 100644 index 0000000000..666a0f1cdb --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers.py @@ -0,0 +1,26 @@ +""" +Get team hierarchy members returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +# there is a valid "user" in the system +USER_DATA_ATTRIBUTES_EMAIL = environ["USER_DATA_ATTRIBUTES_EMAIL"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword=USER_DATA_ATTRIBUTES_EMAIL, + include="user,team", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_1000871040.py b/examples/v2/teams/GetTeamHierarchyMembers_1000871040.py new file mode 100644 index 0000000000..ead6fd9bf9 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_1000871040.py @@ -0,0 +1,25 @@ +""" +Get team hierarchy members paginates by number and size +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + sort="-is_direct", + page_number=1, + page_size=1, + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_1140593961.py b/examples/v2/teams/GetTeamHierarchyMembers_1140593961.py new file mode 100644 index 0000000000..d14a81a9d2 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_1140593961.py @@ -0,0 +1,24 @@ +""" +Get team hierarchy members normalizes number pagination +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + page_number=-1, + page_size=101, + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_2494043793.py b/examples/v2/teams/GetTeamHierarchyMembers_2494043793.py new file mode 100644 index 0000000000..a67fce81b4 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_2494043793.py @@ -0,0 +1,22 @@ +""" +Get team hierarchy members filters names case insensitively +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="hIeRaRcHy MeMbEr", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_3103330950.py b/examples/v2/teams/GetTeamHierarchyMembers_3103330950.py new file mode 100644 index 0000000000..a7f8373367 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_3103330950.py @@ -0,0 +1,23 @@ +""" +Get team hierarchy members returns empty results +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="no-matching-member-Example-Team", + include="user,team", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_3197180671.py b/examples/v2/teams/GetTeamHierarchyMembers_3197180671.py new file mode 100644 index 0000000000..fd8a1b2b82 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_3197180671.py @@ -0,0 +1,24 @@ +""" +Get team hierarchy members deduplicates direct and inherited membership +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + include="team", + sort="-is_direct,handle", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_3330810309.py b/examples/v2/teams/GetTeamHierarchyMembers_3330810309.py new file mode 100644 index 0000000000..5381971bf3 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_3330810309.py @@ -0,0 +1,23 @@ +""" +Get team hierarchy members includes inherited users with null root membership attributes +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + include="user,team", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_3355644561.py b/examples/v2/teams/GetTeamHierarchyMembers_3355644561.py new file mode 100644 index 0000000000..5a4030b2d0 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_3355644561.py @@ -0,0 +1,24 @@ +""" +Get team hierarchy members filters direct members +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_is_direct_only=True, + filter_include_service_accounts=False, + filter_keyword="Example-Team", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_3685423949.py b/examples/v2/teams/GetTeamHierarchyMembers_3685423949.py new file mode 100644 index 0000000000..8e163bf113 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_3685423949.py @@ -0,0 +1,23 @@ +""" +Get team hierarchy members sorts inherited members before direct members +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + sort="is_direct,-name", + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_4101380979.py b/examples/v2/teams/GetTeamHierarchyMembers_4101380979.py new file mode 100644 index 0000000000..293f2b092c --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_4101380979.py @@ -0,0 +1,23 @@ +""" +Get team hierarchy members selects number pagination from page size alone +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + response = api_instance.get_team_hierarchy_members( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + page_size=1, + ) + + print(response) diff --git a/examples/v2/teams/GetTeamHierarchyMembers_4182775736.py b/examples/v2/teams/GetTeamHierarchyMembers_4182775736.py new file mode 100644 index 0000000000..7ef5b04202 --- /dev/null +++ b/examples/v2/teams/GetTeamHierarchyMembers_4182775736.py @@ -0,0 +1,23 @@ +""" +Get team hierarchy members returns "OK" response with pagination +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.teams_api import TeamsApi + +# there is a valid "dd_team" in the system +DD_TEAM_DATA_ID = environ["DD_TEAM_DATA_ID"] + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +configuration.unstable_operations["get_team_hierarchy_members"] = True +with ApiClient(configuration) as api_client: + api_instance = TeamsApi(api_client) + items = api_instance.get_team_hierarchy_members_with_pagination( + team_id=DD_TEAM_DATA_ID, + filter_keyword="Example-Team", + page_size=1, + ) + for item in items: + print(item) diff --git a/src/datadog_api_client/configuration.py b/src/datadog_api_client/configuration.py index 22ee7a2b53..6b4307a80d 100644 --- a/src/datadog_api_client/configuration.py +++ b/src/datadog_api_client/configuration.py @@ -873,6 +873,7 @@ def __init__( "v2.update_ai_custom_ruleset": False, "v2.update_custom_ruleset": False, "v2.add_member_team": False, + "v2.get_team_hierarchy_members": False, "v2.list_member_teams": False, "v2.remove_member_team": False, "v2.create_timeseries_anomaly_investigation": False, diff --git a/src/datadog_api_client/v2/api/teams_api.py b/src/datadog_api_client/v2/api/teams_api.py index 94e3fc16e3..18ecd52963 100644 --- a/src/datadog_api_client/v2/api/teams_api.py +++ b/src/datadog_api_client/v2/api/teams_api.py @@ -38,6 +38,8 @@ from datadog_api_client.v2.model.team_links_response import TeamLinksResponse from datadog_api_client.v2.model.team_link_response import TeamLinkResponse from datadog_api_client.v2.model.team_link_create_request import TeamLinkCreateRequest +from datadog_api_client.v2.model.team_hierarchy_members_response import TeamHierarchyMembersResponse +from datadog_api_client.v2.model.team_hierarchy_member import TeamHierarchyMember from datadog_api_client.v2.model.user_teams_response import UserTeamsResponse from datadog_api_client.v2.model.get_team_memberships_sort import GetTeamMembershipsSort from datadog_api_client.v2.model.user_team import UserTeam @@ -402,6 +404,64 @@ def __init__(self, api_client=None): api_client=api_client, ) + self._get_team_hierarchy_members_endpoint = _Endpoint( + settings={ + "response_type": (TeamHierarchyMembersResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/team/{team_id}/members", + "operation_id": "get_team_hierarchy_members", + "http_method": "GET", + "version": "v2", + }, + params_map={ + "team_id": { + "required": True, + "openapi_types": (str,), + "attribute": "team_id", + "location": "path", + }, + "filter_is_direct_only": { + "openapi_types": (bool,), + "attribute": "filter[is_direct_only]", + "location": "query", + }, + "filter_include_service_accounts": { + "openapi_types": (bool,), + "attribute": "filter[include_service_accounts]", + "location": "query", + }, + "filter_keyword": { + "openapi_types": (str,), + "attribute": "filter[keyword]", + "location": "query", + }, + "include": { + "openapi_types": (str,), + "attribute": "include", + "location": "query", + }, + "sort": { + "openapi_types": (str,), + "attribute": "sort", + "location": "query", + }, + "page_number": { + "openapi_types": (int,), + "attribute": "page[number]", + "location": "query", + }, + "page_size": { + "openapi_types": (int,), + "attribute": "page[size]", + "location": "query", + }, + }, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + self._get_team_link_endpoint = _Endpoint( settings={ "response_type": (TeamLinkResponse,), @@ -1295,6 +1355,145 @@ def get_team_hierarchy_link( return self._get_team_hierarchy_link_endpoint.call_with_http_info(**kwargs) + def get_team_hierarchy_members( + self, + team_id: str, + *, + filter_is_direct_only: Union[bool, UnsetType] = unset, + filter_include_service_accounts: Union[bool, UnsetType] = unset, + filter_keyword: Union[str, UnsetType] = unset, + include: Union[str, UnsetType] = unset, + sort: Union[str, UnsetType] = unset, + page_number: Union[int, UnsetType] = unset, + page_size: Union[int, UnsetType] = unset, + ) -> TeamHierarchyMembersResponse: + """Get team hierarchy members. + + List the direct and inherited members of a team, deduplicated by user. + Members of descendant teams are included unless ``filter[is_direct_only]`` is true. + Datadog support users are always excluded. + + Use ``page[number]`` and ``page[size]`` to paginate through the results. + Invalid query parameters return a JSON:API error with status 400. + Invalid or unknown team UUIDs return status 404. + + :param team_id: UUID of the requested root team. + :type team_id: str + :param filter_is_direct_only: Return only direct members. By default, members inherited from descendant teams are also returned. + :type filter_is_direct_only: bool, optional + :param filter_include_service_accounts: Include service accounts. Datadog support users are always excluded. + :type filter_include_service_accounts: bool, optional + :param filter_keyword: Filter by a case-insensitive substring of the user name, handle, or email. + :type filter_keyword: str, optional + :param include: Comma-separated resources to include: ``user`` and ``team``. The included team is the requested team. + :type include: str, optional + :param sort: Comma-separated sort fields: ``name`` , ``handle`` , ``is_direct`` , and ``provisioned_by``. Fields are applied in order, each optionally prefixed with ``-`` for descending order. By default, team admins come first, followed by other direct members, then inherited members, sorted by name within each group. + :type sort: str, optional + :param page_number: Zero-based page number. Negative values become 0. Defaults to 0. + :type page_number: int, optional + :param page_size: Members per page, from 1 to 100. Values outside this range use the default of 100. + :type page_size: int, optional + :rtype: TeamHierarchyMembersResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["team_id"] = team_id + + if filter_is_direct_only is not unset: + kwargs["filter_is_direct_only"] = filter_is_direct_only + + if filter_include_service_accounts is not unset: + kwargs["filter_include_service_accounts"] = filter_include_service_accounts + + if filter_keyword is not unset: + kwargs["filter_keyword"] = filter_keyword + + if include is not unset: + kwargs["include"] = include + + if sort is not unset: + kwargs["sort"] = sort + + if page_number is not unset: + kwargs["page_number"] = page_number + + if page_size is not unset: + kwargs["page_size"] = page_size + + return self._get_team_hierarchy_members_endpoint.call_with_http_info(**kwargs) + + def get_team_hierarchy_members_with_pagination( + self, + team_id: str, + *, + filter_is_direct_only: Union[bool, UnsetType] = unset, + filter_include_service_accounts: Union[bool, UnsetType] = unset, + filter_keyword: Union[str, UnsetType] = unset, + include: Union[str, UnsetType] = unset, + sort: Union[str, UnsetType] = unset, + page_number: Union[int, UnsetType] = unset, + page_size: Union[int, UnsetType] = unset, + ) -> collections.abc.Iterable[TeamHierarchyMember]: + """Get team hierarchy members. + + Provide a paginated version of :meth:`get_team_hierarchy_members`, returning all items. + + :param team_id: UUID of the requested root team. + :type team_id: str + :param filter_is_direct_only: Return only direct members. By default, members inherited from descendant teams are also returned. + :type filter_is_direct_only: bool, optional + :param filter_include_service_accounts: Include service accounts. Datadog support users are always excluded. + :type filter_include_service_accounts: bool, optional + :param filter_keyword: Filter by a case-insensitive substring of the user name, handle, or email. + :type filter_keyword: str, optional + :param include: Comma-separated resources to include: ``user`` and ``team``. The included team is the requested team. + :type include: str, optional + :param sort: Comma-separated sort fields: ``name`` , ``handle`` , ``is_direct`` , and ``provisioned_by``. Fields are applied in order, each optionally prefixed with ``-`` for descending order. By default, team admins come first, followed by other direct members, then inherited members, sorted by name within each group. + :type sort: str, optional + :param page_number: Zero-based page number. Negative values become 0. Defaults to 0. + :type page_number: int, optional + :param page_size: Members per page, from 1 to 100. Values outside this range use the default of 100. + :type page_size: int, optional + + :return: A generator of paginated results. + :rtype: collections.abc.Iterable[TeamHierarchyMember] + """ + kwargs: Dict[str, Any] = {} + kwargs["team_id"] = team_id + + if filter_is_direct_only is not unset: + kwargs["filter_is_direct_only"] = filter_is_direct_only + + if filter_include_service_accounts is not unset: + kwargs["filter_include_service_accounts"] = filter_include_service_accounts + + if filter_keyword is not unset: + kwargs["filter_keyword"] = filter_keyword + + if include is not unset: + kwargs["include"] = include + + if sort is not unset: + kwargs["sort"] = sort + + if page_number is not unset: + kwargs["page_number"] = page_number + + if page_size is not unset: + kwargs["page_size"] = page_size + + local_page_size = get_attribute_from_path(kwargs, "page_size", 100) + endpoint = self._get_team_hierarchy_members_endpoint + set_attribute_from_path(kwargs, "page_size", local_page_size, endpoint.params_map) + pagination = { + "limit_value": local_page_size, + "results_path": "data", + "page_param": "page_number", + "page_start": 0, + "endpoint": endpoint, + "kwargs": kwargs, + } + return endpoint.call_with_http_info_paginated(pagination) + def get_team_link( self, team_id: str, diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member.py b/src/datadog_api_client/v2/model/team_hierarchy_member.py new file mode 100644 index 0000000000..36302280e3 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member.py @@ -0,0 +1,69 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_attributes import TeamHierarchyMemberAttributes + from datadog_api_client.v2.model.team_hierarchy_member_relationships import TeamHierarchyMemberRelationships + from datadog_api_client.v2.model.team_hierarchy_member_type import TeamHierarchyMemberType + + +class TeamHierarchyMember(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_attributes import TeamHierarchyMemberAttributes + from datadog_api_client.v2.model.team_hierarchy_member_relationships import TeamHierarchyMemberRelationships + from datadog_api_client.v2.model.team_hierarchy_member_type import TeamHierarchyMemberType + + return { + "attributes": (TeamHierarchyMemberAttributes,), + "id": (str,), + "relationships": (TeamHierarchyMemberRelationships,), + "type": (TeamHierarchyMemberType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "relationships": "relationships", + "type": "type", + } + + def __init__( + self_, + attributes: TeamHierarchyMemberAttributes, + id: str, + relationships: TeamHierarchyMemberRelationships, + type: TeamHierarchyMemberType, + **kwargs, + ): + """ + A user relationship to the requested team. + + :param attributes: Membership attributes relative to the requested team. + :type attributes: TeamHierarchyMemberAttributes + + :param id: Relationship identifier containing the team UUID and user UUID. + :type id: str + + :param relationships: User and requested team linkage. + :type relationships: TeamHierarchyMemberRelationships + + :param type: Team hierarchy membership resource type. + :type type: TeamHierarchyMemberType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.relationships = relationships + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_attributes.py b/src/datadog_api_client/v2/model/team_hierarchy_member_attributes.py new file mode 100644 index 0000000000..8091a1064c --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_attributes.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, +) + + +class TeamHierarchyMemberAttributes(ModelNormal): + validations = { + "direct_role": {}, + } + + @cached_property + def openapi_types(_): + return { + "direct_role": (str, none_type), + "is_direct": (bool,), + "provisioned_by": (str, none_type), + "provisioned_by_id": (str, none_type), + } + + attribute_map = { + "direct_role": "direct_role", + "is_direct": "is_direct", + "provisioned_by": "provisioned_by", + "provisioned_by_id": "provisioned_by_id", + } + + def __init__( + self_, + direct_role: Union[str, none_type], + is_direct: bool, + provisioned_by: Union[str, none_type], + provisioned_by_id: Union[str, none_type], + **kwargs, + ): + """ + Membership attributes relative to the requested team. + + :param direct_role: Role on the requested team: admin or member. Null for inherited members. + :type direct_role: str, none_type + + :param is_direct: Whether the user belongs directly to the requested team. + :type is_direct: bool + + :param provisioned_by: Membership provisioner. Null for inherited members. + :type provisioned_by: str, none_type + + :param provisioned_by_id: Identifier supplied by the membership provisioner. Null when unavailable or for inherited members. + :type provisioned_by_id: str, none_type + """ + super().__init__(kwargs) + + self_.direct_role = direct_role + self_.is_direct = is_direct + self_.provisioned_by = provisioned_by + self_.provisioned_by_id = provisioned_by_id diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_included.py b/src/datadog_api_client/v2/model/team_hierarchy_member_included.py new file mode 100644 index 0000000000..b2599f3371 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_included.py @@ -0,0 +1,46 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class TeamHierarchyMemberIncluded(ModelComposed): + def __init__(self, **kwargs): + """ + An included user or the requested team, distinguished by resource type. + + :param attributes: Attributes of user object returned by the API. + :type attributes: UserAttributes + + :param id: UUID of the user. + :type id: UUID + + :param type: Users resource type. + :type type: UsersType + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.team_hierarchy_member_user import TeamHierarchyMemberUser + from datadog_api_client.v2.model.team_hierarchy_member_team import TeamHierarchyMemberTeam + + return { + "oneOf": [ + TeamHierarchyMemberUser, + TeamHierarchyMemberTeam, + ], + } diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_relationships.py b/src/datadog_api_client/v2/model/team_hierarchy_member_relationships.py new file mode 100644 index 0000000000..fa20536c9f --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_relationships.py @@ -0,0 +1,52 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_team_relationship import TeamHierarchyMemberTeamRelationship + from datadog_api_client.v2.model.team_hierarchy_member_user_relationship import TeamHierarchyMemberUserRelationship + + +class TeamHierarchyMemberRelationships(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_team_relationship import ( + TeamHierarchyMemberTeamRelationship, + ) + from datadog_api_client.v2.model.team_hierarchy_member_user_relationship import ( + TeamHierarchyMemberUserRelationship, + ) + + return { + "team": (TeamHierarchyMemberTeamRelationship,), + "user": (TeamHierarchyMemberUserRelationship,), + } + + attribute_map = { + "team": "team", + "user": "user", + } + + def __init__(self_, team: TeamHierarchyMemberTeamRelationship, user: TeamHierarchyMemberUserRelationship, **kwargs): + """ + User and requested team linkage. + + :param team: Linkage to the requested team. + :type team: TeamHierarchyMemberTeamRelationship + + :param user: Linkage to the user. + :type user: TeamHierarchyMemberUserRelationship + """ + super().__init__(kwargs) + + self_.team = team + self_.user = user diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_team.py b/src/datadog_api_client/v2/model/team_hierarchy_member_team.py new file mode 100644 index 0000000000..808606b540 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_team.py @@ -0,0 +1,64 @@ +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +# This product includes software developed at Datadog (https://www.datadoghq.com/). +# Copyright 2019-Present Datadog, Inc. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_team_attributes import TeamHierarchyMemberTeamAttributes + from datadog_api_client.v2.model.team_hierarchy_member_team_type import TeamHierarchyMemberTeamType + + +class TeamHierarchyMemberTeam(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_team_attributes import TeamHierarchyMemberTeamAttributes + from datadog_api_client.v2.model.team_hierarchy_member_team_type import TeamHierarchyMemberTeamType + + return { + "attributes": (TeamHierarchyMemberTeamAttributes,), + "id": (UUID,), + "type": (TeamHierarchyMemberTeamType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__( + self_, + id: UUID, + type: TeamHierarchyMemberTeamType, + attributes: Union[TeamHierarchyMemberTeamAttributes, UnsetType] = unset, + **kwargs, + ): + """ + The requested team, included at most once. Descendant teams are not included. + + :param attributes: Available attributes of the requested team. + :type attributes: TeamHierarchyMemberTeamAttributes, optional + + :param id: UUID of the requested team. + :type id: UUID + + :param type: Requested team resource type. + :type type: TeamHierarchyMemberTeamType + """ + if attributes is not unset: + kwargs["attributes"] = attributes + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_team_attributes.py b/src/datadog_api_client/v2/model/team_hierarchy_member_team_attributes.py new file mode 100644 index 0000000000..3356fbe4ae --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_team_attributes.py @@ -0,0 +1,43 @@ +# 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. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class TeamHierarchyMemberTeamAttributes(ModelNormal): + @cached_property + def openapi_types(_): + return { + "handle": (str,), + "name": (str,), + } + + attribute_map = { + "handle": "handle", + "name": "name", + } + + def __init__(self_, handle: Union[str, UnsetType] = unset, name: Union[str, UnsetType] = unset, **kwargs): + """ + Available attributes of the requested team. + + :param handle: Handle of the team. + :type handle: str, optional + + :param name: Name of the team. + :type name: str, optional + """ + if handle is not unset: + kwargs["handle"] = handle + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_team_data.py b/src/datadog_api_client/v2/model/team_hierarchy_member_team_data.py new file mode 100644 index 0000000000..b65e1367c0 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_team_data.py @@ -0,0 +1,47 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_team_type import TeamHierarchyMemberTeamType + + +class TeamHierarchyMemberTeamData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_team_type import TeamHierarchyMemberTeamType + + return { + "id": (UUID,), + "type": (TeamHierarchyMemberTeamType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: UUID, type: TeamHierarchyMemberTeamType, **kwargs): + """ + Team resource identifier. + + :param id: UUID of the team. + :type id: UUID + + :param type: Requested team resource type. + :type type: TeamHierarchyMemberTeamType + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_team_relationship.py b/src/datadog_api_client/v2/model/team_hierarchy_member_team_relationship.py new file mode 100644 index 0000000000..aa4eb96efb --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_team_relationship.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_team_data import TeamHierarchyMemberTeamData + + +class TeamHierarchyMemberTeamRelationship(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_team_data import TeamHierarchyMemberTeamData + + return { + "data": (TeamHierarchyMemberTeamData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: TeamHierarchyMemberTeamData, **kwargs): + """ + Linkage to the requested team. + + :param data: Team resource identifier. + :type data: TeamHierarchyMemberTeamData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_team_type.py b/src/datadog_api_client/v2/model/team_hierarchy_member_team_type.py new file mode 100644 index 0000000000..4b3ac67eb2 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_team_type.py @@ -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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamHierarchyMemberTeamType(ModelSimple): + """ + Requested team resource type. + + :param value: If omitted defaults to "teams". Must be one of ["teams"]. + :type value: str + """ + + allowed_values = { + "teams", + } + TEAMS: ClassVar["TeamHierarchyMemberTeamType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamHierarchyMemberTeamType.TEAMS = TeamHierarchyMemberTeamType("teams") diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_type.py b/src/datadog_api_client/v2/model/team_hierarchy_member_type.py new file mode 100644 index 0000000000..70a7f44a3d --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_type.py @@ -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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamHierarchyMemberType(ModelSimple): + """ + Team hierarchy membership resource type. + + :param value: If omitted defaults to "user_team_relationship". Must be one of ["user_team_relationship"]. + :type value: str + """ + + allowed_values = { + "user_team_relationship", + } + USER_TEAM_RELATIONSHIP: ClassVar["TeamHierarchyMemberType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamHierarchyMemberType.USER_TEAM_RELATIONSHIP = TeamHierarchyMemberType("user_team_relationship") diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_user.py b/src/datadog_api_client/v2/model/team_hierarchy_member_user.py new file mode 100644 index 0000000000..12fda1af51 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_user.py @@ -0,0 +1,55 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.user_attributes import UserAttributes + from datadog_api_client.v2.model.users_type import UsersType + + +class TeamHierarchyMemberUser(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.user_attributes import UserAttributes + from datadog_api_client.v2.model.users_type import UsersType + + return { + "attributes": (UserAttributes,), + "id": (UUID,), + "type": (UsersType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: UserAttributes, id: UUID, type: UsersType, **kwargs): + """ + A user included in the hierarchy members response. + + :param attributes: Attributes of user object returned by the API. + :type attributes: UserAttributes + + :param id: UUID of the user. + :type id: UUID + + :param type: Users resource type. + :type type: UsersType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_user_data.py b/src/datadog_api_client/v2/model/team_hierarchy_member_user_data.py new file mode 100644 index 0000000000..6426ae8dd9 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_user_data.py @@ -0,0 +1,47 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + UUID, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.users_type import UsersType + + +class TeamHierarchyMemberUserData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.users_type import UsersType + + return { + "id": (UUID,), + "type": (UsersType,), + } + + attribute_map = { + "id": "id", + "type": "type", + } + + def __init__(self_, id: UUID, type: UsersType, **kwargs): + """ + User resource identifier. + + :param id: UUID of the user. + :type id: UUID + + :param type: Users resource type. + :type type: UsersType + """ + super().__init__(kwargs) + + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_member_user_relationship.py b/src/datadog_api_client/v2/model/team_hierarchy_member_user_relationship.py new file mode 100644 index 0000000000..35ff4a6b96 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_member_user_relationship.py @@ -0,0 +1,40 @@ +# 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. +from __future__ import annotations + +from typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member_user_data import TeamHierarchyMemberUserData + + +class TeamHierarchyMemberUserRelationship(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member_user_data import TeamHierarchyMemberUserData + + return { + "data": (TeamHierarchyMemberUserData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: TeamHierarchyMemberUserData, **kwargs): + """ + Linkage to the user. + + :param data: User resource identifier. + :type data: TeamHierarchyMemberUserData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_number_page.py b/src/datadog_api_client/v2/model/team_hierarchy_members_number_page.py new file mode 100644 index 0000000000..ae77c2414f --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_number_page.py @@ -0,0 +1,96 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_members_number_page_type import TeamHierarchyMembersNumberPageType + + +class TeamHierarchyMembersNumberPage(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_members_number_page_type import ( + TeamHierarchyMembersNumberPageType, + ) + + return { + "first_number": (int,), + "last_number": (int, none_type), + "next_number": (int, none_type), + "number": (int,), + "prev_number": (int, none_type), + "size": (int,), + "total": (int,), + "type": (TeamHierarchyMembersNumberPageType,), + } + + attribute_map = { + "first_number": "first_number", + "last_number": "last_number", + "next_number": "next_number", + "number": "number", + "prev_number": "prev_number", + "size": "size", + "total": "total", + "type": "type", + } + + def __init__( + self_, + first_number: int, + last_number: Union[int, none_type], + next_number: Union[int, none_type], + number: int, + prev_number: Union[int, none_type], + size: int, + total: int, + type: TeamHierarchyMembersNumberPageType, + **kwargs, + ): + """ + Pagination metadata using number and size. + + :param first_number: First page number. + :type first_number: int + + :param last_number: Last page number. Null when unavailable. + :type last_number: int, none_type + + :param next_number: Next page number. Null when unavailable. + :type next_number: int, none_type + + :param number: Current zero-based page number. + :type number: int + + :param prev_number: Previous page number. Null when unavailable. + :type prev_number: int, none_type + + :param size: Maximum number of members per page. + :type size: int + + :param total: Total number of members matching the filters. + :type total: int + + :param type: Pagination mode. + :type type: TeamHierarchyMembersNumberPageType + """ + super().__init__(kwargs) + + self_.first_number = first_number + self_.last_number = last_number + self_.next_number = next_number + self_.number = number + self_.prev_number = prev_number + self_.size = size + self_.total = total + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_number_page_type.py b/src/datadog_api_client/v2/model/team_hierarchy_members_number_page_type.py new file mode 100644 index 0000000000..6f131b58ed --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_number_page_type.py @@ -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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamHierarchyMembersNumberPageType(ModelSimple): + """ + Pagination mode. + + :param value: If omitted defaults to "number_size". Must be one of ["number_size"]. + :type value: str + """ + + allowed_values = { + "number_size", + } + NUMBER_SIZE: ClassVar["TeamHierarchyMembersNumberPageType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamHierarchyMembersNumberPageType.NUMBER_SIZE = TeamHierarchyMembersNumberPageType("number_size") diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page.py b/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page.py new file mode 100644 index 0000000000..ff0d25e68f --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page.py @@ -0,0 +1,96 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + none_type, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_members_offset_page_type import TeamHierarchyMembersOffsetPageType + + +class TeamHierarchyMembersOffsetPage(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_members_offset_page_type import ( + TeamHierarchyMembersOffsetPageType, + ) + + return { + "first_offset": (int,), + "last_offset": (int, none_type), + "limit": (int,), + "next_offset": (int, none_type), + "offset": (int,), + "prev_offset": (int, none_type), + "total": (int,), + "type": (TeamHierarchyMembersOffsetPageType,), + } + + attribute_map = { + "first_offset": "first_offset", + "last_offset": "last_offset", + "limit": "limit", + "next_offset": "next_offset", + "offset": "offset", + "prev_offset": "prev_offset", + "total": "total", + "type": "type", + } + + def __init__( + self_, + first_offset: int, + last_offset: Union[int, none_type], + limit: int, + next_offset: Union[int, none_type], + offset: int, + prev_offset: Union[int, none_type], + total: int, + type: TeamHierarchyMembersOffsetPageType, + **kwargs, + ): + """ + Pagination metadata using offset and limit. + + :param first_offset: First offset. + :type first_offset: int + + :param last_offset: Last offset. Null when unavailable. + :type last_offset: int, none_type + + :param limit: Maximum number of members per page. + :type limit: int + + :param next_offset: Next offset. Null when unavailable. + :type next_offset: int, none_type + + :param offset: Current offset. + :type offset: int + + :param prev_offset: Previous offset. Null when unavailable. + :type prev_offset: int, none_type + + :param total: Total number of members matching the filters. + :type total: int + + :param type: Pagination mode. + :type type: TeamHierarchyMembersOffsetPageType + """ + super().__init__(kwargs) + + self_.first_offset = first_offset + self_.last_offset = last_offset + self_.limit = limit + self_.next_offset = next_offset + self_.offset = offset + self_.prev_offset = prev_offset + self_.total = total + self_.type = type diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page_type.py b/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page_type.py new file mode 100644 index 0000000000..b75c7cadf4 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_offset_page_type.py @@ -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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class TeamHierarchyMembersOffsetPageType(ModelSimple): + """ + Pagination mode. + + :param value: If omitted defaults to "offset_limit". Must be one of ["offset_limit"]. + :type value: str + """ + + allowed_values = { + "offset_limit", + } + OFFSET_LIMIT: ClassVar["TeamHierarchyMembersOffsetPageType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +TeamHierarchyMembersOffsetPageType.OFFSET_LIMIT = TeamHierarchyMembersOffsetPageType("offset_limit") diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_page.py b/src/datadog_api_client/v2/model/team_hierarchy_members_page.py new file mode 100644 index 0000000000..8d1fc01b90 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_page.py @@ -0,0 +1,79 @@ +# 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. +from __future__ import annotations + + +from datadog_api_client.model_utils import ( + ModelComposed, + cached_property, +) + + +class TeamHierarchyMembersPage(ModelComposed): + def __init__(self, **kwargs): + """ + Pagination metadata for the selected pagination mode. + + :param first_offset: First offset. + :type first_offset: int + + :param last_offset: Last offset. Null when unavailable. + :type last_offset: int, none_type + + :param limit: Maximum number of members per page. + :type limit: int + + :param next_offset: Next offset. Null when unavailable. + :type next_offset: int, none_type + + :param offset: Current offset. + :type offset: int + + :param prev_offset: Previous offset. Null when unavailable. + :type prev_offset: int, none_type + + :param total: Total number of members matching the filters. + :type total: int + + :param type: Pagination mode. + :type type: TeamHierarchyMembersOffsetPageType + + :param first_number: First page number. + :type first_number: int + + :param last_number: Last page number. Null when unavailable. + :type last_number: int, none_type + + :param next_number: Next page number. Null when unavailable. + :type next_number: int, none_type + + :param number: Current zero-based page number. + :type number: int + + :param prev_number: Previous page number. Null when unavailable. + :type prev_number: int, none_type + + :param size: Maximum number of members per page. + :type size: int + """ + super().__init__(kwargs) + + @cached_property + def _composed_schemas(_): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error because the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + from datadog_api_client.v2.model.team_hierarchy_members_offset_page import TeamHierarchyMembersOffsetPage + from datadog_api_client.v2.model.team_hierarchy_members_number_page import TeamHierarchyMembersNumberPage + + return { + "oneOf": [ + TeamHierarchyMembersOffsetPage, + TeamHierarchyMembersNumberPage, + ], + } diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_response.py b/src/datadog_api_client/v2/model/team_hierarchy_members_response.py new file mode 100644 index 0000000000..9867ca09ab --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_response.py @@ -0,0 +1,78 @@ +# 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. +from __future__ import annotations + +from typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_member import TeamHierarchyMember + from datadog_api_client.v2.model.team_hierarchy_member_included import TeamHierarchyMemberIncluded + from datadog_api_client.v2.model.team_hierarchy_members_response_links import TeamHierarchyMembersResponseLinks + from datadog_api_client.v2.model.team_hierarchy_members_response_meta import TeamHierarchyMembersResponseMeta + from datadog_api_client.v2.model.team_hierarchy_member_user import TeamHierarchyMemberUser + from datadog_api_client.v2.model.team_hierarchy_member_team import TeamHierarchyMemberTeam + + +class TeamHierarchyMembersResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_member import TeamHierarchyMember + from datadog_api_client.v2.model.team_hierarchy_member_included import TeamHierarchyMemberIncluded + from datadog_api_client.v2.model.team_hierarchy_members_response_links import TeamHierarchyMembersResponseLinks + from datadog_api_client.v2.model.team_hierarchy_members_response_meta import TeamHierarchyMembersResponseMeta + + return { + "data": ([TeamHierarchyMember],), + "included": ([TeamHierarchyMemberIncluded],), + "links": (TeamHierarchyMembersResponseLinks,), + "meta": (TeamHierarchyMembersResponseMeta,), + } + + attribute_map = { + "data": "data", + "included": "included", + "links": "links", + "meta": "meta", + } + + def __init__( + self_, + data: List[TeamHierarchyMember], + links: TeamHierarchyMembersResponseLinks, + meta: TeamHierarchyMembersResponseMeta, + included: Union[ + List[Union[TeamHierarchyMemberIncluded, TeamHierarchyMemberUser, TeamHierarchyMemberTeam]], UnsetType + ] = unset, + **kwargs, + ): + """ + Direct and inherited members of the requested team. + + :param data: One relationship per user. + :type data: [TeamHierarchyMember] + + :param included: Requested users and the team. May be absent when the result is empty, even if requested. + :type included: [TeamHierarchyMemberIncluded], optional + + :param links: Page navigation links. Unavailable links are omitted. + :type links: TeamHierarchyMembersResponseLinks + + :param meta: Pagination metadata for the filtered members. + :type meta: TeamHierarchyMembersResponseMeta + """ + if included is not unset: + kwargs["included"] = included + super().__init__(kwargs) + + self_.data = data + self_.links = links + self_.meta = meta diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_response_links.py b/src/datadog_api_client/v2/model/team_hierarchy_members_response_links.py new file mode 100644 index 0000000000..f531a216f5 --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_response_links.py @@ -0,0 +1,72 @@ +# 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. +from __future__ import annotations + +from typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class TeamHierarchyMembersResponseLinks(ModelNormal): + @cached_property + def openapi_types(_): + return { + "first": (str,), + "last": (str,), + "next": (str,), + "prev": (str,), + "self": (str,), + } + + attribute_map = { + "first": "first", + "last": "last", + "next": "next", + "prev": "prev", + "self": "self", + } + + def __init__( + self_, + first: Union[str, UnsetType] = unset, + last: Union[str, UnsetType] = unset, + next: Union[str, UnsetType] = unset, + prev: Union[str, UnsetType] = unset, + self: Union[str, UnsetType] = unset, + **kwargs, + ): + """ + Page navigation links. Unavailable links are omitted. + + :param first: First page URL. + :type first: str, optional + + :param last: Last page URL. + :type last: str, optional + + :param next: Next page URL. + :type next: str, optional + + :param prev: Previous page URL. + :type prev: str, optional + + :param self: Current page URL. + :type self: str, optional + """ + if first is not unset: + kwargs["first"] = first + if last is not unset: + kwargs["last"] = last + if next is not unset: + kwargs["next"] = next + if prev is not unset: + kwargs["prev"] = prev + if self is not unset: + kwargs["self"] = self + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/team_hierarchy_members_response_meta.py b/src/datadog_api_client/v2/model/team_hierarchy_members_response_meta.py new file mode 100644 index 0000000000..4ebb7f1d9d --- /dev/null +++ b/src/datadog_api_client/v2/model/team_hierarchy_members_response_meta.py @@ -0,0 +1,46 @@ +# 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. +from __future__ import annotations + +from typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.team_hierarchy_members_page import TeamHierarchyMembersPage + from datadog_api_client.v2.model.team_hierarchy_members_offset_page import TeamHierarchyMembersOffsetPage + from datadog_api_client.v2.model.team_hierarchy_members_number_page import TeamHierarchyMembersNumberPage + + +class TeamHierarchyMembersResponseMeta(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.team_hierarchy_members_page import TeamHierarchyMembersPage + + return { + "page": (TeamHierarchyMembersPage,), + } + + attribute_map = { + "page": "page", + } + + def __init__( + self_, + page: Union[TeamHierarchyMembersPage, TeamHierarchyMembersOffsetPage, TeamHierarchyMembersNumberPage], + **kwargs, + ): + """ + Pagination metadata for the filtered members. + + :param page: Pagination metadata for the selected pagination mode. + :type page: TeamHierarchyMembersPage + """ + super().__init__(kwargs) + + self_.page = page diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index fa746459af..37a2263058 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -11653,6 +11653,27 @@ from datadog_api_client.v2.model.team_hierarchy_link_team_relationship import TeamHierarchyLinkTeamRelationship from datadog_api_client.v2.model.team_hierarchy_link_type import TeamHierarchyLinkType from datadog_api_client.v2.model.team_hierarchy_links_response import TeamHierarchyLinksResponse +from datadog_api_client.v2.model.team_hierarchy_member import TeamHierarchyMember +from datadog_api_client.v2.model.team_hierarchy_member_attributes import TeamHierarchyMemberAttributes +from datadog_api_client.v2.model.team_hierarchy_member_included import TeamHierarchyMemberIncluded +from datadog_api_client.v2.model.team_hierarchy_member_relationships import TeamHierarchyMemberRelationships +from datadog_api_client.v2.model.team_hierarchy_member_team import TeamHierarchyMemberTeam +from datadog_api_client.v2.model.team_hierarchy_member_team_attributes import TeamHierarchyMemberTeamAttributes +from datadog_api_client.v2.model.team_hierarchy_member_team_data import TeamHierarchyMemberTeamData +from datadog_api_client.v2.model.team_hierarchy_member_team_relationship import TeamHierarchyMemberTeamRelationship +from datadog_api_client.v2.model.team_hierarchy_member_team_type import TeamHierarchyMemberTeamType +from datadog_api_client.v2.model.team_hierarchy_member_type import TeamHierarchyMemberType +from datadog_api_client.v2.model.team_hierarchy_member_user import TeamHierarchyMemberUser +from datadog_api_client.v2.model.team_hierarchy_member_user_data import TeamHierarchyMemberUserData +from datadog_api_client.v2.model.team_hierarchy_member_user_relationship import TeamHierarchyMemberUserRelationship +from datadog_api_client.v2.model.team_hierarchy_members_number_page import TeamHierarchyMembersNumberPage +from datadog_api_client.v2.model.team_hierarchy_members_number_page_type import TeamHierarchyMembersNumberPageType +from datadog_api_client.v2.model.team_hierarchy_members_offset_page import TeamHierarchyMembersOffsetPage +from datadog_api_client.v2.model.team_hierarchy_members_offset_page_type import TeamHierarchyMembersOffsetPageType +from datadog_api_client.v2.model.team_hierarchy_members_page import TeamHierarchyMembersPage +from datadog_api_client.v2.model.team_hierarchy_members_response import TeamHierarchyMembersResponse +from datadog_api_client.v2.model.team_hierarchy_members_response_links import TeamHierarchyMembersResponseLinks +from datadog_api_client.v2.model.team_hierarchy_members_response_meta import TeamHierarchyMembersResponseMeta from datadog_api_client.v2.model.team_included import TeamIncluded from datadog_api_client.v2.model.team_link import TeamLink from datadog_api_client.v2.model.team_link_attributes import TeamLinkAttributes @@ -20450,6 +20471,27 @@ "TeamHierarchyLinkTeamRelationship", "TeamHierarchyLinkType", "TeamHierarchyLinksResponse", + "TeamHierarchyMember", + "TeamHierarchyMemberAttributes", + "TeamHierarchyMemberIncluded", + "TeamHierarchyMemberRelationships", + "TeamHierarchyMemberTeam", + "TeamHierarchyMemberTeamAttributes", + "TeamHierarchyMemberTeamData", + "TeamHierarchyMemberTeamRelationship", + "TeamHierarchyMemberTeamType", + "TeamHierarchyMemberType", + "TeamHierarchyMemberUser", + "TeamHierarchyMemberUserData", + "TeamHierarchyMemberUserRelationship", + "TeamHierarchyMembersNumberPage", + "TeamHierarchyMembersNumberPageType", + "TeamHierarchyMembersOffsetPage", + "TeamHierarchyMembersOffsetPageType", + "TeamHierarchyMembersPage", + "TeamHierarchyMembersResponse", + "TeamHierarchyMembersResponseLinks", + "TeamHierarchyMembersResponseMeta", "TeamIncluded", "TeamLink", "TeamLinkAttributes", diff --git a/tests/v2/features/given.json b/tests/v2/features/given.json index b307445fc2..1a96861049 100644 --- a/tests/v2/features/given.json +++ b/tests/v2/features/given.json @@ -1961,6 +1961,38 @@ "tag": "Teams", "operationId": "CreateTeamLink" }, + { + "parameters": [ + { + "name": "team_id", + "source": "dd_team_2.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"role\": \"admin\"\n },\n \"relationships\": {\n \"user\": {\n \"data\": {\n \"id\": \"{{team_hierarchy_user.data.id}}\",\n \"type\": \"users\"\n }\n }\n },\n \"type\": \"team_memberships\"\n }\n}" + } + ], + "step": "there is a valid \"team_hierarchy_child_membership\" in the system", + "key": "team_hierarchy_child_membership", + "tag": "Teams", + "operationId": "CreateTeamMembership" + }, + { + "parameters": [ + { + "name": "team_id", + "source": "dd_team_2.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"role\": \"admin\"\n },\n \"relationships\": {\n \"user\": {\n \"data\": {\n \"id\": \"{{user.data.id}}\",\n \"type\": \"users\"\n }\n }\n },\n \"type\": \"team_memberships\"\n }\n}" + } + ], + "step": "there is a valid \"team_hierarchy_duplicate_membership\" in the system", + "key": "team_hierarchy_duplicate_membership", + "tag": "Teams", + "operationId": "CreateTeamMembership" + }, { "parameters": [ { @@ -2006,6 +2038,18 @@ "tag": "Users", "operationId": "SendInvitations" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"users\",\n \"attributes\": {\n \"email\": \"hierarchy-{{ unique }}@datadoghq.com\",\n \"name\": \"Hierarchy member\"\n }\n }\n}" + } + ], + "step": "there is a valid \"team_hierarchy_user\" in the system", + "key": "team_hierarchy_user", + "tag": "Users", + "operationId": "CreateUser" + }, { "parameters": [ { diff --git a/tests/v2/features/teams.feature b/tests/v2/features/teams.feature index 4133b1f46e..1a14900099 100644 --- a/tests/v2/features/teams.feature +++ b/tests/v2/features/teams.feature @@ -378,6 +378,271 @@ Feature: Teams When the request with pagination is sent Then the response status is 200 OK + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members deduplicates direct and inherited membership + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And there is a valid "team_hierarchy_duplicate_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "sort" parameter with value "-is_direct,handle" + And request contains "include" parameter with value "team" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 2 + And the response "meta.page.total" is equal to 2 + And the response "data[0].relationships.user.data.id" is equal to "{{ user.data.id }}" + And the response "data[0].attributes.is_direct" is equal to true + And the response "data[0].attributes.direct_role" is equal to "admin" + And the response "data[1].relationships.user.data.id" is equal to "{{ team_hierarchy_user.data.id }}" + And the response "data[1].attributes.is_direct" is equal to false + And the response "included" has length 1 + And the response "included[0].id" is equal to "{{ dd_team.data.id }}" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members filters direct members + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "filter[is_direct_only]" parameter with value true + And request contains "filter[include_service_accounts]" parameter with value false + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].relationships.user.data.id" is equal to "{{ user.data.id }}" + And the response "data[0].attributes.is_direct" is equal to true + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members filters names case insensitively + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "hIeRaRcHy MeMbEr" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].relationships.user.data.id" is equal to "{{ team_hierarchy_user.data.id }}" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members includes inherited users with null root membership attributes + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "include" parameter with value "user,team" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].attributes.is_direct" is equal to false + And the response "data[0].attributes.direct_role" is equal to null + And the response "data[0].attributes.provisioned_by" is equal to null + And the response "data[0].attributes.provisioned_by_id" is equal to null + And the response "data[0].relationships.user.data.id" is equal to "{{ team_hierarchy_user.data.id }}" + And the response "data[0].relationships.team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "included" has length 2 + And the response "included" has item with field "id" with value "{{ dd_team.data.id }}" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members normalizes number pagination + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" request + And there is a valid "dd_team" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "page[number]" parameter with value -1 + And request contains "page[size]" parameter with value 101 + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "meta.page.number" is equal to 0 + And the response "meta.page.size" is equal to 100 + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members paginates by number and size + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "sort" parameter with value "-is_direct" + And request contains "page[number]" parameter with value 1 + And request contains "page[size]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "data[0].attributes.is_direct" is equal to false + And the response "meta.page.type" is equal to "number_size" + And the response "meta.page.number" is equal to 1 + And the response "meta.page.size" is equal to 1 + And the response "meta.page.total" is equal to 2 + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members rejects unsupported includes + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" request + And there is a valid "dd_team" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "include" parameter with value "descendants" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors[0].status" is equal to "400" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members returns "Bad Request" response + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" request + And there is a valid "dd_team" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "sort" parameter with value "invalid" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors[0].status" is equal to "400" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members returns "Not Found" response + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" request + And request contains "team_id" parameter with value "00000000-0000-4000-8000-000000000000" + When the request is sent + Then the response status is 404 Not Found + And the response "errors[0].status" is equal to "404" + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members returns "OK" response + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" request + And there is a valid "dd_team" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ user.data.attributes.email }}" + And request contains "include" parameter with value "user,team" + 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 "UserTeamRelationship:{{ dd_team.data.id }}:{{ user.data.id }}" + And the response "data[0].type" is equal to "user_team_relationship" + And the response "data[0].attributes.is_direct" is equal to true + And the response "data[0].attributes.direct_role" is equal to "admin" + And the response "data[0].relationships.user.data.type" is equal to "users" + And the response "data[0].relationships.team.data.type" is equal to "teams" + And the response "data[0].relationships.team.data.id" is equal to "{{ dd_team.data.id }}" + And the response "included" has length 2 + And the response "included" has item with field "id" with value "{{ user.data.id }}" + And the response "included" has item with field "id" with value "{{ dd_team.data.id }}" + And the response "meta.page.type" is equal to "offset_limit" + And the response "meta.page.limit" is equal to 100 + And the response "meta.page.total" is equal to 1 + + @replay-only @skip @skip-validation @team:ddoghq/aaa-omg @with-pagination + Scenario: Get team hierarchy members returns "OK" response with pagination + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "page[size]" parameter with value 1 + When the request with pagination is sent + Then the response status is 200 OK + And the response has 2 items + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members returns empty results + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "no-matching-member-{{ unique }}" + And request contains "include" parameter with value "user,team" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 0 + And the response "meta.page.total" is equal to 0 + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members selects number pagination from page size alone + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "page[size]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "data" has length 1 + And the response "meta.page.type" is equal to "number_size" + And the response "meta.page.number" is equal to 0 + And the response "meta.page.size" is equal to 1 + + @skip @team:ddoghq/aaa-omg + Scenario: Get team hierarchy members sorts inherited members before direct members + Given operation "GetTeamHierarchyMembers" enabled + And new "GetTeamHierarchyMembers" 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 there is a valid "team_hierarchy_user" in the system + And there is a valid "team_hierarchy_child_membership" in the system + And there is a valid "user" in the system + And there is a valid "team_membership" in the system + And request contains "team_id" parameter from "dd_team.data.id" + And request contains "filter[keyword]" parameter with value "{{ unique }}" + And request contains "sort" parameter with value "is_direct,-name" + When the request is sent + Then the response status is 200 OK + And the response "data" has length 2 + And the response "data[0].relationships.user.data.id" is equal to "{{ team_hierarchy_user.data.id }}" + And the response "data[1].relationships.user.data.id" is equal to "{{ user.data.id }}" + @team:ddoghq/aaa-omg Scenario: Get team memberships returns "API error response." response Given new "GetTeamMemberships" request diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 68ab96be66..9092e01f76 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -10854,6 +10854,12 @@ "type": "idempotent" } }, + "GetTeamHierarchyMembers": { + "tag": "Teams", + "undo": { + "type": "safe" + } + }, "GetTeamMemberships": { "tag": "Teams", "undo": {