diff options
author | John L. Villalovos <john@sodarock.com> | 2021-03-07 11:31:23 -0800 |
---|---|---|
committer | Nejc Habjan <hab.nejc@gmail.com> | 2021-04-17 17:09:41 +0200 |
commit | aee1f496c1f414c1e30909767d53ae624fe875e7 (patch) | |
tree | 04a7fe9d8f77cffeae733bb8dd3447911995f3a1 /gitlab/v4/objects/pipelines.py | |
parent | 8603248f73d8c751023fbfd2a394c5b7d939af7f (diff) | |
download | gitlab-aee1f496c1f414c1e30909767d53ae624fe875e7.tar.gz |
chore: have _create_attrs & _update_attrs be a namedtuple
Convert _create_attrs and _update_attrs to use a NamedTuple
(RequiredOptional) to help with code readability. Update all code to
use the NamedTuple.
Diffstat (limited to 'gitlab/v4/objects/pipelines.py')
-rw-r--r-- | gitlab/v4/objects/pipelines.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gitlab/v4/objects/pipelines.py b/gitlab/v4/objects/pipelines.py index 9f0516a..703d40b 100644 --- a/gitlab/v4/objects/pipelines.py +++ b/gitlab/v4/objects/pipelines.py @@ -1,6 +1,6 @@ from gitlab import cli, types from gitlab import exceptions as exc -from gitlab.base import RESTManager, RESTObject +from gitlab.base import RequiredOptional, RESTManager, RESTObject from gitlab.mixins import ( CRUDMixin, CreateMixin, @@ -83,7 +83,7 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManage "order_by", "sort", ) - _create_attrs = (("ref",), tuple()) + _create_attrs = RequiredOptional(required=("ref",)) def create(self, data, **kwargs): """Creates a new object. @@ -150,8 +150,8 @@ class ProjectPipelineScheduleVariableManager( ) _obj_cls = ProjectPipelineScheduleVariable _from_parent_attrs = {"project_id": "project_id", "pipeline_schedule_id": "id"} - _create_attrs = (("key", "value"), tuple()) - _update_attrs = (("key", "value"), tuple()) + _create_attrs = RequiredOptional(required=("key", "value")) + _update_attrs = RequiredOptional(required=("key", "value")) class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject): @@ -196,5 +196,9 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): _path = "/projects/%(project_id)s/pipeline_schedules" _obj_cls = ProjectPipelineSchedule _from_parent_attrs = {"project_id": "id"} - _create_attrs = (("description", "ref", "cron"), ("cron_timezone", "active")) - _update_attrs = (tuple(), ("description", "ref", "cron", "cron_timezone", "active")) + _create_attrs = RequiredOptional( + required=("description", "ref", "cron"), optional=("cron_timezone", "active") + ) + _update_attrs = RequiredOptional( + optional=("description", "ref", "cron", "cron_timezone", "active"), + ) |