From 18415fe34f44892da504ec578ea35e74f0d78565 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Mon, 2 Jan 2017 09:14:20 +0100 Subject: [PATCH 01/16] Forbid empty id for get() Unless the class explicitly defines it's OK (getRequiresId set to True). --- gitlab/objects.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitlab/objects.py b/gitlab/objects.py index 2a33dc518..4088661a5 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -99,6 +99,8 @@ def get(self, id=None, **kwargs): args = self._set_parent_args(**kwargs) if not self.obj_cls.canGet: raise NotImplementedError + if id is None and self.obj_cls.getRequiresId is True: + raise ValueError('The id argument must be defined.') return self.obj_cls.get(self.gitlab, id, **args) def list(self, **kwargs): From 05b3abf99b7af987a66c549fbd66e11710d5e3e6 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Mon, 2 Jan 2017 11:20:31 +0100 Subject: [PATCH 02/16] Some objects need getRequires to be set to False --- gitlab/objects.py | 3 +++ tools/python_test.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/gitlab/objects.py b/gitlab/objects.py index 4088661a5..8f44ef933 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -736,6 +736,7 @@ class CurrentUser(GitlabObject): class ApplicationSettings(GitlabObject): _url = '/application/settings' _id_in_update_url = False + getRequiresId = False optionalUpdateAttrs = ['after_sign_out_path', 'container_registry_token_expire_delay', 'default_branch_protection', @@ -794,6 +795,7 @@ class KeyManager(BaseManager): class NotificationSettings(GitlabObject): _url = '/notification_settings' _id_in_update_url = False + getRequiresId = False optionalUpdateAttrs = ['level', 'notification_email', 'new_note', @@ -2022,6 +2024,7 @@ class ProjectService(GitlabObject): canCreate = False _id_in_update_url = False _id_in_delete_url = False + getRequiresId = False requiredUrlAttrs = ['project_id', 'service_name'] _service_attrs = { diff --git a/tools/python_test.py b/tools/python_test.py index abfa5087b..55cb4784e 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -290,6 +290,14 @@ settings = gl.notificationsettings.get() assert(settings.level == gitlab.NOTIFICATION_LEVEL_WATCH) +# services +service = admin_project.services.get(service_name='asana') +service.active = True +service.api_key = 'whatever' +service.save() +service = admin_project.services.get(service_name='asana') +assert(service.active == True) + # snippets snippets = gl.snippets.list() assert(len(snippets) == 0) From e7560a9d07632cf4b7da8d44acbb63aa1248104a Mon Sep 17 00:00:00 2001 From: Will Starms Date: Wed, 11 Jan 2017 17:40:28 -0600 Subject: [PATCH 03/16] Update project.archive() docs --- docs/gl_objects/projects.py | 4 ++-- docs/gl_objects/projects.rst | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/gl_objects/projects.py b/docs/gl_objects/projects.py index ed99cec44..54bde842e 100644 --- a/docs/gl_objects/projects.py +++ b/docs/gl_objects/projects.py @@ -67,8 +67,8 @@ # end star # archive -project.archive_() -project.unarchive_() +project.archive() +project.unarchive() # end archive # events list diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst index 584fa58f6..dc6c48baf 100644 --- a/docs/gl_objects/projects.rst +++ b/docs/gl_objects/projects.rst @@ -94,9 +94,8 @@ Archive/unarchive a project: .. note:: - The underscore character at the end of the methods is used to workaround a - conflict with a previous misuse of the ``archive`` method (deprecated but - not yet removed). + Previous versions used ``archive_`` and ``unarchive_`` due to a naming issue, + they have been deprecated but not yet removed. Repository ---------- From de0536b1cfff43c494c64930a37333529e589a94 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 21 Jan 2017 14:13:28 +0100 Subject: [PATCH 04/16] Support the scope attribute in runners.list() --- docs/gl_objects/runners.py | 2 ++ docs/gl_objects/runners.rst | 11 ++++++++--- gitlab/objects.py | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/gl_objects/runners.py b/docs/gl_objects/runners.py index 5092dc08f..3de36df51 100644 --- a/docs/gl_objects/runners.py +++ b/docs/gl_objects/runners.py @@ -1,6 +1,8 @@ # list # List owned runners runners = gl.runners.list() +# With a filter +runners = gl.runners.list(scope='active') # List all runners, using a filter runners = gl.runners.all(scope='paused') # end list diff --git a/docs/gl_objects/runners.rst b/docs/gl_objects/runners.rst index 32d671999..2f7e5999c 100644 --- a/docs/gl_objects/runners.rst +++ b/docs/gl_objects/runners.rst @@ -13,9 +13,14 @@ Examples Use the ``list()`` and ``all()`` methods to list runners. -The ``all()`` method accepts a ``scope`` parameter to filter the list. Allowed -values for this parameter are ``specific``, ``shared``, ``active``, ``paused`` -and ``online``. +Both methods accept a ``scope`` parameter to filter the list. Allowed values +for this parameter are: + +* ``active`` +* ``paused`` +* ``online`` +* ``specific`` (``all()`` only) +* ``shared`` (``all()`` only) .. note:: diff --git a/gitlab/objects.py b/gitlab/objects.py index 8f44ef933..b2c0c040e 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -2478,6 +2478,7 @@ class Runner(GitlabObject): _url = '/runners' canCreate = False optionalUpdateAttrs = ['description', 'active', 'tag_list'] + optionalListAttrs = ['scope'] class RunnerManager(BaseManager): From 04435e1b13166fb45216c494f3af4d9bdb76bcaf Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 21 Jan 2017 14:42:12 +0100 Subject: [PATCH 05/16] Add support for project runners This API allows to enable/disable specific runners for a project, and to list the project associated runners. Fix #205 --- docs/gl_objects/runners.py | 18 ++++++++++++++++ docs/gl_objects/runners.rst | 42 +++++++++++++++++++++++++++++++++---- gitlab/objects.py | 11 ++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/docs/gl_objects/runners.py b/docs/gl_objects/runners.py index 3de36df51..1a9cb82dd 100644 --- a/docs/gl_objects/runners.py +++ b/docs/gl_objects/runners.py @@ -22,3 +22,21 @@ # or runner.delete() # end delete + +# project list +runners = gl.project_runners.list(project_id=1) +# or +runners = project.runners.list() +# end project list + +# project enable +p_runner = gl.project_runners.create({'runner_id': runner.id}, project_id=1) +# or +p_runner = project.runners.create({'runner_id': runner.id}) +# end project enable + +# project disable +gl.project_runners.delete(runner.id) +# or +project.runners.delete(runner.id) +# end project disable diff --git a/docs/gl_objects/runners.rst b/docs/gl_objects/runners.rst index 2f7e5999c..02db9be3a 100644 --- a/docs/gl_objects/runners.rst +++ b/docs/gl_objects/runners.rst @@ -2,11 +2,17 @@ Runners ####### -Global runners -============== +Runners are external process used to run CI jobs. They are deployed by the +administrator and registered to the GitLab instance. -Use :class:`~gitlab.objects.Runner` objects to manipulate runners. The -:attr:`gitlab.Gitlab.runners` manager object provides helper functions. +Shared runners are available for all projects. Specific runners are enabled for +a list of projects. + +Global runners (admin) +====================== + +* Object class: :class:`~gitlab.objects.Runner` +* Manager objects: :attr:`gitlab.Gitlab.runners` Examples -------- @@ -48,3 +54,31 @@ Remove a runner: .. literalinclude:: runners.py :start-after: # delete :end-before: # end delete + +Project runners +=============== + +* Object class: :class:`~gitlab.objects.ProjectRunner` +* Manager objects: :attr:`gitlab.Gitlab.runners`, + :attr:`gitlab.Gitlab.Project.runners` + +Examples +-------- + +List the runners for a project: + +.. literalinclude:: runners.py + :start-after: # project list + :end-before: # end project list + +Enable a specific runner for a project: + +.. literalinclude:: runners.py + :start-after: # project enable + :end-before: # end project enable + +Disable a specific runner for a project: + +.. literalinclude:: runners.py + :start-after: # project disable + :end-before: # end project disable diff --git a/gitlab/objects.py b/gitlab/objects.py index b2c0c040e..3f09aad8c 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -2142,6 +2142,16 @@ class ProjectDeploymentManager(BaseManager): obj_cls = ProjectDeployment +class ProjectRunner(GitlabObject): + _url = '/projects/%(project_id)s/runners' + canUpdate = False + requiredCreateAttrs = ['runner_id'] + + +class ProjectRunnerManager(BaseManager): + obj_cls = ProjectRunner + + class Project(GitlabObject): _url = '/projects' _constructorTypes = {'owner': 'User', 'namespace': 'Group'} @@ -2189,6 +2199,7 @@ class Project(GitlabObject): ('notificationsettings', ProjectNotificationSettingsManager, [('project_id', 'id')]), ('pipelines', ProjectPipelineManager, [('project_id', 'id')]), + ('runners', ProjectRunnerManager, [('project_id', 'id')]), ('services', ProjectServiceManager, [('project_id', 'id')]), ('snippets', ProjectSnippetManager, [('project_id', 'id')]), ('tags', ProjectTagManager, [('project_id', 'id')]), From ee666fd57e5cb100b6e195bb74228ac242d8932a Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 21 Jan 2017 16:54:16 +0100 Subject: [PATCH 06/16] Add support for commit creation Fixes #206 --- docs/gl_objects/commits.py | 20 ++++++++++++++++++++ docs/gl_objects/commits.rst | 31 +++++++++++++++++-------------- gitlab/objects.py | 6 ++++-- tools/python_test.py | 15 ++++++++++++++- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/docs/gl_objects/commits.py b/docs/gl_objects/commits.py index 30465139e..2ed66f560 100644 --- a/docs/gl_objects/commits.py +++ b/docs/gl_objects/commits.py @@ -9,6 +9,26 @@ commits = project.commits.list(since='2016-01-01T00:00:00Z') # end filter list +# create +# See https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions +# for actions detail +data = { + 'branch_name': 'master', + 'commit_message': 'blah blah blah', + 'actions': [ + { + 'action': 'create', + 'file_path': 'blah', + 'content': 'blah' + } + ] +} + +commit = gl.project_commits.create(data, project_id=1) +# or +commit = project.commits.create(data) +# end commit + # get commit = gl.project_commits.get('e3d5a71b', project_id=1) # or diff --git a/docs/gl_objects/commits.rst b/docs/gl_objects/commits.rst index 5a43597a5..8be1b8602 100644 --- a/docs/gl_objects/commits.rst +++ b/docs/gl_objects/commits.rst @@ -5,10 +5,9 @@ Commits Commits ======= -Use :class:`~gitlab.objects.ProjectCommit` objects to manipulate commits. The -:attr:`gitlab.Gitlab.project_commits` and -:attr:`gitlab.objects.Project.commits` manager objects provide helper -functions. +* Object class: :class:`~gitlab.objects.ProjectCommit` +* Manager objects: :attr:`gitlab.Gitlab.project_commits`, + :attr:`gitlab.objects.Project.commits` Examples -------- @@ -26,6 +25,12 @@ results: :start-after: # filter list :end-before: # end filter list +Create a commit: + +.. literalinclude:: commits.py + :start-after: # create + :end-before: # end create + Get a commit detail: .. literalinclude:: commits.py @@ -41,11 +46,10 @@ Get the diff for a commit: Commit comments =============== -Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits. The -:attr:`gitlab.Gitlab.project_commit_comments` and -:attr:`gitlab.objects.Project.commit_comments` and -:attr:`gitlab.objects.ProjectCommit.comments` manager objects provide helper -functions. +* Object class: :class:`~gitlab.objects.ProjectCommiComment` +* Manager objects: :attr:`gitlab.Gitlab.project_commit_comments`, + :attr:`gitlab.objects.Project.commit_comments`, + :attr:`gitlab.objects.ProjectCommit.comments` Examples -------- @@ -65,11 +69,10 @@ Add a comment on a commit: Commit status ============= -Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits. -The :attr:`gitlab.Gitlab.project_commit_statuses`, -:attr:`gitlab.objects.Project.commit_statuses` and -:attr:`gitlab.objects.ProjectCommit.statuses` manager objects provide helper -functions. +* Object class: :class:`~gitlab.objects.ProjectCommitStatus` +* Manager objects: :attr:`gitlab.Gitlab.project_commit_statuses`, + :attr:`gitlab.objects.Project.commit_statuses`, + :attr:`gitlab.objects.ProjectCommit.statuses` Examples -------- diff --git a/gitlab/objects.py b/gitlab/objects.py index 3f09aad8c..8c3591151 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -223,7 +223,8 @@ def _data_for_gitlab(self, extra_parameters={}, update=False, if hasattr(self, attribute): value = getattr(self, attribute) if isinstance(value, list): - value = ",".join(value) + if value and isinstance(value[0], six.string_types): + value = ",".join(value) if attribute == 'sudo': value = str(value) data[attribute] = value @@ -1278,8 +1279,9 @@ class ProjectCommit(GitlabObject): _url = '/projects/%(project_id)s/repository/commits' canDelete = False canUpdate = False - canCreate = False requiredUrlAttrs = ['project_id'] + requiredCreateAttrs = ['branch_name', 'commit_message', 'actions'] + optionalCreateAttrs = ['author_email', 'author_name'] shortPrintAttr = 'title' managers = ( ('comments', ProjectCommitCommentManager, diff --git a/tools/python_test.py b/tools/python_test.py index 55cb4784e..2d31d9f2d 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -161,8 +161,21 @@ readme = admin_project.files.get(file_path='README.rst', ref='master') assert(readme.decode() == 'Initial content') +data = { + 'branch_name': 'master', + 'commit_message': 'blah blah blah', + 'actions': [ + { + 'action': 'create', + 'file_path': 'blah', + 'content': 'blah' + } + ] +} +admin_project.commits.create(data) + tree = admin_project.repository_tree() -assert(len(tree) == 1) +assert(len(tree) == 2) assert(tree[0]['name'] == 'README.rst') blob = admin_project.repository_blob('master', 'README.rst') assert(blob == 'Initial content') From 4fba82eef461c5ef5829f6ce126aa393a8a56254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20N=C3=BC=C3=9Flein?= Date: Mon, 23 Jan 2017 01:27:19 +0100 Subject: [PATCH 07/16] Fix install doc it's just confusing that it would say "pip" again :) --- docs/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/install.rst b/docs/install.rst index 6abba3f03..fc9520400 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -12,7 +12,7 @@ Use :command:`pip` to install the latest stable version of ``python-gitlab``: The current development version is available on `github `__. Use :command:`git` and -:command:`pip` to install it: +:command:`python setup.py` to install it: .. code-block:: console From 1d827bd50041eab2ce3871c9070a698f6762d019 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Wed, 25 Jan 2017 08:29:25 +0100 Subject: [PATCH 08/16] deploy keys doc: fix inclusion --- docs/gl_objects/deploy_keys.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gl_objects/deploy_keys.py b/docs/gl_objects/deploy_keys.py index f144d9ef9..f86f2f72a 100644 --- a/docs/gl_objects/deploy_keys.py +++ b/docs/gl_objects/deploy_keys.py @@ -4,7 +4,7 @@ # global get key = gl.keys.get(key_id) -# end global key +# end global get # list keys = gl.project_keys.list(project_id=1) From 5cfa6fccf1a0c5c03871e1b3a4f910e25abfd854 Mon Sep 17 00:00:00 2001 From: Andjelko Horvat Date: Thu, 26 Jan 2017 22:25:15 +0100 Subject: [PATCH 09/16] Add builds-email and pipelines-email services --- gitlab/objects.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitlab/objects.py b/gitlab/objects.py index 8c3591151..846da204f 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -2042,6 +2042,10 @@ class ProjectService(GitlabObject): 'drone-ci': (('token', 'drone_url'), ('enable_ssl_verification', )), 'emails-on-push': (('recipients', ), ('disable_diffs', 'send_from_committer_email')), + 'builds-email': (('recipients', ), ('add_pusher', + 'notify_only_broken_builds')), + 'pipelines-email': (('recipients', ), ('add_pusher', + 'notify_only_broken_builds')), 'external-wiki': (('external_wiki_url', ), tuple()), 'flowdock': (('token', ), tuple()), 'gemnasium': (('api_key', 'token', ), tuple()), From 492a75121375059a66accbbbd6af433acf6d7106 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 4 Feb 2017 08:54:55 +0100 Subject: [PATCH 10/16] Deploy keys: rework enable/disable The method have been moved to the keys manager class as they don't make sens at all on the project keys themselves. Update doc and add tests. Fixes #196 --- docs/gl_objects/deploy_keys.py | 4 ++-- gitlab/objects.py | 17 ++++++++--------- tools/python_test.py | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docs/gl_objects/deploy_keys.py b/docs/gl_objects/deploy_keys.py index f86f2f72a..5d85055a7 100644 --- a/docs/gl_objects/deploy_keys.py +++ b/docs/gl_objects/deploy_keys.py @@ -36,9 +36,9 @@ # end delete # enable -deploy_key.enable() +project.keys.enable(key_id) # end enable # disable -deploy_key.disable() +project.keys.disable(key_id) # end disable diff --git a/gitlab/objects.py b/gitlab/objects.py index 846da204f..1ea3049fe 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1366,24 +1366,23 @@ class ProjectKey(GitlabObject): requiredUrlAttrs = ['project_id'] requiredCreateAttrs = ['title', 'key'] - def enable(self): + +class ProjectKeyManager(BaseManager): + obj_cls = ProjectKey + + def enable(self, key_id): """Enable a deploy key for a project.""" - url = '/projects/%s/deploy_keys/%s/enable' % (self.project_id, self.id) + url = '/projects/%s/deploy_keys/%s/enable' % (self.parent.id, key_id) r = self.gitlab._raw_post(url) raise_error_from_response(r, GitlabProjectDeployKeyError, 201) - def disable(self): + def disable(self, key_id): """Disable a deploy key for a project.""" - url = '/projects/%s/deploy_keys/%s/disable' % (self.project_id, - self.id) + url = '/projects/%s/deploy_keys/%s/disable' % (self.parent.id, key_id) r = self.gitlab._raw_delete(url) raise_error_from_response(r, GitlabProjectDeployKeyError, 200) -class ProjectKeyManager(BaseManager): - obj_cls = ProjectKey - - class ProjectEvent(GitlabObject): _url = '/projects/%(project_id)s/events' canGet = 'from_list' diff --git a/tools/python_test.py b/tools/python_test.py index 2d31d9f2d..ae5e09985 100644 --- a/tools/python_test.py +++ b/tools/python_test.py @@ -12,6 +12,13 @@ "a6WP5lTi/HJIjAl6Hu+zHgdj1XVExeH+S52EwpZf/ylTJub0Bl5gHwf/siVE48mLMI" "sqrukXTZ6Zg+8EHAIvIQwJ1dKcXe8P5IoLT7VKrbkgAnolS0I8J+uH7KtErZJb5oZh" "S4OEwsNpaXMAr+6/wWSpircV2/e7sFLlhlKBC4Iq1MpqlZ7G3p foo@bar") +DEPLOY_KEY = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFdRyjJQh+1niBpXqE2I8dzjG" + "MXFHlRjX9yk/UfOn075IdaockdU58sw2Ai1XIWFpZpfJkW7z+P47ZNSqm1gzeXI" + "rtKa9ZUp8A7SZe8vH4XVn7kh7bwWCUirqtn8El9XdqfkzOs/+FuViriUWoJVpA6" + "WZsDNaqINFKIA5fj/q8XQw+BcS92L09QJg9oVUuH0VVwNYbU2M2IRmSpybgC/gu" + "uWTrnCDMmLItksATifLvRZwgdI8dr+q6tbxbZknNcgEPrI2jT0hYN9ZcjNeWuyv" + "rke9IepE7SPBT41C+YtUX4dfDZDmczM1cE0YL/krdUCfuZHMa4ZS2YyNd6slufc" + "vn bar@foo") # login/password authentication gl = gitlab.Gitlab('http://localhost:8080', email=LOGIN, password=PASSWORD) @@ -183,6 +190,15 @@ archive2 = admin_project.repository_archive('master') assert(archive1 == archive2) +# deploy keys +deploy_key = admin_project.keys.create({'title': 'foo@bar', 'key': DEPLOY_KEY}) +project_keys = admin_project.keys.list() +assert(len(project_keys) == 1) +sudo_project.keys.enable(deploy_key.id) +assert(len(sudo_project.keys.list()) == 1) +sudo_project.keys.disable(deploy_key.id) +assert(len(sudo_project.keys.list()) == 0) + # labels label1 = admin_project.labels.create({'name': 'label1', 'color': '#778899'}) label1 = admin_project.labels.get('label1') From 2f274bcd0bfb9fef2a2682445843b7804980ecf6 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 4 Feb 2017 09:04:23 +0100 Subject: [PATCH 11/16] document the dynamic aspect of objects --- docs/api-usage.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/api-usage.rst b/docs/api-usage.rst index 4f8cb3717..a15aecbfa 100644 --- a/docs/api-usage.rst +++ b/docs/api-usage.rst @@ -2,7 +2,7 @@ Getting started with the API ############################ -The ``gitlab`` package provides 3 basic types: +The ``gitlab`` package provides 3 base types: * ``gitlab.Gitlab`` is the primary class, handling the HTTP requests. It holds the GitLab URL and authentication information. @@ -68,6 +68,17 @@ Examples: user = gl.users.create(user_data) print(user) +The attributes of objects are defined upon object creation, and depend on the +GitLab API itself. To list the available information associated with an object +use the python introspection tools: + +.. code-block:: python + + project = gl.projects.get(1) + print(vars(project)) + # or + print(project.__dict__) + Some ``gitlab.GitlabObject`` classes also provide managers to access related GitLab resources: From 58708b186e71289427cbce8decfeab28fdf66ad6 Mon Sep 17 00:00:00 2001 From: James Johnson Date: Wed, 8 Feb 2017 11:41:02 -0600 Subject: [PATCH 12/16] fixes gpocentek/python-gitlab#215 --- gitlab/objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab/objects.py b/gitlab/objects.py index 1ea3049fe..4da86d767 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1447,10 +1447,10 @@ class ProjectIssue(GitlabObject): requiredUrlAttrs = ['project_id'] requiredCreateAttrs = ['title'] optionalCreateAttrs = ['description', 'assignee_id', 'milestone_id', - 'labels', 'created_at'] + 'labels', 'created_at', 'due_date'] optionalUpdateAttrs = ['title', 'description', 'assignee_id', 'milestone_id', 'labels', 'created_at', - 'updated_at', 'state_event'] + 'updated_at', 'state_event', 'due_date'] shortPrintAttr = 'title' managers = ( ('notes', ProjectIssueNoteManager, From 3f98e0345c451a8ecb7d46d727acf7725ce73d80 Mon Sep 17 00:00:00 2001 From: Alex Widener Date: Thu, 9 Feb 2017 10:52:33 -0500 Subject: [PATCH 13/16] Added pipeline_events to ProejctHook attrs Ran tests, all passed. --- gitlab/objects.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitlab/objects.py b/gitlab/objects.py index 1ea3049fe..9648e26c0 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1417,7 +1417,8 @@ class ProjectHook(GitlabObject): requiredCreateAttrs = ['url'] optionalCreateAttrs = ['push_events', 'issues_events', 'note_events', 'merge_requests_events', 'tag_push_events', - 'build_events', 'enable_ssl_verification', 'token'] + 'build_events', 'enable_ssl_verification', 'token', + 'pipeline_events'] shortPrintAttr = 'url' From 41ca4497c3e30100991db0e8c673b722e45a6f44 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Sat, 18 Feb 2017 16:39:45 +0100 Subject: [PATCH 14/16] Handle settings.domain_whitelist, partly The API doesn't like receiving lists, although documentation says it's what's expected. To be investigated. This fixes the tests. --- gitlab/objects.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/gitlab/objects.py b/gitlab/objects.py index 41931abf6..4f5a394c1 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -222,10 +222,10 @@ def _data_for_gitlab(self, extra_parameters={}, update=False, for attribute in attributes: if hasattr(self, attribute): value = getattr(self, attribute) - if isinstance(value, list): - if value and isinstance(value[0], six.string_types): - value = ",".join(value) - if attribute == 'sudo': + # labels need to be sent as a comma-separated list + if attribute == 'labels' and isinstance(value, list): + value = ", ".join(value) + elif attribute == 'sudo': value = str(value) data[attribute] = value @@ -764,6 +764,15 @@ class ApplicationSettings(GitlabObject): canCreate = False canDelete = False + def _data_for_gitlab(self, extra_parameters={}, update=False, + as_json=True): + data = (super(ApplicationSettings, self) + ._data_for_gitlab(extra_parameters, update=update, + as_json=False)) + if not self.domain_whitelist: + data.pop('domain_whitelist', None) + return json.dumps(data) + class ApplicationSettingsManager(BaseManager): obj_cls = ApplicationSettings @@ -1458,19 +1467,6 @@ class ProjectIssue(GitlabObject): [('project_id', 'project_id'), ('issue_id', 'id')]), ) - def _data_for_gitlab(self, extra_parameters={}, update=False, - as_json=True): - # Gitlab-api returns labels in a json list and takes them in a - # comma separated list. - if hasattr(self, "labels"): - if (self.labels is not None and - not isinstance(self.labels, six.string_types)): - labels = ", ".join(self.labels) - extra_parameters['labels'] = labels - - return super(ProjectIssue, self)._data_for_gitlab(extra_parameters, - update) - def subscribe(self, **kwargs): """Subscribe to an issue. From a273a174ea00b563d16138ed98cc723bad7b7e29 Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Tue, 21 Feb 2017 05:48:07 +0100 Subject: [PATCH 15/16] {Project,Group}Member: support expires_at attribute Fixes #224 --- gitlab/objects.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitlab/objects.py b/gitlab/objects.py index 4f5a394c1..ea40b6f7d 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -870,7 +870,9 @@ class GroupMember(GitlabObject): canGet = 'from_list' requiredUrlAttrs = ['group_id'] requiredCreateAttrs = ['access_level', 'user_id'] + optionalCreateAttrs = ['expires_at'] requiredUpdateAttrs = ['access_level'] + optionalCreateAttrs = ['expires_at'] shortPrintAttr = 'username' def _update(self, **kwargs): @@ -1530,7 +1532,9 @@ class ProjectMember(GitlabObject): _url = '/projects/%(project_id)s/members' requiredUrlAttrs = ['project_id'] requiredCreateAttrs = ['access_level', 'user_id'] + optionalCreateAttrs = ['expires_at'] requiredUpdateAttrs = ['access_level'] + optionalCreateAttrs = ['expires_at'] shortPrintAttr = 'username' From cd696240ec9000ce12c4232db3436fbca58b8fdd Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Tue, 21 Feb 2017 05:54:43 +0100 Subject: [PATCH 16/16] 0.19 release --- AUTHORS | 4 ++++ ChangeLog | 15 +++++++++++++++ gitlab/__init__.py | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 3e38faff0..d01d5783e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -8,7 +8,10 @@ Contributors ------------ Adam Reid +Alex Widener Amar Sood (tekacs) +Andjelko Horvat +Andreas Nüßlein Andrew Austin Armin Weihbold Asher256 @@ -28,6 +31,7 @@ hakkeroid itxaka Ivica Arsov James (d0c_s4vage) Johnson +James Johnson Jason Antman Jonathon Reinhart Koen Smets diff --git a/ChangeLog b/ChangeLog index e769d163f..14415f9ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Version 0.19 + + * Update project.archive() docs + * Support the scope attribute in runners.list() + * Add support for project runners + * Add support for commit creation + * Fix install doc + * Add builds-email and pipelines-email services + * Deploy keys: rework enable/disable + * Document the dynamic aspect of objects + * Add pipeline_events to ProjectHook attrs + * Add due_date attribute to ProjectIssue + * Handle settings.domain_whitelist, partly + * {Project,Group}Member: support expires_at attribute + Version 0.18 * Fix JIRA service editing for GitLab 8.14+ diff --git a/gitlab/__init__.py b/gitlab/__init__.py index e0051aafd..119dab080 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -34,11 +34,11 @@ from gitlab.objects import * # noqa __title__ = 'python-gitlab' -__version__ = '0.18' +__version__ = '0.19' __author__ = 'Gauvain Pocentek' __email__ = 'gauvain@pocentek.net' __license__ = 'LGPL3' -__copyright__ = 'Copyright 2013-2016 Gauvain Pocentek' +__copyright__ = 'Copyright 2013-2017 Gauvain Pocentek' warnings.filterwarnings('default', category=DeprecationWarning, module='^gitlab')