mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-25 02:05:09 +00:00
Finish all user routes
This commit is contained in:
parent
5d1ce5b572
commit
ba8c827bc1
3 changed files with 327 additions and 41 deletions
|
@ -99,7 +99,7 @@ class RateLimits(NamedTuple):
|
||||||
# SCIM
|
# SCIM
|
||||||
# Search
|
# Search
|
||||||
# Teams
|
# Teams
|
||||||
# Users DONE(1st part)
|
# Users DONE
|
||||||
# Webhooks
|
# Webhooks
|
||||||
|
|
||||||
|
|
||||||
|
@ -282,6 +282,171 @@ class HTTPClient:
|
||||||
|
|
||||||
return await self.request("GET", f"/users/{username}/hovercard", params=params)
|
return await self.request("GET", f"/users/{username}/hovercard", params=params)
|
||||||
|
|
||||||
|
async def list_blocked_users_for_authenticated_user(self):
|
||||||
|
return await self.request("GET", "/user/blocks")
|
||||||
|
|
||||||
|
async def check_user_blocked_for_authenticated_user(self, *, username: str):
|
||||||
|
return await self.request("GET", f"/user/blocks/{username}")
|
||||||
|
|
||||||
|
async def block_user(self, *, username: str):
|
||||||
|
return await self.request("PUT", f"/user/blocks/{username}")
|
||||||
|
|
||||||
|
async def unblock_user(self, *, username: str):
|
||||||
|
return await self.request("DELETE", f"/user/blocks/{username}")
|
||||||
|
|
||||||
|
async def set_primary_email_visibility_for_authenticated_user(self, *, visibility: Literal["public", "private"]):
|
||||||
|
return await self.request("PATCH", "/user/email/visibility", json={"visibility": visibility})
|
||||||
|
|
||||||
|
async def list_email_addresses_for_the_authenticated_user(self, *, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/emails", params=params)
|
||||||
|
|
||||||
|
async def add_email_addresses_for_the_authenticated_user(self, *, emails: List[str]):
|
||||||
|
return await self.request("POST", "/user/emails", json={"email": emails})
|
||||||
|
|
||||||
|
async def delete_email_addresses_for_the_authenticated_user(self, *, emails: List[str]):
|
||||||
|
return await self.request("DELETE", "/user/emails", json={"email": emails})
|
||||||
|
|
||||||
|
async def list_public_email_addresses_for_the_authenticated_user(self,* , per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/emails/public", params=params)
|
||||||
|
|
||||||
|
async def list_followers_of_the_authenticated_user(self, *, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/followers", params=params)
|
||||||
|
|
||||||
|
async def list_following_for_the_authenticated_user(self, *, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/following", params=params)
|
||||||
|
|
||||||
|
async def check_person_followed_by_authenticated_user(self, *, username: str):
|
||||||
|
return await self.request("GET", f"/user/following/{username}")
|
||||||
|
|
||||||
|
async def follow_user(self, *, username: str):
|
||||||
|
return await self.request("PUT", f"/user/following/{username}")
|
||||||
|
|
||||||
|
async def unfollow_user(self, *, username: str):
|
||||||
|
return await self.request("DELETE", f"/user/following/{username}")
|
||||||
|
|
||||||
|
async def list_followers_for_user(self, *, username: str, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", f"/users/{username}/followers", params=params)
|
||||||
|
|
||||||
|
async def list_following_for_user(self, *, username: str, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", f"/users/{username}/following", params=params)
|
||||||
|
|
||||||
|
async def check_user_follows_another_user(self, *, username: str, target_user: str):
|
||||||
|
return await self.request("GET", f"/users/{username}/following/{target_user}")
|
||||||
|
|
||||||
|
async def list_gpg_keys_for_authenticated_user(self, *, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/gpg_keys", params=params)
|
||||||
|
|
||||||
|
async def create_gpg_key_for_authenticated_user(self, *, name: Optional[str] = None, armored_public_key: str):
|
||||||
|
data = {
|
||||||
|
"armored_public_key": armored_public_key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if name:
|
||||||
|
data["name"] = name
|
||||||
|
|
||||||
|
return await self.request("POST", "/user/gpg_keys", json=data)
|
||||||
|
|
||||||
|
async def get_gpg_key_for_authenticated_user(self, *, gpg_key_id: int):
|
||||||
|
return await self.request("GET", f"/user/gpg_keys/{gpg_key_id}")
|
||||||
|
|
||||||
|
async def delete_gpg_key_for_authenticated_user(self, *, gpg_key_id: int):
|
||||||
|
return await self.request("DELETE", f"/user/gpg_keys/{gpg_key_id}")
|
||||||
|
|
||||||
|
async def list_gpg_keys_for_user(self, *, username: str, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", f"/users/{username}/gpg_keys", params=params)
|
||||||
|
|
||||||
|
async def list_public_ssh_keys_for_authenticated_user(self, *, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", "/user/keys", params=params)
|
||||||
|
|
||||||
|
async def create_public_ssh_key_for_authenticated_user(self, *, title: Optional[str] = None, key: str):
|
||||||
|
data = {
|
||||||
|
"key": key,
|
||||||
|
}
|
||||||
|
|
||||||
|
if title:
|
||||||
|
data["title"] = title
|
||||||
|
|
||||||
|
return await self.request("POST", "/user/keys", json=data)
|
||||||
|
|
||||||
|
async def get_public_ssh_key_for_authenticated_user(self, *, key_id: int):
|
||||||
|
return await self.request("GET", f"/user/keys/{key_id}")
|
||||||
|
|
||||||
|
async def delete_public_ssh_key_for_authenticated_user(self, *, key_id: int):
|
||||||
|
return await self.request("DELETE", f"/user/keys/{key_id}")
|
||||||
|
|
||||||
|
async def list_public_ssh_keys_for_user(self, *, username: str, per_page: Optional[int] = None, page: Optional[int] = None):
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if per_page:
|
||||||
|
params["per_page"] = per_page
|
||||||
|
if page:
|
||||||
|
params["page"] = page
|
||||||
|
|
||||||
|
return await self.request("GET", f"/users/{username}/keys", params=params)
|
||||||
|
|
||||||
# === REPOS === #
|
# === REPOS === #
|
||||||
|
|
||||||
async def list_org_repos(
|
async def list_org_repos(
|
||||||
|
@ -1011,7 +1176,7 @@ class HTTPClient:
|
||||||
async def fork_gist(self, *, gist_id: str):
|
async def fork_gist(self, *, gist_id: str):
|
||||||
return await self.request("POST", f"/gists/{gist_id}/forks")
|
return await self.request("POST", f"/gists/{gist_id}/forks")
|
||||||
|
|
||||||
async def check_gist_is_starred(self, *, gist_id: str):
|
async def check_gist_starred(self, *, gist_id: str):
|
||||||
return await self.request("GET", f"/gists/{gist_id}/star")
|
return await self.request("GET", f"/gists/{gist_id}/star")
|
||||||
|
|
||||||
async def star_gist(self, *, gist_id: str):
|
async def star_gist(self, *, gist_id: str):
|
||||||
|
|
|
@ -6,13 +6,28 @@ if TYPE_CHECKING:
|
||||||
from typing_extensions import NotRequired
|
from typing_extensions import NotRequired
|
||||||
|
|
||||||
|
|
||||||
class LicenseSimple(TypedDict):
|
class SimpleUser(TypedDict):
|
||||||
key: str
|
name: NotRequired[Optional[str]]
|
||||||
name: str
|
email: NotRequired[Optional[str]]
|
||||||
url: Optional[str]
|
login: str
|
||||||
spdx_id: Optional[str]
|
id: int
|
||||||
node_id: str
|
node_id: str
|
||||||
html_url: NotRequired[str]
|
avatar_url: str
|
||||||
|
gravatar_id: Optional[str]
|
||||||
|
url: str
|
||||||
|
html_url: str
|
||||||
|
followers_url: str
|
||||||
|
following_url: str
|
||||||
|
gists_url: str
|
||||||
|
starred_url: str
|
||||||
|
subscriptions_url: str
|
||||||
|
organizations_url: str
|
||||||
|
repos_url: str
|
||||||
|
events_url: str
|
||||||
|
received_events_url: str
|
||||||
|
type: str
|
||||||
|
site_admin: bool
|
||||||
|
starred_at: NotRequired[str]
|
||||||
|
|
||||||
|
|
||||||
GeneratedObjectResult = List[LicenseSimple]
|
GeneratedObject = List[SimpleUser]
|
||||||
|
|
|
@ -1,58 +1,164 @@
|
||||||
{
|
{
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"title": "License Simple",
|
"title": "Simple User",
|
||||||
"description": "License Simple",
|
"description": "Simple User",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"key": {
|
|
||||||
"type": "string",
|
|
||||||
"examples": [
|
|
||||||
"mit"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"name": {
|
"name": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"email": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"login": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"examples": [
|
"examples": [
|
||||||
"MIT License"
|
"octocat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"url": {
|
"id": {
|
||||||
"type": [
|
"type": "integer",
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"format": "uri",
|
|
||||||
"examples": [
|
"examples": [
|
||||||
"https://api.github.com/licenses/mit"
|
1
|
||||||
]
|
|
||||||
},
|
|
||||||
"spdx_id": {
|
|
||||||
"type": [
|
|
||||||
"string",
|
|
||||||
"null"
|
|
||||||
],
|
|
||||||
"examples": [
|
|
||||||
"MIT"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_id": {
|
"node_id": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"examples": [
|
"examples": [
|
||||||
"MDc6TGljZW5zZW1pdA=="
|
"MDQ6VXNlcjE="
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"avatar_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://github.com/images/error/octocat_happy.gif"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gravatar_id": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
],
|
||||||
|
"examples": [
|
||||||
|
"41d064eb2195891e12d0413f63227ea7"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"html_url": {
|
"html_url": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"format": "uri"
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://github.com/octocat"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"followers_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/followers"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"following_url": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/following{/other_user}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gists_url": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/gists{/gist_id}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"starred_url": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/starred{/owner}{/repo}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"subscriptions_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/subscriptions"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"organizations_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/orgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"repos_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/repos"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"events_url": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/events{/privacy}"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"received_events_url": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "uri",
|
||||||
|
"examples": [
|
||||||
|
"https://api.github.com/users/octocat/received_events"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"User"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"site_admin": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"starred_at": {
|
||||||
|
"type": "string",
|
||||||
|
"examples": [
|
||||||
|
"\"2020-07-09T00:17:55Z\""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"key",
|
"avatar_url",
|
||||||
"name",
|
"events_url",
|
||||||
"url",
|
"followers_url",
|
||||||
"spdx_id",
|
"following_url",
|
||||||
"node_id"
|
"gists_url",
|
||||||
|
"gravatar_id",
|
||||||
|
"html_url",
|
||||||
|
"id",
|
||||||
|
"node_id",
|
||||||
|
"login",
|
||||||
|
"organizations_url",
|
||||||
|
"received_events_url",
|
||||||
|
"repos_url",
|
||||||
|
"site_admin",
|
||||||
|
"starred_url",
|
||||||
|
"subscriptions_url",
|
||||||
|
"type",
|
||||||
|
"url"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue