Module aiogithubapi.namespaces.users
Methods for the users namespace
https://docs.github.com/en/rest/reference/users
Expand source code
"""
Methods for the users namespace
https://docs.github.com/en/rest/reference/users
"""
from __future__ import annotations
from typing import Any, Dict
from ..const import GitHubRequestKwarg
from ..models.organization import GitHubOrganizationMinimalModel
from ..models.repository import GitHubRepositoryModel
from ..models.response import GitHubResponseModel
from ..models.user import GitHubUserModel
from .base import BaseNamespace
from .projects import GitHubUsersProjectsNamespace
class GitHubUsersNamespace(BaseNamespace):
"""Methods for the users namespace"""
def __post_init__(self) -> None:
self._projects = GitHubUsersProjectsNamespace(self._client)
@property
def projects(self) -> GitHubUsersProjectsNamespace:
"""Property to access the users projects namespace"""
return self._projects
async def get(
self,
username: str,
**kwargs: Dict[GitHubRequestKwarg, Any],
) -> GitHubResponseModel[GitHubUserModel]:
"""
Get a user
**Arguments**:
`username`
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/users#get-a-user
"""
response = await self._client.async_call_api(
endpoint=f"/users/{username}",
**kwargs,
)
response.data = GitHubUserModel(response.data)
return response
async def starred(
self,
username: str,
**kwargs: Dict[GitHubRequestKwarg, Any],
) -> GitHubResponseModel[list[GitHubRepositoryModel]]:
"""
Get the starred repositories of a user
**Arguments**:
`username`
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/users#get-a-user
"""
response = await self._client.async_call_api(
endpoint=f"/users/{username}/starred",
**kwargs,
)
response.data = [GitHubRepositoryModel(data) for data in response.data]
return response
async def repos(
self,
username: str,
**kwargs: Dict[GitHubRequestKwarg, Any],
) -> GitHubResponseModel[list[GitHubRepositoryModel]]:
"""
Get the repositories of a user
**Arguments**:
`username`
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/repos#list-repositories-for-a-user
"""
response = await self._client.async_call_api(
endpoint=f"/users/{username}/repos",
**kwargs,
)
response.data = [GitHubRepositoryModel(data) for data in response.data]
return response
async def orgs(
self,
username: str,
**kwargs: Dict[GitHubRequestKwarg, Any],
) -> GitHubResponseModel[list[GitHubOrganizationMinimalModel]]:
"""
List public organization memberships for the specified user.
**Arguments**:
`username`
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/orgs#list-organizations-for-a-user
"""
response = await self._client.async_call_api(
endpoint=f"/users/{username}/orgs",
**kwargs,
)
response.data = [GitHubOrganizationMinimalModel(data) for data in response.data or []]
return response
Classes
class GitHubUsersNamespace (client: GitHubClient)
-
Methods for the users namespace
Initialise the namespace.
Expand source code
class GitHubUsersNamespace(BaseNamespace): """Methods for the users namespace""" def __post_init__(self) -> None: self._projects = GitHubUsersProjectsNamespace(self._client) @property def projects(self) -> GitHubUsersProjectsNamespace: """Property to access the users projects namespace""" return self._projects async def get( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[GitHubUserModel]: """ Get a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/users#get-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}", **kwargs, ) response.data = GitHubUserModel(response.data) return response async def starred( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubRepositoryModel]]: """ Get the starred repositories of a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/users#get-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/starred", **kwargs, ) response.data = [GitHubRepositoryModel(data) for data in response.data] return response async def repos( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubRepositoryModel]]: """ Get the repositories of a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/repos#list-repositories-for-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/repos", **kwargs, ) response.data = [GitHubRepositoryModel(data) for data in response.data] return response async def orgs( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubOrganizationMinimalModel]]: """ List public organization memberships for the specified user. **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/orgs#list-organizations-for-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/orgs", **kwargs, ) response.data = [GitHubOrganizationMinimalModel(data) for data in response.data or []] return response
Ancestors
Instance variables
var projects : GitHubUsersProjectsNamespace
-
Property to access the users projects namespace
Expand source code
@property def projects(self) -> GitHubUsersProjectsNamespace: """Property to access the users projects namespace""" return self._projects
Methods
async def get(self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any]) ‑> GitHubResponseModel[GitHubUserModel]
-
Get a user
Arguments:
username
The username to return, example "octocat"
Expand source code
async def get( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[GitHubUserModel]: """ Get a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/users#get-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}", **kwargs, ) response.data = GitHubUserModel(response.data) return response
async def orgs(self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any]) ‑> GitHubResponseModel[list[GitHubOrganizationMinimalModel]]
-
List public organization memberships for the specified user.
Arguments:
username
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/orgs#list-organizations-for-a-user
Expand source code
async def orgs( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubOrganizationMinimalModel]]: """ List public organization memberships for the specified user. **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/orgs#list-organizations-for-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/orgs", **kwargs, ) response.data = [GitHubOrganizationMinimalModel(data) for data in response.data or []] return response
async def repos(self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any]) ‑> GitHubResponseModel[list[GitHubRepositoryModel]]
-
Get the repositories of a user
Arguments:
username
The username to return, example "octocat"
https://docs.github.com/en/rest/reference/repos#list-repositories-for-a-user
Expand source code
async def repos( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubRepositoryModel]]: """ Get the repositories of a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/repos#list-repositories-for-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/repos", **kwargs, ) response.data = [GitHubRepositoryModel(data) for data in response.data] return response
async def starred(self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any]) ‑> GitHubResponseModel[list[GitHubRepositoryModel]]
-
Get the starred repositories of a user
Arguments:
username
The username to return, example "octocat"
Expand source code
async def starred( self, username: str, **kwargs: Dict[GitHubRequestKwarg, Any], ) -> GitHubResponseModel[list[GitHubRepositoryModel]]: """ Get the starred repositories of a user **Arguments**: `username` The username to return, example "octocat" https://docs.github.com/en/rest/reference/users#get-a-user """ response = await self._client.async_call_api( endpoint=f"/users/{username}/starred", **kwargs, ) response.data = [GitHubRepositoryModel(data) for data in response.data] return response