|
| 1 | +# coding=utf-8 |
| 2 | + |
| 3 | +from ..base import BitbucketCloudBase |
| 4 | + |
| 5 | + |
| 6 | +class DeploymentEnvironments(BitbucketCloudBase): |
| 7 | + def __init__(self, url, *args, **kwargs): |
| 8 | + super(DeploymentEnvironments, self).__init__(url, *args, **kwargs) |
| 9 | + |
| 10 | + def __get_object(self, data): |
| 11 | + return DeploymentEnvironment( |
| 12 | + self.url_joiner(self.url, data["uuid"]), |
| 13 | + data, |
| 14 | + **self._new_session_args, |
| 15 | + ) |
| 16 | + |
| 17 | + def each(self, q=None, sort=None): |
| 18 | + """ |
| 19 | + Returns the list of environments in this repository. |
| 20 | +
|
| 21 | + :param q: string: Query string to narrow down the response. |
| 22 | + See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details. |
| 23 | + :param sort: string: Name of a response property to sort results. |
| 24 | + See https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering for details. |
| 25 | +
|
| 26 | + :return: A generator for the DeploymentEnvironment objects |
| 27 | +
|
| 28 | + API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/environments/#get |
| 29 | + """ |
| 30 | + params = {} |
| 31 | + if sort is not None: |
| 32 | + params["sort"] = sort |
| 33 | + if q is not None: |
| 34 | + params["q"] = q |
| 35 | + for deployment_environment in self._get_paged( |
| 36 | + None, |
| 37 | + params=params, |
| 38 | + ): |
| 39 | + yield self.__get_object(deployment_environment) |
| 40 | + |
| 41 | + return |
| 42 | + |
| 43 | + def get(self, uuid): |
| 44 | + """ |
| 45 | + Returns the environment with the uuid in this repository. |
| 46 | +
|
| 47 | + :param uuid: string: The requested environment uuid |
| 48 | +
|
| 49 | + :return: The requested DeploymentEnvironment objects |
| 50 | +
|
| 51 | + API docs: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/environments/%7Benvironment_uuid%7D#get |
| 52 | + """ |
| 53 | + return self.__get_object(super(DeploymentEnvironments, self).get(uuid)) |
| 54 | + |
| 55 | + |
| 56 | +class DeploymentEnvironment(BitbucketCloudBase): |
| 57 | + def __init__(self, url, data, *args, **kwargs): |
| 58 | + super(DeploymentEnvironment, self).__init__( |
| 59 | + url, *args, data=data, expected_type="deployment_environment", **kwargs |
| 60 | + ) |
| 61 | + |
| 62 | + @property |
| 63 | + def uuid(self): |
| 64 | + """The deployment environment uuid""" |
| 65 | + return self.get_data("uuid") |
| 66 | + |
| 67 | + @property |
| 68 | + def category(self): |
| 69 | + """The deployment environment category""" |
| 70 | + return self.get_data("category") |
| 71 | + |
| 72 | + @property |
| 73 | + def deployment_gate_enabled(self): |
| 74 | + """The deployment environment deployment gate enabled""" |
| 75 | + return self.get_data("deployment_gate_enabled") |
| 76 | + |
| 77 | + @property |
| 78 | + def environment_lock_enabled(self): |
| 79 | + """The deployment environment environment lock enabled""" |
| 80 | + return self.get_data("environment_lock_enabled") |
| 81 | + |
| 82 | + @property |
| 83 | + def environment_type(self): |
| 84 | + """The deployment environment environment type""" |
| 85 | + return self.get_data("environment_type") |
| 86 | + |
| 87 | + @property |
| 88 | + def hidden(self): |
| 89 | + """The deployment environment hidden""" |
| 90 | + return self.get_data("hidden") |
| 91 | + |
| 92 | + @property |
| 93 | + def lock(self): |
| 94 | + """The deployment environment lock""" |
| 95 | + return self.get_data("lock") |
| 96 | + |
| 97 | + @property |
| 98 | + def name(self): |
| 99 | + """The deployment environment name""" |
| 100 | + return self.get_data("name") |
| 101 | + |
| 102 | + @property |
| 103 | + def rank(self): |
| 104 | + """The deployment environment rank""" |
| 105 | + return self.get_data("rank") |
| 106 | + |
| 107 | + @property |
| 108 | + def restrictions(self): |
| 109 | + """The deployment environment restrictions""" |
| 110 | + return self.get_data("restrictions") |
| 111 | + |
| 112 | + @property |
| 113 | + def slug(self): |
| 114 | + """The deployment environment slug""" |
| 115 | + return self.get_data("slug") |
| 116 | + |
| 117 | + @property |
| 118 | + def type(self): |
| 119 | + """The deployment environment type""" |
| 120 | + return self.get_data("type") |
0 commit comments