| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c11bebd commit e5438c6
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -551,7 +551,8 @@ def update(self, obj, **kwargs): | |||
| 551 | 551 | if missing: | |
| 552 | 552 | raise GitlabUpdateError('Missing attribute(s): %s' % | |
| 553 | 553 | ", ".join(missing)) | |
| 554 | - url = self._construct_url(id_=obj.id, obj=obj, parameters=params) | ||
| 554 | + obj_id = params[obj.idAttr] if obj._id_in_update_url else None | ||
| 555 | + url = self._construct_url(id_=obj_id, obj=obj, parameters=params) | ||
| 555 | 556 | headers = self._create_headers(content_type="application/json") | |
| 556 | 557 | ||
| 557 | 558 | # build data that can really be sent to server | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,7 +89,7 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 89 | 89 | required=True) | |
| 90 | 90 | [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | |
| 91 | 91 | required=True) | |
| 92 | - for x in cls.requiredGetAttrs] | ||
| 92 | + for x in cls.requiredGetAttrs if x != cls.idAttr] | ||
| 93 | 93 | ||
| 94 | 94 | elif action_name == CREATE: | |
| 95 | 95 | [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | |
@@ -109,7 +109,7 @@ def _populate_sub_parser_by_class(cls, sub_parser): | |||
| 109 | 109 | else cls.requiredCreateAttrs) | |
| 110 | 110 | [sub_parser_action.add_argument("--%s" % x.replace('_', '-'), | |
| 111 | 111 | required=True) | |
| 112 | - for x in attrs] | ||
| 112 | + for x in attrs if x != cls.idAttr] | ||
| 113 | 113 | ||
| 114 | 114 | attrs = (cls.optionalUpdateAttrs | |
| 115 | 115 | if cls.optionalUpdateAttrs is not None | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,6 +178,7 @@ class GitlabObject(object): | |||
| 178 | 178 | # plural | |
| 179 | 179 | _urlPlural = None | |
| 180 | 180 | _id_in_delete_url = True | |
| 181 | + _id_in_update_url = True | ||
| 181 | 182 | _returnClass = None | |
| 182 | 183 | _constructorTypes = None | |
| 183 | 184 | ||
@@ -936,6 +937,7 @@ class ProjectMilestoneManager(BaseManager): | |||
| 936 | 937 | class ProjectLabel(GitlabObject): | |
| 937 | 938 | _url = '/projects/%(project_id)s/labels' | |
| 938 | 939 | _id_in_delete_url = False | |
| 940 | + _id_in_update_url = False | ||
| 939 | 941 | canGet = 'from_list' | |
| 940 | 942 | requiredUrlAttrs = ['project_id'] | |
| 941 | 943 | idAttr = 'name' | |
@@ -1031,6 +1033,17 @@ class ProjectTriggerManager(BaseManager): | |||
| 1031 | 1033 | obj_cls = ProjectTrigger | |
| 1032 | 1034 | ||
| 1033 | 1035 | ||
| 1036 | + class ProjectVariable(GitlabObject): | ||
| 1037 | + _url = '/projects/%(project_id)s/variables' | ||
| 1038 | + idAttr = 'key' | ||
| 1039 | + requiredUrlAttrs = ['project_id'] | ||
| 1040 | + requiredCreateAttrs = ['key', 'value'] | ||
| 1041 | + | ||
| 1042 | + | ||
| 1043 | + class ProjectVariableManager(BaseManager): | ||
| 1044 | + obj_cls = ProjectVariable | ||
| 1045 | + | ||
| 1046 | + | ||
| 1034 | 1047 | class Project(GitlabObject): | |
| 1035 | 1048 | _url = '/projects' | |
| 1036 | 1049 | _constructorTypes = {'owner': 'User', 'namespace': 'Group'} | |
@@ -1059,6 +1072,7 @@ class Project(GitlabObject): | |||
| 1059 | 1072 | ('snippets', ProjectSnippetManager, [('project_id', 'id')]), | |
| 1060 | 1073 | ('tags', ProjectTagManager, [('project_id', 'id')]), | |
| 1061 | 1074 | ('triggers', ProjectTriggerManager, [('project_id', 'id')]), | |
| 1075 | + ('variables', ProjectVariableManager, [('project_id', 'id')]), | ||
| 1062 | 1076 | ] | |
| 1063 | 1077 | ||
| 1064 | 1078 | def Branch(self, id=None, **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ pip install -rrequirements.txt | |||
| 41 | 41 | pip install -e . | |
| 42 | 42 | ||
| 43 | 43 | # NOTE(gpocentek): the first call might fail without a little delay | |
| 44 | - sleep 5 | ||
| 44 | + sleep 20 | ||
| 45 | 45 | ||
| 46 | 46 | set -e | |
| 47 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,6 @@ $VENV_CMD $VENV | |||
| 34 | 34 | pip install -rrequirements.txt | |
| 35 | 35 | pip install -e . | |
| 36 | 36 | ||
| 37 | - sleep 10 | ||
| 37 | + sleep 20 | ||
| 38 | 38 | ||
| 39 | 39 | python $(dirname $0)/python_test.py | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,3 +158,12 @@ | |||
| 158 | 158 | assert(len(admin_project.triggers.list()) == 1) | |
| 159 | 159 | tr1 = admin_project.triggers.get(tr1.token) | |
| 160 | 160 | tr1.delete() | |
| 161 | + | ||
| 162 | + # variables | ||
| 163 | + v1 = admin_project.variables.create({'key': 'key1', 'value': 'value1'}) | ||
| 164 | + assert(len(admin_project.variables.list()) == 1) | ||
| 165 | + v1.value = 'new_value1' | ||
| 166 | + v1.save() | ||
| 167 | + v1 = admin_project.variables.get(v1.key) | ||
| 168 | + assert(v1.value == 'new_value1') | ||
| 169 | + v1.delete() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments