|
3 | 3 | # Copyright 2019-Present Datadog, Inc. |
4 | 4 | from __future__ import annotations |
5 | 5 |
|
| 6 | +import collections |
6 | 7 | from typing import Any, Dict, List, Union |
7 | 8 |
|
8 | 9 | from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint |
9 | 10 | from datadog_api_client.configuration import Configuration |
10 | 11 | from datadog_api_client.model_utils import ( |
| 12 | + set_attribute_from_path, |
| 13 | + get_attribute_from_path, |
11 | 14 | UnsetType, |
12 | 15 | unset, |
13 | 16 | ) |
14 | 17 | from datadog_api_client.v2.model.teams_response import TeamsResponse |
15 | 18 | from datadog_api_client.v2.model.list_teams_sort import ListTeamsSort |
16 | 19 | from datadog_api_client.v2.model.list_teams_include import ListTeamsInclude |
| 20 | +from datadog_api_client.v2.model.team import Team |
17 | 21 | from datadog_api_client.v2.model.team_response import TeamResponse |
18 | 22 | from datadog_api_client.v2.model.team_create_request import TeamCreateRequest |
19 | 23 | from datadog_api_client.v2.model.team_update_request import TeamUpdateRequest |
@@ -829,6 +833,67 @@ def list_teams( |
829 | 833 |
|
830 | 834 | return self._list_teams_endpoint.call_with_http_info(**kwargs) |
831 | 835 |
|
| 836 | + def list_teams_with_pagination( |
| 837 | + self, |
| 838 | + *, |
| 839 | + page_number: Union[int, UnsetType] = unset, |
| 840 | + page_size: Union[int, UnsetType] = unset, |
| 841 | + sort: Union[ListTeamsSort, UnsetType] = unset, |
| 842 | + include: Union[List[ListTeamsInclude], UnsetType] = unset, |
| 843 | + filter_keyword: Union[str, UnsetType] = unset, |
| 844 | + filter_me: Union[bool, UnsetType] = unset, |
| 845 | + ) -> collections.abc.Iterable[Team]: |
| 846 | + """Get all teams. |
| 847 | +
|
| 848 | + Provide a paginated version of :meth:`list_teams`, returning all items. |
| 849 | +
|
| 850 | + :param page_number: Specific page number to return. |
| 851 | + :type page_number: int, optional |
| 852 | + :param page_size: Size for a given page. The maximum allowed value is 100. |
| 853 | + :type page_size: int, optional |
| 854 | + :param sort: Specifies the order of the returned teams |
| 855 | + :type sort: ListTeamsSort, optional |
| 856 | + :param include: Included related resources optionally requested. Allowed enum values: ``team_links, user_team_permissions`` |
| 857 | + :type include: [ListTeamsInclude], optional |
| 858 | + :param filter_keyword: Search query. Can be team name, team handle, or email of team member |
| 859 | + :type filter_keyword: str, optional |
| 860 | + :param filter_me: When true, only returns teams the current user belongs to |
| 861 | + :type filter_me: bool, optional |
| 862 | +
|
| 863 | + :return: A generator of paginated results. |
| 864 | + :rtype: collections.abc.Iterable[Team] |
| 865 | + """ |
| 866 | + kwargs: Dict[str, Any] = {} |
| 867 | + if page_number is not unset: |
| 868 | + kwargs["page_number"] = page_number |
| 869 | + |
| 870 | + if page_size is not unset: |
| 871 | + kwargs["page_size"] = page_size |
| 872 | + |
| 873 | + if sort is not unset: |
| 874 | + kwargs["sort"] = sort |
| 875 | + |
| 876 | + if include is not unset: |
| 877 | + kwargs["include"] = include |
| 878 | + |
| 879 | + if filter_keyword is not unset: |
| 880 | + kwargs["filter_keyword"] = filter_keyword |
| 881 | + |
| 882 | + if filter_me is not unset: |
| 883 | + kwargs["filter_me"] = filter_me |
| 884 | + |
| 885 | + local_page_size = get_attribute_from_path(kwargs, "page_size", 10) |
| 886 | + endpoint = self._list_teams_endpoint |
| 887 | + set_attribute_from_path(kwargs, "page_size", local_page_size, endpoint.params_map) |
| 888 | + pagination = { |
| 889 | + "limit_value": local_page_size, |
| 890 | + "results_path": "data", |
| 891 | + "page_param": "page_number", |
| 892 | + "endpoint": endpoint, |
| 893 | + "kwargs": kwargs, |
| 894 | + } |
| 895 | + return endpoint.call_with_http_info_paginated(pagination) |
| 896 | + |
832 | 897 | def update_team( |
833 | 898 | self, |
834 | 899 | team_id: str, |
|
0 commit comments