File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed
Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -204,3 +204,34 @@ async def delete(
204204 api = f"/orgs/{ organization } /teams/{ team } "
205205 response = await self ._client .delete (api )
206206 response .raise_for_status ()
207+
208+ async def members (
209+ self ,
210+ organization : str ,
211+ team : str ,
212+ ) -> Iterable [JSON_OBJECT ]:
213+ """
214+ Get all members of a team. Team members will include the members of
215+ child teams.
216+
217+ https://docs.github.com/en/rest/teams/members#list-team-members
218+
219+ Args:
220+ organization: GitHub organization to use
221+ team: The slug of the team name.
222+
223+ Raises:
224+ `httpx.HTTPStatusError` if there was an error in the request
225+ """
226+ api = f"/orgs/{ organization } /teams/{ team } /members"
227+ members = []
228+ params = {
229+ "per_page" : "100" ,
230+ }
231+
232+ async for response in self ._client .get_all (api , params = params ):
233+ response .raise_for_status ()
234+
235+ members .extend (response .json ())
236+
237+ return members
Original file line number Diff line number Diff line change @@ -195,3 +195,23 @@ async def test_delete_failure(self):
195195 self .client .delete .assert_awaited_once_with (
196196 "/orgs/foo/teams/bar" ,
197197 )
198+
199+ async def test_members (self ):
200+ response1 = create_response ()
201+ response1 .json .return_value = [{"id" : 1 }]
202+ response2 = create_response ()
203+ response2 .json .return_value = [{"id" : 2 }, {"id" : 3 }]
204+
205+ self .client .get_all .return_value = AsyncIteratorMock (
206+ [response1 , response2 ]
207+ )
208+
209+ repos = await self .api .members ("foo" , "bar" )
210+
211+ self .assertEqual (len (repos ), 3 )
212+ self .assertEqual (repos , [{"id" : 1 }, {"id" : 2 }, {"id" : 3 }])
213+
214+ self .client .get_all .assert_called_once_with (
215+ "/orgs/foo/teams/bar/members" ,
216+ params = {"per_page" : "100" },
217+ )
You can’t perform that action at this time.
0 commit comments