| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ea089e0 commit 5b08d2a
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,13 @@ API objects manipulation | |||
| 3 | 3 | ######################## | |
| 4 | 4 | ||
| 5 | 5 | .. toctree:: | |
| 6 | + :maxdepth: 1 | ||
| 6 | 7 | ||
| 7 | 8 | gl_objects/branches | |
| 8 | 9 | gl_objects/builds | |
| 9 | 10 | gl_objects/commits | |
| 10 | 11 | gl_objects/deploy_keys | |
| 12 | + gl_objects/environments | ||
| 11 | 13 | gl_objects/groups | |
| 12 | 14 | gl_objects/issues | |
| 13 | 15 | gl_objects/namespaces | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,31 @@ | |||
| 1 | + # list | ||
| 2 | + environments = gl.project_environments.list(project_id=1) | ||
| 3 | + # or | ||
| 4 | + environments = project.environments.list() | ||
| 5 | + # end list | ||
| 6 | + | ||
| 7 | + # get | ||
| 8 | + environment = gl.project_environments.get(environment_id, project_id=1) | ||
| 9 | + # or | ||
| 10 | + environment = project.environments.get(environment_id) | ||
| 11 | + # end get | ||
| 12 | + | ||
| 13 | + # create | ||
| 14 | + environment = gl.project_environments.create({'name': 'production'}, | ||
| 15 | + project_id=1) | ||
| 16 | + # or | ||
| 17 | + environment = project.environments.create({'name': 'production'}) | ||
| 18 | + # end create | ||
| 19 | + | ||
| 20 | + # update | ||
| 21 | + environment.external_url = 'http://foo.bar.com' | ||
| 22 | + environment.save() | ||
| 23 | + # end update | ||
| 24 | + | ||
| 25 | + # delete | ||
| 26 | + environment = gl.project_environments.delete(environment_id, project_id=1) | ||
| 27 | + # or | ||
| 28 | + environment = project.environments.list(environment_id) | ||
| 29 | + # or | ||
| 30 | + environment.delete() | ||
| 31 | + # end delete | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,41 @@ | |||
| 1 | + ############ | ||
| 2 | + Environments | ||
| 3 | + ############ | ||
| 4 | + | ||
| 5 | + Use :class:`~gitlab.objects.ProjectEnvironment` objects to manipulate | ||
| 6 | + environments for projects. The :attr:`gitlab.Gitlab.project_environments` and | ||
| 7 | + :attr:`Project.environments <gitlab.objects.Project.environments>` manager | ||
| 8 | + objects provide helper functions. | ||
| 9 | + | ||
| 10 | + Examples | ||
| 11 | + -------- | ||
| 12 | + | ||
| 13 | + List environments for a project: | ||
| 14 | + | ||
| 15 | + .. literalinclude:: environments.py | ||
| 16 | + :start-after: # list | ||
| 17 | + :end-before: # end list | ||
| 18 | + | ||
| 19 | + Get a single environment: | ||
| 20 | + | ||
| 21 | + .. literalinclude:: environments.py | ||
| 22 | + :start-after: # get | ||
| 23 | + :end-before: # end get | ||
| 24 | + | ||
| 25 | + Create an environment for a project: | ||
| 26 | + | ||
| 27 | + .. literalinclude:: environments.py | ||
| 28 | + :start-after: # create | ||
| 29 | + :end-before: # end create | ||
| 30 | + | ||
| 31 | + Update an environment for a project: | ||
| 32 | + | ||
| 33 | + .. literalinclude:: environments.py | ||
| 34 | + :start-after: # update | ||
| 35 | + :end-before: # end update | ||
| 36 | + | ||
| 37 | + Delete an environment for a project: | ||
| 38 | + | ||
| 39 | + .. literalinclude:: environments.py | ||
| 40 | + :start-after: # delete | ||
| 41 | + :end-before: # end delete | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,6 +88,8 @@ class Gitlab(object): | |||
| 88 | 88 | project_commit_statuses (ProjectCommitStatusManager): Manager for | |
| 89 | 89 | GitLab projects commits statuses | |
| 90 | 90 | project_keys (ProjectKeyManager): Manager for GitLab projects keys | |
| 91 | + project_environments (ProjectEnvironmentManager): Manager for GitLab | ||
| 92 | + projects environments | ||
| 91 | 93 | project_events (ProjectEventManager): Manager for GitLab projects | |
| 92 | 94 | events | |
| 93 | 95 | project_forks (ProjectForkManager): Manager for GitLab projects forks | |
@@ -165,6 +167,7 @@ def __init__(self, url, private_token=None, email=None, password=None, | |||
| 165 | 167 | self.project_commit_comments = ProjectCommitCommentManager(self) | |
| 166 | 168 | self.project_commit_statuses = ProjectCommitStatusManager(self) | |
| 167 | 169 | self.project_keys = ProjectKeyManager(self) | |
| 170 | + self.project_environments = ProjectEnvironmentManager(self) | ||
| 168 | 171 | self.project_events = ProjectEventManager(self) | |
| 169 | 172 | self.project_forks = ProjectForkManager(self) | |
| 170 | 173 | self.project_hooks = ProjectHookManager(self) | |
@@ -417,6 +420,7 @@ def list(self, obj_class, **kwargs): | |||
| 417 | 420 | ", ".join(missing)) | |
| 418 | 421 | ||
| 419 | 422 | url = self._construct_url(id_=None, obj=obj_class, parameters=kwargs) | |
| 423 | + print(url) | ||
| 420 | 424 | headers = self._create_headers() | |
| 421 | 425 | ||
| 422 | 426 | # Remove attributes that are used in url so that there is only | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1075,6 +1075,19 @@ class ProjectCommitManager(BaseManager): | |||
| 1075 | 1075 | obj_cls = ProjectCommit | |
| 1076 | 1076 | ||
| 1077 | 1077 | ||
| 1078 | + class ProjectEnvironment(GitlabObject): | ||
| 1079 | + _url = '/projects/%(project_id)s/environments' | ||
| 1080 | + canGet = 'from_list' | ||
| 1081 | + requiredUrlAttrs = ['project_id'] | ||
| 1082 | + requiredCreateAttrs = ['name'] | ||
| 1083 | + optionalCreateAttrs = ['external_url'] | ||
| 1084 | + optionalUpdateAttrs = ['name', 'external_url'] | ||
| 1085 | + | ||
| 1086 | + | ||
| 1087 | + class ProjectEnvironmentManager(BaseManager): | ||
| 1088 | + obj_cls = ProjectEnvironment | ||
| 1089 | + | ||
| 1090 | + | ||
| 1078 | 1091 | class ProjectKey(GitlabObject): | |
| 1079 | 1092 | _url = '/projects/%(project_id)s/keys' | |
| 1080 | 1093 | canUpdate = False | |
@@ -1659,6 +1672,7 @@ class Project(GitlabObject): | |||
| 1659 | 1672 | [('project_id', 'id')]), | |
| 1660 | 1673 | ('commit_statuses', ProjectCommitStatusManager, | |
| 1661 | 1674 | [('project_id', 'id')]), | |
| 1675 | + ('environments', ProjectEnvironmentManager, [('project_id', 'id')]), | ||
| 1662 | 1676 | ('events', ProjectEventManager, [('project_id', 'id')]), | |
| 1663 | 1677 | ('files', ProjectFileManager, [('project_id', 'id')]), | |
| 1664 | 1678 | ('forks', ProjectForkManager, [('project_id', 'id')]), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments