mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Add support for environments (#2223)
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
import datetime
|
||||
from typing import List
|
||||
|
||||
import github.EnvironmentDeploymentBranchPolicy
|
||||
import github.EnvironmentProtectionRule
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class Environment(github.GithubObject.CompletableGithubObject):
|
||||
"""
|
||||
This class represents Environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
return self.get__repr__({"name": self._name.value})
|
||||
|
||||
@property
|
||||
def created_at(self) -> datetime.datetime:
|
||||
self._completeIfNotSet(self._created_at)
|
||||
return self._created_at.value
|
||||
|
||||
@property
|
||||
def html_url(self) -> str:
|
||||
self._completeIfNotSet(self._html_url)
|
||||
return self._html_url.value
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
self._completeIfNotSet(self._id)
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
self._completeIfNotSet(self._name)
|
||||
return self._name.value
|
||||
|
||||
@property
|
||||
def node_id(self) -> str:
|
||||
self._completeIfNotSet(self._node_id)
|
||||
return self._node_id.value
|
||||
|
||||
@property
|
||||
def protection_rules(
|
||||
self,
|
||||
) -> List[github.EnvironmentProtectionRule.EnvironmentProtectionRule]:
|
||||
self._completeIfNotSet(self._protection_rules)
|
||||
return self._protection_rules.value
|
||||
|
||||
@property
|
||||
def updated_at(self) -> datetime.datetime:
|
||||
self._completeIfNotSet(self._updated_at)
|
||||
return self._updated_at.value
|
||||
|
||||
@property
|
||||
def url(self) -> str:
|
||||
self._completeIfNotSet(self._url)
|
||||
return self._url.value
|
||||
|
||||
@property
|
||||
def deployment_branch_policy(
|
||||
self,
|
||||
) -> github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicy:
|
||||
self._completeIfNotSet(self._deployment_branch_policy)
|
||||
return self._deployment_branch_policy.value
|
||||
|
||||
def _initAttributes(self):
|
||||
self._created_at = github.GithubObject.NotSet
|
||||
self._html_url = github.GithubObject.NotSet
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._name = github.GithubObject.NotSet
|
||||
self._node_id = github.GithubObject.NotSet
|
||||
self._protection_rules = github.GithubObject.NotSet
|
||||
self._updated_at = github.GithubObject.NotSet
|
||||
self._url = github.GithubObject.NotSet
|
||||
self._deployment_branch_policy = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "created_at" in attributes: # pragma no branch
|
||||
self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
|
||||
if "html_url" in attributes: # pragma no branch
|
||||
self._html_url = self._makeStringAttribute(attributes["html_url"])
|
||||
if "id" in attributes: # pragma no branch
|
||||
self._id = self._makeIntAttribute(attributes["id"])
|
||||
if "name" in attributes: # pragma no branch
|
||||
self._name = self._makeStringAttribute(attributes["name"])
|
||||
if "node_id" in attributes: # pragma no branch
|
||||
self._node_id = self._makeStringAttribute(attributes["node_id"])
|
||||
if "protection_rules" in attributes: # pragma no branch
|
||||
self._protection_rules = self._makeListOfClassesAttribute(
|
||||
github.EnvironmentProtectionRule.EnvironmentProtectionRule,
|
||||
attributes["protection_rules"],
|
||||
)
|
||||
if "updated_at" in attributes: # pragma no branch
|
||||
self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
|
||||
if "url" in attributes: # pragma no branch
|
||||
self._url = self._makeStringAttribute(attributes["url"])
|
||||
if "deployment_branch_policy" in attributes: # pragma no branch
|
||||
self._deployment_branch_policy = self._makeClassAttribute(
|
||||
github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicy,
|
||||
attributes["deployment_branch_policy"],
|
||||
)
|
||||
@@ -0,0 +1,75 @@
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
import github.EnvironmentProtectionRuleReviewer
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class EnvironmentDeploymentBranchPolicy(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents a deployment branch policy for an environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
return self.get__repr__({})
|
||||
|
||||
@property
|
||||
def protected_branches(self) -> bool:
|
||||
return self._protected_branches.value
|
||||
|
||||
@property
|
||||
def custom_branch_policies(self) -> bool:
|
||||
return self._custom_branch_policies.value
|
||||
|
||||
def _initAttributes(self):
|
||||
self._protected_branches = github.GithubObject.NotSet
|
||||
self._custom_branch_policies = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "protected_branches" in attributes: # pragma no branch
|
||||
self._protected_branches = self._makeBoolAttribute(
|
||||
attributes["protected_branches"]
|
||||
)
|
||||
if "custom_branch_policies" in attributes: # pragma no branch
|
||||
self._custom_branch_policies = self._makeBoolAttribute(
|
||||
attributes["custom_branch_policies"]
|
||||
)
|
||||
|
||||
|
||||
class EnvironmentDeploymentBranchPolicyParams:
|
||||
"""
|
||||
This class presents the deployment branch policy parameters as can be configured for an Environment.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, protected_branches: bool = False, custom_branch_policies: bool = False
|
||||
):
|
||||
assert isinstance(protected_branches, bool)
|
||||
assert isinstance(custom_branch_policies, bool)
|
||||
self.protected_branches = protected_branches
|
||||
self.custom_branch_policies = custom_branch_policies
|
||||
|
||||
def _asdict(self) -> dict:
|
||||
return {
|
||||
"protected_branches": self.protected_branches,
|
||||
"custom_branch_policies": self.custom_branch_policies,
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
from typing import List
|
||||
|
||||
import github.EnvironmentProtectionRuleReviewer
|
||||
import github.GithubObject
|
||||
|
||||
|
||||
class EnvironmentProtectionRule(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents a protection rule for an environment. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
return self.get__repr__({"id": self._id.value})
|
||||
|
||||
@property
|
||||
def id(self) -> int:
|
||||
return self._id.value
|
||||
|
||||
@property
|
||||
def node_id(self) -> str:
|
||||
return self._node_id.value
|
||||
|
||||
@property
|
||||
def type(self) -> str:
|
||||
return self._type.value
|
||||
|
||||
@property
|
||||
def reviewers(
|
||||
self,
|
||||
) -> List[
|
||||
github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer
|
||||
]:
|
||||
return self._reviewers.value
|
||||
|
||||
@property
|
||||
def wait_timer(self) -> int:
|
||||
return self._wait_timer.value
|
||||
|
||||
def _initAttributes(self):
|
||||
self._id = github.GithubObject.NotSet
|
||||
self._node_id = github.GithubObject.NotSet
|
||||
self._type = github.GithubObject.NotSet
|
||||
self._reviewers = github.GithubObject.NotSet
|
||||
self._wait_timer = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "id" in attributes: # pragma no branch
|
||||
self._id = self._makeIntAttribute(attributes["id"])
|
||||
if "node_id" in attributes: # pragma no branch
|
||||
self._node_id = self._makeStringAttribute(attributes["node_id"])
|
||||
if "type" in attributes: # pragma no branch
|
||||
self._type = self._makeStringAttribute(attributes["type"])
|
||||
if "reviewers" in attributes: # pragma no branch
|
||||
self._reviewers = self._makeListOfClassesAttribute(
|
||||
github.EnvironmentProtectionRuleReviewer.EnvironmentProtectionRuleReviewer,
|
||||
attributes["reviewers"],
|
||||
)
|
||||
if "wait_timer" in attributes: # pragma no branch
|
||||
self._wait_timer = self._makeIntAttribute(attributes["wait_timer"])
|
||||
@@ -0,0 +1,80 @@
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import github.GithubObject
|
||||
import github.NamedUser
|
||||
import github.Team
|
||||
|
||||
|
||||
class EnvironmentProtectionRuleReviewer(github.GithubObject.NonCompletableGithubObject):
|
||||
"""
|
||||
This class represents a reviewer for an EnvironmentProtectionRule. The reference can be found here https://docs.github.com/en/rest/reference/deployments#environments
|
||||
"""
|
||||
|
||||
def __repr__(self):
|
||||
return self.get__repr__({"type": self._type.value})
|
||||
|
||||
@property
|
||||
def type(self) -> str:
|
||||
return self._type.value
|
||||
|
||||
@property
|
||||
def reviewer(self) -> github.NamedUser.NamedUser | github.Team.Team:
|
||||
return self._reviewer.value
|
||||
|
||||
def _initAttributes(self):
|
||||
self._type = github.GithubObject.NotSet
|
||||
self._reviewer = github.GithubObject.NotSet
|
||||
|
||||
def _useAttributes(self, attributes):
|
||||
if "type" in attributes: # pragma no branch
|
||||
self._type = self._makeStringAttribute(attributes["type"])
|
||||
if "reviewer" in attributes: # pragma no branch
|
||||
assert self._type.value in ("User", "Team")
|
||||
if self._type.value == "User":
|
||||
self._reviewer = self._makeClassAttribute(
|
||||
github.NamedUser.NamedUser, attributes["reviewer"]
|
||||
)
|
||||
elif self._type.value == "Team":
|
||||
self._reviewer = self._makeClassAttribute(
|
||||
github.Team.Team, attributes["reviewer"]
|
||||
)
|
||||
|
||||
|
||||
class ReviewerParams:
|
||||
"""
|
||||
This class presents reviewers as can be configured for an Environment.
|
||||
"""
|
||||
|
||||
def __init__(self, type_: str, id_: int):
|
||||
assert isinstance(type_, str) and type_ in ("User", "Team")
|
||||
assert isinstance(id_, int)
|
||||
self.type = type_
|
||||
self.id = id_
|
||||
|
||||
def _asdict(self) -> dict:
|
||||
return {
|
||||
"type": self.type,
|
||||
"id": self.id,
|
||||
}
|
||||
@@ -100,6 +100,7 @@
|
||||
# Copyright 2022 Ibrahim Hussaini <ibrahimhussainialias@outlook.com> #
|
||||
# Copyright 2022 KimSia Sim <245021+simkimsia@users.noreply.github.com> #
|
||||
# Copyright 2022 Marco Köpcke <hello@parakoopa.de> #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# Copyright 2023 Jonathan Leitschuh <Jonathan.Leitschuh@gmail.com> #
|
||||
# Copyright 2023 Sol Redfern <59831933+Tsuesun@users.noreply.github.com> #
|
||||
# Copyright 2023 Mikhail f. Shiryaev <mr.felixoid@gmail.com> #
|
||||
@@ -143,6 +144,10 @@ import github.Comparison
|
||||
import github.ContentFile
|
||||
import github.Deployment
|
||||
import github.Download
|
||||
import github.Environment
|
||||
import github.EnvironmentDeploymentBranchPolicy
|
||||
import github.EnvironmentProtectionRule
|
||||
import github.EnvironmentProtectionRuleReviewer
|
||||
import github.Event
|
||||
import github.GitBlob
|
||||
import github.GitCommit
|
||||
@@ -4103,6 +4108,95 @@ class Repository(github.GithubObject.CompletableGithubObject):
|
||||
None,
|
||||
)
|
||||
|
||||
def get_environments(self):
|
||||
"""
|
||||
:calls: `GET /repos/{owner}/{repo}/environments <https://docs.github.com/en/rest/reference/deployments#get-all-environments>`_
|
||||
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Environment.Environment`
|
||||
"""
|
||||
return github.PaginatedList.PaginatedList(
|
||||
github.Environment.Environment,
|
||||
self._requester,
|
||||
f"{self.url}/environments",
|
||||
None,
|
||||
list_item="environments",
|
||||
)
|
||||
|
||||
def get_environment(self, environment_name):
|
||||
"""
|
||||
:calls: `GET /repos/{owner}/{repo}/environments/{environment_name} <https://docs.github.com/en/rest/reference/deployments#get-an-environment>`_
|
||||
:rtype: :class:`github.Environment.Environment`
|
||||
"""
|
||||
assert isinstance(environment_name, str), environment_name
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"GET", f"{self.url}/environments/{environment_name}"
|
||||
)
|
||||
return github.Environment.Environment(
|
||||
self._requester, headers, data, completed=True
|
||||
)
|
||||
|
||||
def create_environment(
|
||||
self,
|
||||
environment_name,
|
||||
wait_timer=0,
|
||||
reviewers=[],
|
||||
deployment_branch_policy=None,
|
||||
):
|
||||
"""
|
||||
:calls: `PUT /repos/{owner}/{repo}/environments/{environment_name} <https://docs.github.com/en/rest/reference/deployments#create-or-update-an-environment>`_
|
||||
:param environment_name: string
|
||||
:param wait_timer: int
|
||||
:param reviews: List[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams]
|
||||
:param deployment_branch_policy: Optional[:class:github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams`]
|
||||
:rtype: :class:`github.Environment.Environment`
|
||||
"""
|
||||
assert isinstance(environment_name, str), environment_name
|
||||
assert isinstance(wait_timer, int)
|
||||
assert isinstance(reviewers, list)
|
||||
assert all(
|
||||
[
|
||||
isinstance(
|
||||
reviewer, github.EnvironmentProtectionRuleReviewer.ReviewerParams
|
||||
)
|
||||
for reviewer in reviewers
|
||||
]
|
||||
)
|
||||
assert (
|
||||
isinstance(
|
||||
deployment_branch_policy,
|
||||
github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams,
|
||||
)
|
||||
or deployment_branch_policy is None
|
||||
)
|
||||
|
||||
put_parameters = {
|
||||
"wait_timer": wait_timer,
|
||||
"reviewers": [reviewer._asdict() for reviewer in reviewers],
|
||||
"deployment_branch_policy": deployment_branch_policy._asdict()
|
||||
if deployment_branch_policy
|
||||
else None,
|
||||
}
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"PUT", f"{self.url}/environments/{environment_name}", input=put_parameters
|
||||
)
|
||||
return github.Environment.Environment(
|
||||
self._requester, headers, data, completed=True
|
||||
)
|
||||
|
||||
update_environment = create_environment
|
||||
|
||||
def delete_environment(self, environment_name):
|
||||
"""
|
||||
:calls: `DELETE /repos/{owner}/{repo}/environments/{environment_name} <https://docs.github.com/en/rest/reference/deployments#delete-an-environment>`_
|
||||
:param environment_name: string
|
||||
:rtype: None
|
||||
"""
|
||||
assert isinstance(environment_name, str), environment_name
|
||||
|
||||
headers, data = self._requester.requestJsonAndCheck(
|
||||
"DELETE", f"{self.url}/environments/{environment_name}"
|
||||
)
|
||||
|
||||
def _initAttributes(self):
|
||||
self._allow_auto_merge = github.GithubObject.NotSet
|
||||
self._allow_forking = github.GithubObject.NotSet
|
||||
|
||||
@@ -14,6 +14,11 @@ from github.Comparison import Comparison
|
||||
from github.ContentFile import ContentFile
|
||||
from github.Deployment import Deployment
|
||||
from github.Download import Download
|
||||
from github.Environment import Environment
|
||||
from github.EnvironmentDeploymentBranchPolicy import (
|
||||
EnvironmentDeploymentBranchPolicyParams,
|
||||
)
|
||||
from github.EnvironmentProtectionRuleReviewer import ReviewerParams
|
||||
from github.Event import Event
|
||||
from github.GitBlob import GitBlob
|
||||
from github.GitCommit import GitCommit
|
||||
@@ -142,6 +147,15 @@ class Repository(CompletableGithubObject):
|
||||
) -> Deployment: ...
|
||||
def get_repository_advisories(self) -> PaginatedList[RepositoryAdvisory]: ...
|
||||
def get_repository_advisory(self, ghsa: str) -> RepositoryAdvisory: ...
|
||||
def create_environment(
|
||||
self,
|
||||
environment_name: str,
|
||||
wait_timer: int = ...,
|
||||
reviewers: List[ReviewerParams] = ...,
|
||||
deployment_branch_policy: Optional[
|
||||
EnvironmentDeploymentBranchPolicyParams
|
||||
] = ...,
|
||||
) -> Environment: ...
|
||||
def create_file(
|
||||
self,
|
||||
path: str,
|
||||
@@ -287,6 +301,7 @@ class Repository(CompletableGithubObject):
|
||||
@property
|
||||
def default_branch(self) -> str: ...
|
||||
def delete(self) -> None: ...
|
||||
def delete_environment(self, environment_name: str) -> None: ...
|
||||
def delete_file(
|
||||
self,
|
||||
path: str,
|
||||
@@ -392,6 +407,8 @@ class Repository(CompletableGithubObject):
|
||||
) -> List[ContentFile]: ...
|
||||
def get_download(self, id: int) -> Download: ...
|
||||
def get_downloads(self) -> PaginatedList[Download]: ...
|
||||
def get_environments(self) -> PaginatedList[Environment]: ...
|
||||
def get_environment(self, environment_name: str) -> Environment: ...
|
||||
def get_events(self) -> PaginatedList[Event]: ...
|
||||
def get_forks(self) -> PaginatedList[Repository]: ...
|
||||
def create_fork(
|
||||
@@ -644,6 +661,15 @@ class Repository(CompletableGithubObject):
|
||||
@property
|
||||
def trees_url(self) -> str: ...
|
||||
def unsubscribe_from_hub(self, event: str, callback: str) -> None: ...
|
||||
def update_environment(
|
||||
self,
|
||||
environment_name: str,
|
||||
wait_timer: int = ...,
|
||||
reviewers: List[ReviewerParams] = ...,
|
||||
deployment_branch_policy: Optional[
|
||||
EnvironmentDeploymentBranchPolicyParams
|
||||
] = ...,
|
||||
) -> Environment: ...
|
||||
def update_file(
|
||||
self,
|
||||
path: str,
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
############################ Copyrights and license ############################
|
||||
# #
|
||||
# Copyright 2022 Alson van der Meulen <alson.vandermeulen@dearhealth.com> #
|
||||
# #
|
||||
# This file is part of PyGithub. #
|
||||
# http://pygithub.readthedocs.io/ #
|
||||
# #
|
||||
# PyGithub is free software: you can redistribute it and/or modify it under #
|
||||
# the terms of the GNU Lesser General Public License as published by the Free #
|
||||
# Software Foundation, either version 3 of the License, or (at your option) #
|
||||
# any later version. #
|
||||
# #
|
||||
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
||||
# details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU Lesser General Public License #
|
||||
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
||||
# #
|
||||
################################################################################
|
||||
|
||||
import datetime
|
||||
|
||||
import pytest # type: ignore
|
||||
|
||||
import github
|
||||
import github.EnvironmentDeploymentBranchPolicy
|
||||
import github.EnvironmentProtectionRule
|
||||
import github.EnvironmentProtectionRuleReviewer
|
||||
import github.NamedUser
|
||||
import github.Team
|
||||
|
||||
from . import Framework
|
||||
|
||||
|
||||
class Environment(Framework.TestCase):
|
||||
def setUp(self):
|
||||
self.tokenAuthMode = True
|
||||
super().setUp()
|
||||
self.repo = self.g.get_user().get_repo("PyGithub")
|
||||
self.environment = self.repo.get_environment("dev")
|
||||
|
||||
def testAttributes(self):
|
||||
self.assertEqual(self.environment.name, "dev")
|
||||
self.assertEqual(self.environment.id, 464814513)
|
||||
self.assertEqual(self.environment.node_id, "EN_kwDOHKhL9c4btIGx")
|
||||
self.assertEqual(
|
||||
self.environment.url,
|
||||
"https://api.github.com/repos/alson/PyGithub/environments/dev",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.environment.html_url,
|
||||
"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.environment.created_at, datetime.datetime(2022, 4, 13, 15, 6, 32)
|
||||
)
|
||||
self.assertEqual(
|
||||
self.environment.updated_at, datetime.datetime(2022, 4, 13, 15, 6, 32)
|
||||
)
|
||||
self.assertTrue(self.environment.deployment_branch_policy.protected_branches)
|
||||
self.assertFalse(
|
||||
self.environment.deployment_branch_policy.custom_branch_policies
|
||||
)
|
||||
|
||||
def testProtectionRules(self):
|
||||
protection_rules = self.environment.protection_rules
|
||||
self.assertEqual(len(protection_rules), 3)
|
||||
self.assertEqual(protection_rules[0].id, 216323)
|
||||
self.assertEqual(protection_rules[0].node_id, "GA_kwDOHKhL9c4AA00D")
|
||||
self.assertEqual(protection_rules[0].type, "branch_policy")
|
||||
self.assertEqual(protection_rules[1].id, 216324)
|
||||
self.assertEqual(protection_rules[1].node_id, "GA_kwDOHKhL9c4AA00E")
|
||||
self.assertEqual(protection_rules[1].type, "required_reviewers")
|
||||
self.assertEqual(protection_rules[2].id, 216325)
|
||||
self.assertEqual(protection_rules[2].node_id, "GA_kwDOHKhL9c4AA00F")
|
||||
self.assertEqual(protection_rules[2].type, "wait_timer")
|
||||
self.assertEqual(protection_rules[2].wait_timer, 15)
|
||||
|
||||
def testReviewers(self):
|
||||
# This is necessary so we can maintain our own expectations, which have been manually editted, for this test.
|
||||
reviewers = self.repo.get_environment("dev").protection_rules[1].reviewers
|
||||
self.assertEqual(len(reviewers), 2)
|
||||
self.assertEqual(reviewers[0].type, "User")
|
||||
self.assertIsInstance(reviewers[0].reviewer, github.NamedUser.NamedUser)
|
||||
assert isinstance(
|
||||
reviewers[0].reviewer, github.NamedUser.NamedUser
|
||||
) # Make type checker happy
|
||||
self.assertEqual(reviewers[0].reviewer.id, 19245)
|
||||
self.assertEqual(reviewers[0].reviewer.login, "alson")
|
||||
self.assertEqual(reviewers[0].reviewer.type, "User")
|
||||
self.assertEqual(reviewers[1].type, "Team")
|
||||
self.assertIsInstance(reviewers[1].reviewer, github.Team.Team)
|
||||
assert isinstance(
|
||||
reviewers[1].reviewer, github.Team.Team
|
||||
) # Make type checker happy
|
||||
self.assertEqual(reviewers[1].reviewer.id, 1)
|
||||
self.assertEqual(reviewers[1].reviewer.slug, "justice-league")
|
||||
self.assertEqual(reviewers[1].reviewer.url, "https://api.github.com/teams/1")
|
||||
|
||||
def testGetEnvironments(self):
|
||||
environments = self.repo.get_environments()
|
||||
self.assertEqual(environments.totalCount, 1)
|
||||
self.assertEqual(
|
||||
environments[0].url,
|
||||
"https://api.github.com/repos/alson/PyGithub/environments/dev",
|
||||
)
|
||||
self.assertEqual(environments[0].name, "dev")
|
||||
|
||||
def testCreateEnvironment(self):
|
||||
environment = self.repo.create_environment("test")
|
||||
self.assertEqual(environment.name, "test")
|
||||
self.assertEqual(environment.id, 470015651)
|
||||
self.assertEqual(environment.node_id, "EN_kwDOHKhL9c4cA96j")
|
||||
self.assertEqual(
|
||||
environment.url,
|
||||
"https://api.github.com/repos/alson/PyGithub/environments/test",
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.html_url,
|
||||
"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test",
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.created_at, datetime.datetime(2022, 4, 19, 14, 4, 32)
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.updated_at, datetime.datetime(2022, 4, 19, 14, 4, 32)
|
||||
)
|
||||
self.assertEqual(len(environment.protection_rules), 0)
|
||||
self.assertIsNone(environment.deployment_branch_policy)
|
||||
|
||||
def testUpdateEnvironment(self):
|
||||
environment = self.repo.create_environment(
|
||||
"test",
|
||||
wait_timer=42,
|
||||
reviewers=[
|
||||
github.EnvironmentProtectionRuleReviewer.ReviewerParams(
|
||||
type_="User", id_=19245
|
||||
)
|
||||
],
|
||||
deployment_branch_policy=github.EnvironmentDeploymentBranchPolicy.EnvironmentDeploymentBranchPolicyParams(
|
||||
protected_branches=True, custom_branch_policies=False
|
||||
),
|
||||
)
|
||||
self.assertEqual(environment.name, "test")
|
||||
self.assertEqual(environment.id, 470015651)
|
||||
self.assertEqual(environment.node_id, "EN_kwDOHKhL9c4cA96j")
|
||||
self.assertEqual(
|
||||
environment.url,
|
||||
"https://api.github.com/repos/alson/PyGithub/environments/test",
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.html_url,
|
||||
"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test",
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.created_at, datetime.datetime(2022, 4, 19, 14, 4, 32)
|
||||
)
|
||||
self.assertEqual(
|
||||
environment.updated_at, datetime.datetime(2022, 4, 19, 14, 4, 32)
|
||||
)
|
||||
self.assertEqual(len(environment.protection_rules), 3)
|
||||
self.assertEqual(environment.protection_rules[0].type, "required_reviewers")
|
||||
self.assertEqual(len(environment.protection_rules[0].reviewers), 1)
|
||||
self.assertEqual(environment.protection_rules[0].reviewers[0].type, "User")
|
||||
self.assertEqual(
|
||||
environment.protection_rules[0].reviewers[0].reviewer.id, 19245
|
||||
)
|
||||
self.assertEqual(environment.protection_rules[1].type, "wait_timer")
|
||||
self.assertEqual(environment.protection_rules[1].wait_timer, 42)
|
||||
self.assertEqual(environment.protection_rules[2].type, "branch_policy")
|
||||
self.assertTrue(environment.deployment_branch_policy.protected_branches)
|
||||
self.assertFalse(environment.deployment_branch_policy.custom_branch_policies)
|
||||
|
||||
def testDeleteEnvironment(self):
|
||||
self.repo.delete_environment("test")
|
||||
with pytest.raises(github.UnknownObjectException):
|
||||
self.repo.get_environment("test")
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
|
||||
https
|
||||
PUT
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments/test
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'}
|
||||
{"wait_timer": 0, "reviewers": [], "deployment_branch_policy": null}
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Tue, 19 Apr 2022 14:04:32 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"551b8efc5f64e50c7aea535a16d55561640ea5649a4e1d349ed09f953cae96da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4993'), ('X-RateLimit-Reset', '1650380634'), ('X-RateLimit-Used', '7'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'C759:D172:956268:97BB8A:625EC170')]
|
||||
{"id":470015651,"node_id":"EN_kwDOHKhL9c4cA96j","name":"test","url":"https://api.github.com/repos/alson/PyGithub/environments/test","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test","created_at":"2022-04-19T14:04:32Z","updated_at":"2022-04-19T14:04:32Z","protection_rules":[],"deployment_branch_policy":null}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
https
|
||||
DELETE
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments/test
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
204
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:43 GMT'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4996'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '4'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('X-GitHub-Request-Id', 'F37C:EF19:493413:4A9458:62601246')]
|
||||
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments/test
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
404
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 14:01:43 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4995'), ('X-RateLimit-Reset', '1650466902'), ('X-RateLimit-Used', '5'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Vary', 'Accept-Encoding, Accept, X-Requested-With'), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'F37D:1385E:70D68B:727E0B:62601247')]
|
||||
{"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#get-an-environment"}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments?per_page=1
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 18:02:57 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"ed85111e774379ffa08c34657bedabffff15a4f8e053b94cc89adc52e7f771da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4837'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '163'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D7DE:34F1:419DBE:43183F:62571051')]
|
||||
{"total_count":1,"environments":[{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}]}
|
||||
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 18:02:57 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"ed85111e774379ffa08c34657bedabffff15a4f8e053b94cc89adc52e7f771da"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4836'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '164'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D7DF:12F27:1358BD:147359:62571051')]
|
||||
{"total_count":1,"environments":[{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}]}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
GET
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments/dev
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python'}
|
||||
None
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 13 Apr 2022 17:40:18 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"3b0433057350078e2272494ff1c150fd0063b57b11fad140ec6bf723991e9ebf"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4915'), ('X-RateLimit-Reset', '1649873132'), ('X-RateLimit-Used', '85'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D6B6:B7D7:1419EA:151E71:62570B02')]
|
||||
{"id":464814513,"node_id":"EN_kwDOHKhL9c4btIGx","name":"dev","url":"https://api.github.com/repos/alson/PyGithub/environments/dev","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=dev","created_at":"2022-04-13T15:06:32Z","updated_at":"2022-04-13T15:06:32Z","protection_rules":[{"id":216323,"node_id":"GA_kwDOHKhL9c4AA00D","type":"branch_policy"},{"id":216324,"node_id":"GA_kwDOHKhL9c4AA00E","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}, {"type":"Team","reviewer":{"id":1,"node_id":"MDQ6VGVhbTE=","url":"https://api.github.com/teams/1","html_url":"https://github.com/orgs/github/teams/justice-league","name":"Justice League","slug":"justice-league","description":"A great team.","privacy":"closed","permission":"admin","members_url":"https://api.github.com/teams/1/members{/member}","repositories_url":"https://api.github.com/teams/1/repos","parent":null}}]},{"id":216325,"node_id":"GA_kwDOHKhL9c4AA00F","type":"wait_timer","wait_timer":15}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
https
|
||||
PUT
|
||||
api.github.com
|
||||
None
|
||||
/repos/alson/PyGithub/environments/test
|
||||
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'}
|
||||
{"wait_timer": 42, "reviewers": [{"type": "User", "id": 19245}], "deployment_branch_policy": {"protected_branches": true, "custom_branch_policies": false}}
|
||||
200
|
||||
[('Server', 'GitHub.com'), ('Date', 'Wed, 20 Apr 2022 10:41:27 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"6a0e8d2fa745fa04719de5c68f6535950341c778998f7979827ab4a865451879"'), ('X-OAuth-Scopes', 'repo'), ('X-Accepted-OAuth-Scopes', ''), ('github-authentication-token-expiration', '2022-05-13 15:01:13 UTC'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4992'), ('X-RateLimit-Reset', '1650454681'), ('X-RateLimit-Used', '8'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'D0C7:FF6E:A162C:A41FF:625FE356')]
|
||||
{"id":470015651,"node_id":"EN_kwDOHKhL9c4cA96j","name":"test","url":"https://api.github.com/repos/alson/PyGithub/environments/test","html_url":"https://github.com/alson/PyGithub/deployments/activity_log?environments_filter=test","created_at":"2022-04-19T14:04:32Z","updated_at":"2022-04-19T14:04:32Z","protection_rules":[{"id":222463,"node_id":"GA_kwDOHKhL9c4AA2T_","type":"required_reviewers","reviewers":[{"type":"User","reviewer":{"login":"alson","id":19245,"node_id":"MDQ6VXNlcjE5MjQ1","avatar_url":"https://avatars.githubusercontent.com/u/19245?v=4","gravatar_id":"","url":"https://api.github.com/users/alson","html_url":"https://github.com/alson","followers_url":"https://api.github.com/users/alson/followers","following_url":"https://api.github.com/users/alson/following{/other_user}","gists_url":"https://api.github.com/users/alson/gists{/gist_id}","starred_url":"https://api.github.com/users/alson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alson/subscriptions","organizations_url":"https://api.github.com/users/alson/orgs","repos_url":"https://api.github.com/users/alson/repos","events_url":"https://api.github.com/users/alson/events{/privacy}","received_events_url":"https://api.github.com/users/alson/received_events","type":"User","site_admin":false}}]},{"id":222464,"node_id":"GA_kwDOHKhL9c4AA2UA","type":"wait_timer","wait_timer":42},{"id":222465,"node_id":"GA_kwDOHKhL9c4AA2UB","type":"branch_policy"}],"deployment_branch_policy":{"protected_branches":true,"custom_branch_policies":false}}
|
||||
|
||||
Reference in New Issue
Block a user