Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

List pipeline schedule variables #595

Copy link
Copy link
@mlq

Description

@mlq
Issue body actions

Description of the problem, including code/CLI snippet

Last year, I've proposed the #398 PR in order to implement the support for pipeline schedules. The implementation has been updated and merged upstream, thank you for that.

However, this year I am trying to use the latest upstream release and have trouble to list the variables of a pipeline schedule. When I access the variables member of a project.pipelineschedule, I access the ProjectPipelineScheduleVariableManager which is neither iterable nor has a list() method implemented.

Therefore, I don't know how to access the actual list of variables. Maybe I am just assuming something wrong. Further, depending on how the list of pipeline schedules of a project has been retrieved, the pipeline schedule object contains the actual value of the variables or not.

Can someone point me out what the correct way would be?

Thank you

Expected Behavior

I expected the ProjectPipelineScheduleVariableManager to be either iterable or to implement a list() method.

Actual Behavior

Not supported (?)

Solution

As a solution, I just implemented a list() method that also takes care of the case where the actual variables have not been retrieved for the schedule. This is probably not the correct way to do it, but I do not know better.

diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 1d771ae..6886962 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2649,6 +2649,12 @@ class ProjectPipelineScheduleVariableManager(CreateMixin, UpdateMixin,
     _create_attrs = (('key', 'value'), tuple())
     _update_attrs = (('key', 'value'), tuple())
 
+    def list(self, **kwargs):
+        if 'variables' in self._parent._attrs:
+            return [self._obj_cls(self, x) for x in self._parent._attrs['variables']]
+        else:
+            return [self._obj_cls(self, x) for x in self._parent.manager.get(self._parent.id)._attrs['variables']]
+
 
 class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject):
     _managers = (('variables', 'ProjectPipelineScheduleVariableManager'),)

Specifications

  • python-gitlab version: 1.6.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): GitLab Community Edition 11.3.0 17bd59a

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.