diff --git a/api/apps/apps.py b/api/apps/apps.py index da3a787..c757f5a 100644 --- a/api/apps/apps.py +++ b/api/apps/apps.py @@ -1,11 +1,13 @@ from core.rest_client import RestClient from api.apps.installactions import Installation +from api.apps.permission import Permission class Apps(RestClient): def __init__(self, api_root_url, **kwargs): super(Apps, self).__init__(api_root_url, **kwargs) self.installaction = Installation(self.api_root_url, **kwargs) + self.permission = Permission(self.api_root_url, **kwargs) def create_gitHub_app_from_a_manifest(self, code, **kwargs): """ diff --git a/api/apps/permission.py b/api/apps/permission.py new file mode 100644 index 0000000..f6d14ff --- /dev/null +++ b/api/apps/permission.py @@ -0,0 +1,41 @@ +from core.rest_client import RestClient + + +class Permission(RestClient): + def list_ssh_for_current_user(self, **kwargs): + """ + https://docs.github.com/en/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user + :param kwargs: + :return: + """ + headers = {'Accept': 'application/vnd.github+json'} + return self.get("/user/keys", headers=headers, **kwargs) + + def create_ssh_for_current_user(self, **kwargs): + """ + https://docs.github.com/en/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user + :param kwargs: + :return: + """ + headers = {'Accept': 'application/vnd.github+json'} + return self.post("/user/keys", headers=headers, **kwargs) + + def get_a_ssh_for_current_user(self, key_id, **kwargs): + """ + https://docs.github.com/en/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user + :param key_id: SSH key id + :param kwargs: + :return: + """ + headers = {'Accept': 'application/vnd.github+json'} + return self.get("/user/keys/{}".format(key_id), headers=headers, **kwargs) + + def delete_a_ssh_for_current_user(self, key_id, **kwargs): + """ + https://docs.github.com/en/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user + :param key_id: SSH key id + :param kwargs: + :return: + """ + headers = {'Accept': 'application/vnd.github+json'} + return self.delete("/user/keys/{}".format(key_id), headers=headers, **kwargs) diff --git a/api/interactions/orgs.py b/api/interactions/orgs.py index 912f709..2ee1171 100644 --- a/api/interactions/orgs.py +++ b/api/interactions/orgs.py @@ -2,7 +2,8 @@ class Orgs(RestClient): - def __init__(self): + def __init__(self, api_root_url, **kwargs): + super(Orgs, self).__init__(api_root_url, **kwargs) self.headers = {'Accept': 'application/vnd.github.sombra-preview'} def get_interactions_limits_for_org(self, org, **kwargs): diff --git a/api/interactions/repos.py b/api/interactions/repos.py index c4fc7c0..d728a21 100644 --- a/api/interactions/repos.py +++ b/api/interactions/repos.py @@ -2,7 +2,8 @@ class Repos(RestClient): - def __init__(self): + def __init__(self, api_root_url, **kwargs): + super(Repos, self).__init__(api_root_url, **kwargs) self.headers = {'Accept': 'application/vnd.github.sombra-preview'} def get_interaction_restrictions_for_repo(self, owner, **kwargs):