Module ogr.services.github.auth_providers.abstract
Expand source code
# Copyright Contributors to the Packit project.
# SPDX-License-Identifier: MIT
from typing import Optional
import github
class GithubAuthentication:
"""
Represents a token manager for authentication via GitHub App.
"""
def get_token(self, namespace: str, repo: str) -> str:
"""
Get a GitHub token for requested repository.
Args:
namespace: Namespace of the repository.
repo: Name of the repository.
Returns:
A token that can be used in PyGithub instance for authentication.
"""
raise NotImplementedError()
@property
def pygithub_instance(self) -> "github.Github":
"""
Returns:
Generic PyGithub instance. Used for `GitUser` for example.
"""
raise NotImplementedError()
@staticmethod
def try_create(**kwargs) -> Optional["GithubAuthentication"]:
"""
Tries to construct authentication object from provided keyword arguments.
Returns:
`GithubAuthentication` object or `None` if the creation was not
successful.
"""
raise NotImplementedError()
Classes
class GithubAuthentication
-
Represents a token manager for authentication via GitHub App.
Expand source code
class GithubAuthentication: """ Represents a token manager for authentication via GitHub App. """ def get_token(self, namespace: str, repo: str) -> str: """ Get a GitHub token for requested repository. Args: namespace: Namespace of the repository. repo: Name of the repository. Returns: A token that can be used in PyGithub instance for authentication. """ raise NotImplementedError() @property def pygithub_instance(self) -> "github.Github": """ Returns: Generic PyGithub instance. Used for `GitUser` for example. """ raise NotImplementedError() @staticmethod def try_create(**kwargs) -> Optional["GithubAuthentication"]: """ Tries to construct authentication object from provided keyword arguments. Returns: `GithubAuthentication` object or `None` if the creation was not successful. """ raise NotImplementedError()
Subclasses
Static methods
def try_create(**kwargs) ‑> Optional[GithubAuthentication]
-
Tries to construct authentication object from provided keyword arguments.
Returns
GithubAuthentication
object orNone
if the creation was not successful.Expand source code
@staticmethod def try_create(**kwargs) -> Optional["GithubAuthentication"]: """ Tries to construct authentication object from provided keyword arguments. Returns: `GithubAuthentication` object or `None` if the creation was not successful. """ raise NotImplementedError()
Instance variables
var pygithub_instance : github.MainClass.Github
-
Returns
Generic PyGithub instance. Used for
GitUser
for example.Expand source code
@property def pygithub_instance(self) -> "github.Github": """ Returns: Generic PyGithub instance. Used for `GitUser` for example. """ raise NotImplementedError()
Methods
def get_token(self, namespace: str, repo: str) ‑> str
-
Get a GitHub token for requested repository.
Args
namespace
- Namespace of the repository.
repo
- Name of the repository.
Returns
A token that can be used in PyGithub instance for authentication.
Expand source code
def get_token(self, namespace: str, repo: str) -> str: """ Get a GitHub token for requested repository. Args: namespace: Namespace of the repository. repo: Name of the repository. Returns: A token that can be used in PyGithub instance for authentication. """ raise NotImplementedError()