diff --git a/changelog/+utils-refactor.changed.md b/changelog/+utils-refactor.changed.md index b137c8c5..dac91d1d 100644 --- a/changelog/+utils-refactor.changed.md +++ b/changelog/+utils-refactor.changed.md @@ -1 +1 @@ -Refactored the GitHub API interaction layer into reusable per-entity modules below `saltext.github.utils.github`. These raise `GitHubApiError`/`GitHubNotFoundError` (subclasses of `CommandExecutionError`) instead of returning error indicators. Existing execution module functions behave as before, except that unhandled API errors now surface as the above exceptions instead of raw PyGithub ones. +Refactored the GitHub API interaction layer into reusable per-entity modules below `saltext.github.utils.gh`. These raise `GitHubApiError`/`GitHubNotFoundError` (subclasses of `CommandExecutionError`) instead of returning error indicators. Existing execution module functions behave as before, except that unhandled API errors now surface as the above exceptions instead of raw PyGithub ones. diff --git a/docs/ref/utils/index.rst b/docs/ref/utils/index.rst index 9d4d05ad..da3eef7c 100644 --- a/docs/ref/utils/index.rst +++ b/docs/ref/utils/index.rst @@ -10,13 +10,13 @@ _________ :toctree: utils - utils.github - utils.github.client - utils.github.exceptions - utils.github.issues - utils.github.milestones - utils.github.pulls - utils.github.repos - utils.github.rulesets - utils.github.teams - utils.github.users + utils.gh + utils.gh.client + utils.gh.exceptions + utils.gh.issues + utils.gh.milestones + utils.gh.pulls + utils.gh.repos + utils.gh.rulesets + utils.gh.teams + utils.gh.users diff --git a/docs/ref/utils/saltext.github.utils.gh.client.rst b/docs/ref/utils/saltext.github.utils.gh.client.rst new file mode 100644 index 00000000..371282c8 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.client.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.client +============================== + +.. automodule:: saltext.github.utils.gh.client + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.exceptions.rst b/docs/ref/utils/saltext.github.utils.gh.exceptions.rst new file mode 100644 index 00000000..a15f1ec5 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.exceptions.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.exceptions +================================== + +.. automodule:: saltext.github.utils.gh.exceptions + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.issues.rst b/docs/ref/utils/saltext.github.utils.gh.issues.rst new file mode 100644 index 00000000..40838720 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.issues.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.issues +============================== + +.. automodule:: saltext.github.utils.gh.issues + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.milestones.rst b/docs/ref/utils/saltext.github.utils.gh.milestones.rst new file mode 100644 index 00000000..bdcce9a3 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.milestones.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.milestones +================================== + +.. automodule:: saltext.github.utils.gh.milestones + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.pulls.rst b/docs/ref/utils/saltext.github.utils.gh.pulls.rst new file mode 100644 index 00000000..f6ef7dc6 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.pulls.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.pulls +============================= + +.. automodule:: saltext.github.utils.gh.pulls + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.repos.rst b/docs/ref/utils/saltext.github.utils.gh.repos.rst new file mode 100644 index 00000000..6c24befc --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.repos.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.repos +============================= + +.. automodule:: saltext.github.utils.gh.repos + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.rst b/docs/ref/utils/saltext.github.utils.gh.rst new file mode 100644 index 00000000..f23dd432 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh +======================= + +.. automodule:: saltext.github.utils.gh + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.rulesets.rst b/docs/ref/utils/saltext.github.utils.gh.rulesets.rst new file mode 100644 index 00000000..d53bf303 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.rulesets.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.rulesets +================================ + +.. automodule:: saltext.github.utils.gh.rulesets + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.teams.rst b/docs/ref/utils/saltext.github.utils.gh.teams.rst new file mode 100644 index 00000000..172a86ab --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.teams.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.teams +============================= + +.. automodule:: saltext.github.utils.gh.teams + :members: diff --git a/docs/ref/utils/saltext.github.utils.gh.users.rst b/docs/ref/utils/saltext.github.utils.gh.users.rst new file mode 100644 index 00000000..6789a159 --- /dev/null +++ b/docs/ref/utils/saltext.github.utils.gh.users.rst @@ -0,0 +1,5 @@ +saltext.github.utils.gh.users +============================= + +.. automodule:: saltext.github.utils.gh.users + :members: diff --git a/docs/ref/utils/saltext.github.utils.github.client.rst b/docs/ref/utils/saltext.github.utils.github.client.rst deleted file mode 100644 index 72202b64..00000000 --- a/docs/ref/utils/saltext.github.utils.github.client.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.client -================================== - -.. automodule:: saltext.github.utils.github.client - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.exceptions.rst b/docs/ref/utils/saltext.github.utils.github.exceptions.rst deleted file mode 100644 index a64a161f..00000000 --- a/docs/ref/utils/saltext.github.utils.github.exceptions.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.exceptions -====================================== - -.. automodule:: saltext.github.utils.github.exceptions - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.issues.rst b/docs/ref/utils/saltext.github.utils.github.issues.rst deleted file mode 100644 index ae450b0c..00000000 --- a/docs/ref/utils/saltext.github.utils.github.issues.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.issues -================================== - -.. automodule:: saltext.github.utils.github.issues - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.milestones.rst b/docs/ref/utils/saltext.github.utils.github.milestones.rst deleted file mode 100644 index b64be801..00000000 --- a/docs/ref/utils/saltext.github.utils.github.milestones.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.milestones -====================================== - -.. automodule:: saltext.github.utils.github.milestones - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.pulls.rst b/docs/ref/utils/saltext.github.utils.github.pulls.rst deleted file mode 100644 index d5321249..00000000 --- a/docs/ref/utils/saltext.github.utils.github.pulls.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.pulls -================================= - -.. automodule:: saltext.github.utils.github.pulls - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.repos.rst b/docs/ref/utils/saltext.github.utils.github.repos.rst deleted file mode 100644 index b43706df..00000000 --- a/docs/ref/utils/saltext.github.utils.github.repos.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.repos -================================= - -.. automodule:: saltext.github.utils.github.repos - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.rst b/docs/ref/utils/saltext.github.utils.github.rst deleted file mode 100644 index 3a149363..00000000 --- a/docs/ref/utils/saltext.github.utils.github.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github -=========================== - -.. automodule:: saltext.github.utils.github - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.rulesets.rst b/docs/ref/utils/saltext.github.utils.github.rulesets.rst deleted file mode 100644 index 68cad6c8..00000000 --- a/docs/ref/utils/saltext.github.utils.github.rulesets.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.rulesets -==================================== - -.. automodule:: saltext.github.utils.github.rulesets - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.teams.rst b/docs/ref/utils/saltext.github.utils.github.teams.rst deleted file mode 100644 index dae2586e..00000000 --- a/docs/ref/utils/saltext.github.utils.github.teams.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.teams -================================= - -.. automodule:: saltext.github.utils.github.teams - :members: diff --git a/docs/ref/utils/saltext.github.utils.github.users.rst b/docs/ref/utils/saltext.github.utils.github.users.rst deleted file mode 100644 index 2da335a3..00000000 --- a/docs/ref/utils/saltext.github.utils.github.users.rst +++ /dev/null @@ -1,5 +0,0 @@ -saltext.github.utils.github.users -================================= - -.. automodule:: saltext.github.utils.github.users - :members: diff --git a/src/saltext/github/modules/github.py b/src/saltext/github/modules/github.py index a3927bce..8b8ce5cc 100644 --- a/src/saltext/github/modules/github.py +++ b/src/saltext/github/modules/github.py @@ -61,16 +61,16 @@ from saltext.github.utils import filter_unset try: - from saltext.github.utils.github import client as gh_client - from saltext.github.utils.github import issues as gh_issues - from saltext.github.utils.github import milestones as gh_milestones - from saltext.github.utils.github import pulls as gh_pulls - from saltext.github.utils.github import repos as gh_repos - from saltext.github.utils.github import rulesets as gh_rulesets - from saltext.github.utils.github import teams as gh_teams - from saltext.github.utils.github import users as gh_users - from saltext.github.utils.github.exceptions import GitHubApiError - from saltext.github.utils.github.exceptions import GitHubNotFoundError + from saltext.github.utils.gh import client as gh_client + from saltext.github.utils.gh import issues as gh_issues + from saltext.github.utils.gh import milestones as gh_milestones + from saltext.github.utils.gh import pulls as gh_pulls + from saltext.github.utils.gh import repos as gh_repos + from saltext.github.utils.gh import rulesets as gh_rulesets + from saltext.github.utils.gh import teams as gh_teams + from saltext.github.utils.gh import users as gh_users + from saltext.github.utils.gh.exceptions import GitHubApiError + from saltext.github.utils.gh.exceptions import GitHubNotFoundError HAS_LIBS = True except ImportError: # pragma: no cover diff --git a/src/saltext/github/utils/github/__init__.py b/src/saltext/github/utils/gh/__init__.py similarity index 82% rename from src/saltext/github/utils/github/__init__.py rename to src/saltext/github/utils/gh/__init__.py index 340be2f7..1b92ade0 100644 --- a/src/saltext/github/utils/github/__init__.py +++ b/src/saltext/github/utils/gh/__init__.py @@ -3,10 +3,10 @@ The submodules of this package provide reusable primitives for talking to the GitHub API on behalf of an organization, built around -:class:`~saltext.github.utils.github.client.GitHubConnection`. -They raise :class:`~saltext.github.utils.github.exceptions.GitHubApiError` +:class:`~saltext.github.utils.gh.client.GitHubConnection`. +They raise :class:`~saltext.github.utils.gh.exceptions.GitHubApiError` (or its more specific subclass -:class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError`) +:class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError`) on API errors. """ @@ -15,8 +15,8 @@ import salt.utils.http import salt.utils.json -from saltext.github.utils.github.exceptions import GitHubApiError # noqa: F401 -from saltext.github.utils.github.exceptions import GitHubNotFoundError # noqa: F401 +from saltext.github.utils.gh.exceptions import GitHubApiError # noqa: F401 +from saltext.github.utils.gh.exceptions import GitHubNotFoundError # noqa: F401 log = logging.getLogger(__name__) diff --git a/src/saltext/github/utils/github/client.py b/src/saltext/github/utils/gh/client.py similarity index 95% rename from src/saltext/github/utils/github/client.py rename to src/saltext/github/utils/gh/client.py index 091ebb7d..3a72fd37 100644 --- a/src/saltext/github/utils/github/client.py +++ b/src/saltext/github/utils/gh/client.py @@ -2,8 +2,8 @@ Shared plumbing for talking to the GitHub v3 API via PyGithub. The functions in this package operate on a :class:`GitHubConnection` and -raise :class:`~saltext.github.utils.github.exceptions.GitHubApiError` -(or its :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` +raise :class:`~saltext.github.utils.gh.exceptions.GitHubApiError` +(or its :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` subclass) on API errors. They are shared between the classic ``github`` execution module and future resource modules. """ @@ -17,8 +17,8 @@ from github.GithubException import UnknownObjectException from salt.exceptions import CommandExecutionError -from saltext.github.utils.github.exceptions import GitHubApiError -from saltext.github.utils.github.exceptions import GitHubNotFoundError +from saltext.github.utils.gh.exceptions import GitHubApiError +from saltext.github.utils.gh.exceptions import GitHubNotFoundError log = logging.getLogger(__name__) diff --git a/src/saltext/github/utils/github/exceptions.py b/src/saltext/github/utils/gh/exceptions.py similarity index 100% rename from src/saltext/github/utils/github/exceptions.py rename to src/saltext/github/utils/gh/exceptions.py diff --git a/src/saltext/github/utils/github/issues.py b/src/saltext/github/utils/gh/issues.py similarity index 92% rename from src/saltext/github/utils/github/issues.py rename to src/saltext/github/utils/gh/issues.py index 76a901fc..1d35e1bf 100644 --- a/src/saltext/github/utils/github/issues.py +++ b/src/saltext/github/utils/gh/issues.py @@ -4,7 +4,7 @@ import logging -from saltext.github.utils.github import client +from saltext.github.utils.gh import client log = logging.getLogger(__name__) @@ -14,7 +14,7 @@ def get(conn, repo_name, number): Return the raw data of a single issue. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository the issue belongs to. @@ -30,7 +30,7 @@ def get_comments(conn, repo_name, number, since=None): Return the raw comment data for a single issue. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository the issue belongs to. @@ -70,7 +70,7 @@ def list_all( options. Pull requests are excluded. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository whose issues to list. diff --git a/src/saltext/github/utils/github/milestones.py b/src/saltext/github/utils/gh/milestones.py similarity index 88% rename from src/saltext/github/utils/github/milestones.py rename to src/saltext/github/utils/gh/milestones.py index 52f6f4cb..eeebafdd 100644 --- a/src/saltext/github/utils/github/milestones.py +++ b/src/saltext/github/utils/gh/milestones.py @@ -4,7 +4,7 @@ import logging -from saltext.github.utils.github import client +from saltext.github.utils.gh import client log = logging.getLogger(__name__) @@ -14,7 +14,7 @@ def get(conn, repo_name, number): Return the raw data of a single milestone. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository the milestone belongs to. @@ -39,7 +39,7 @@ def list_all( search options. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository whose milestones to list. diff --git a/src/saltext/github/utils/github/pulls.py b/src/saltext/github/utils/gh/pulls.py similarity index 92% rename from src/saltext/github/utils/github/pulls.py rename to src/saltext/github/utils/gh/pulls.py index 1de17b2a..47d87d4c 100644 --- a/src/saltext/github/utils/github/pulls.py +++ b/src/saltext/github/utils/gh/pulls.py @@ -4,7 +4,7 @@ import logging -from saltext.github.utils.github import client +from saltext.github.utils.gh import client log = logging.getLogger(__name__) @@ -25,7 +25,7 @@ def list_all( search options. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. repo_name The name of the repository whose pull requests to list. diff --git a/src/saltext/github/utils/github/repos.py b/src/saltext/github/utils/gh/repos.py similarity index 88% rename from src/saltext/github/utils/github/repos.py rename to src/saltext/github/utils/gh/repos.py index 91edbc8e..d44a2b5a 100644 --- a/src/saltext/github/utils/github/repos.py +++ b/src/saltext/github/utils/gh/repos.py @@ -8,8 +8,8 @@ from salt.exceptions import CommandExecutionError from saltext.github.utils import filter_unset -from saltext.github.utils.github.client import api_request -from saltext.github.utils.github.exceptions import GitHubNotFoundError +from saltext.github.utils.gh.client import api_request +from saltext.github.utils.gh.exceptions import GitHubNotFoundError log = logging.getLogger(__name__) @@ -50,7 +50,7 @@ def list_all(conn, ignore_cache=False): objects (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ignore_cache Bypass the cached repository list. @@ -71,7 +71,7 @@ def get_info(conn, name, ignore_cache=False): Return information about a single repository as a dictionary (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the repository. @@ -79,7 +79,7 @@ def get_info(conn, name, ignore_cache=False): ignore_cache Bypass the cached repository information. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the repository does not exist. """ key = ("repo_info", name.lower()) @@ -106,12 +106,12 @@ def get_teams(conn, name): Return the teams a repository belongs to. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the repository. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the repository does not exist. """ try: @@ -146,7 +146,7 @@ def create( Create a new repository in the organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the repository to create. @@ -187,7 +187,7 @@ def update( Update an existing repository in the organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the repository to update. @@ -225,7 +225,7 @@ def delete(conn, name): Delete a repository from the organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the repository to delete. diff --git a/src/saltext/github/utils/github/rulesets.py b/src/saltext/github/utils/gh/rulesets.py similarity index 90% rename from src/saltext/github/utils/github/rulesets.py rename to src/saltext/github/utils/gh/rulesets.py index 2d8b8f89..07a27373 100644 --- a/src/saltext/github/utils/github/rulesets.py +++ b/src/saltext/github/utils/gh/rulesets.py @@ -6,7 +6,7 @@ from salt.exceptions import CommandExecutionError -from saltext.github.utils.github import client +from saltext.github.utils.gh import client log = logging.getLogger(__name__) @@ -67,7 +67,7 @@ def list_all( Return all rulesets of a repository or organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. Other parameters as described in :func:`build_path`. ``headers`` is a mapping of extra headers to send. @@ -81,7 +81,7 @@ def get(conn, ruleset_id, ruleset_type, *, owner=None, repo_name=None, org_name= Return the data of a specific ruleset. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ruleset_id The ID of the ruleset to retrieve. @@ -102,7 +102,7 @@ def create( Create a new ruleset. Returns the data of the created ruleset. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ruleset_params The ruleset definition. Must contain at least ``name`` and @@ -131,7 +131,7 @@ def update( Update an existing ruleset. Returns the data of the updated ruleset. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ruleset_id The ID of the ruleset to update. @@ -156,7 +156,7 @@ def delete( Delete a ruleset. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ruleset_id The ID of the ruleset to delete. diff --git a/src/saltext/github/utils/github/teams.py b/src/saltext/github/utils/gh/teams.py similarity index 87% rename from src/saltext/github/utils/github/teams.py rename to src/saltext/github/utils/gh/teams.py index b5524313..757569d1 100644 --- a/src/saltext/github/utils/github/teams.py +++ b/src/saltext/github/utils/gh/teams.py @@ -11,7 +11,7 @@ from github.GithubException import UnknownObjectException from saltext.github.utils import filter_unset -from saltext.github.utils.github.client import api_request +from saltext.github.utils.gh.client import api_request log = logging.getLogger(__name__) @@ -23,7 +23,7 @@ def list_all(conn, ignore_cache=False): team details (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ignore_cache Bypass the cached team list. @@ -51,7 +51,7 @@ def get(conn, name): not exist. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the team. @@ -65,7 +65,7 @@ def create(conn, name, *, description=None, repo_names=None, privacy=None, permi Create a new team in the organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. name The name of the team to create. @@ -96,7 +96,7 @@ def update(conn, team_info, name, *, description=None, privacy=None, permission= Update an existing team. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -126,7 +126,7 @@ def delete(conn, team_info): Delete a team from the organization. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -143,7 +143,7 @@ def list_repos(conn, team_info, ignore_cache=False): name to repository details (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -175,7 +175,7 @@ def add_repo(conn, team_info, repo_name, permission=None): on it. Returns false if updating the permission failed. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -205,7 +205,7 @@ def remove_repo(conn, team_info, repo_name): longer associated with the team afterwards. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -225,7 +225,7 @@ def list_members(conn, team_info, ignore_cache=False): Return the (lowercase) logins of a team's members (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -247,7 +247,7 @@ def add_member(conn, team_info, login): Add an organization member to a team. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -267,7 +267,7 @@ def remove_member(conn, team_info, login): a member of the team afterwards. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. team_info The team's entry from :func:`list_all`. @@ -275,7 +275,7 @@ def remove_member(conn, team_info, login): login The login of the user to remove. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the team or user does not exist. """ team = conn.org.get_team_by_slug(team_info["slug"]) diff --git a/src/saltext/github/utils/github/users.py b/src/saltext/github/utils/gh/users.py similarity index 80% rename from src/saltext/github/utils/github/users.py rename to src/saltext/github/utils/gh/users.py index 7285623b..c1e79ef2 100644 --- a/src/saltext/github/utils/github/users.py +++ b/src/saltext/github/utils/gh/users.py @@ -6,7 +6,7 @@ from github.GithubException import UnknownObjectException -from saltext.github.utils.github.client import api_request +from saltext.github.utils.gh.client import api_request log = logging.getLogger(__name__) @@ -17,7 +17,7 @@ def list_members(conn, ignore_cache=False): Return the logins of all members of the organization (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ignore_cache Bypass the cached member list. @@ -34,12 +34,12 @@ def get_user_info(conn, login): membership state. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. login The login of the user to look up. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the user does not exist. """ user = conn.client.get_user(login) @@ -76,12 +76,12 @@ def invite_member(conn, login): membership state is ``pending``. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. login The login of the user to invite. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the user does not exist. """ user = conn.client.get_user(login) @@ -101,12 +101,12 @@ def remove_member(conn, login): longer a member afterwards. conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. login The login of the user to remove. - Raises :class:`~saltext.github.utils.github.exceptions.GitHubNotFoundError` + Raises :class:`~saltext.github.utils.gh.exceptions.GitHubNotFoundError` if the user does not exist. """ user = conn.client.get_user(login) @@ -124,7 +124,7 @@ def list_members_without_mfa(conn, ignore_cache=False): MFA turned on (cached). conn - The :class:`~saltext.github.utils.github.client.GitHubConnection` to use. + The :class:`~saltext.github.utils.gh.client.GitHubConnection` to use. ignore_cache Bypass the cached member list. diff --git a/tests/functional/modules/github/test_profiles.py b/tests/functional/modules/github/test_profiles.py index 9a010824..6875b8cb 100644 --- a/tests/functional/modules/github/test_profiles.py +++ b/tests/functional/modules/github/test_profiles.py @@ -6,7 +6,7 @@ import pytest from salt.exceptions import CommandExecutionError -from saltext.github.utils.github.exceptions import GitHubNotFoundError +from saltext.github.utils.gh.exceptions import GitHubNotFoundError @pytest.fixture(scope="module") diff --git a/tests/unit/modules/test_github.py b/tests/unit/modules/test_github.py index d472bbaf..4fb28949 100644 --- a/tests/unit/modules/test_github.py +++ b/tests/unit/modules/test_github.py @@ -6,8 +6,8 @@ from salt.modules import config as config_mod from saltext.github.modules import github as github_mod -from saltext.github.utils.github import client as gh_client -from saltext.github.utils.github.exceptions import GitHubApiError +from saltext.github.utils.gh import client as gh_client +from saltext.github.utils.gh.exceptions import GitHubApiError @pytest.fixture diff --git a/tests/unit/utils/test_client.py b/tests/unit/utils/test_client.py index 63257be5..91019c0f 100644 --- a/tests/unit/utils/test_client.py +++ b/tests/unit/utils/test_client.py @@ -4,9 +4,9 @@ import pytest from salt.exceptions import CommandExecutionError -from saltext.github.utils.github import client as gh_client -from saltext.github.utils.github.exceptions import GitHubApiError -from saltext.github.utils.github.exceptions import GitHubNotFoundError +from saltext.github.utils.gh import client as gh_client +from saltext.github.utils.gh.exceptions import GitHubApiError +from saltext.github.utils.gh.exceptions import GitHubNotFoundError @pytest.fixture diff --git a/tests/unit/utils/test_rulesets.py b/tests/unit/utils/test_rulesets.py index ad5d4ee8..31277437 100644 --- a/tests/unit/utils/test_rulesets.py +++ b/tests/unit/utils/test_rulesets.py @@ -1,7 +1,7 @@ import pytest from salt.exceptions import CommandExecutionError -from saltext.github.utils.github import rulesets as gh_rulesets +from saltext.github.utils.gh import rulesets as gh_rulesets def test_build_path_repo():