@@ -207,9 +207,9 @@ class GitlabObject(object):
207207 #: Attributes that are optional when creating a new object.
208208 optionalCreateAttrs = []
209209 #: Attributes that are required when updating an object.
210- requiredUpdateAttrs = None
210+ requiredUpdateAttrs = []
211211 #: Attributes that are optional when updating an object.
212- optionalUpdateAttrs = None
212+ optionalUpdateAttrs = []
213213 #: Whether the object ID is required in the GET url.
214214 getRequiresId = True
215215 #: List of managers to create.
@@ -219,10 +219,15 @@ class GitlabObject(object):
219219 #: Attribute to use as ID when displaying the object.
220220 shortPrintAttr = None
221221
222- def _data_for_gitlab (self , extra_parameters = {}):
222+ def _data_for_gitlab (self , extra_parameters = {}, update = False ):
223223 data = {}
224- for attribute in itertools .chain (self .requiredCreateAttrs ,
225- self .optionalCreateAttrs ):
224+ if update and (self .requiredUpdateAttrs or self .optionalUpdateAttrs ):
225+ attributes = itertools .chain (self .requiredUpdateAttrs ,
226+ self .optionalUpdateAttrs )
227+ else :
228+ attributes = itertools .chain (self .requiredCreateAttrs ,
229+ self .optionalCreateAttrs )
230+ for attribute in attributes :
226231 if hasattr (self , attribute ):
227232 data [attribute ] = getattr (self , attribute )
228233
@@ -506,7 +511,7 @@ class User(GitlabObject):
506511 'confirm' ]
507512 managers = [('keys' , UserKeyManager , [('user_id' , 'id' )])]
508513
509- def _data_for_gitlab (self , extra_parameters = {}):
514+ def _data_for_gitlab (self , extra_parameters = {}, update = False ):
510515 if hasattr (self , 'confirm' ):
511516 self .confirm = str (self .confirm ).lower ()
512517 return super (User , self )._data_for_gitlab (extra_parameters )
@@ -549,6 +554,28 @@ def Key(self, id=None, **kwargs):
549554 return CurrentUserKey ._get_list_or_object (self .gitlab , id , ** kwargs )
550555
551556
557+ class ApplicationSettings (GitlabObject ):
558+ _url = '/application/settings'
559+ _id_in_update_url = False
560+ optionalUpdateAttrs = ['after_sign_out_path' , 'default_branch_protection' ,
561+ 'default_project_visibility' ,
562+ 'default_projects_limit' ,
563+ 'default_snippet_visibility' , 'gravatar_enabled' ,
564+ 'home_page_url' , 'restricted_signup_domains' ,
565+ 'restricted_visibility_levels' ,
566+ 'session_expire_delay' , 'sign_in_text' ,
567+ 'signin_enabled' , 'signup_enabled' ,
568+ 'twitter_sharing_enabled' ,
569+ 'user_oauth_applications' ]
570+ canList = False
571+ canCreate = False
572+ canDelete = False
573+
574+
575+ class ApplicationSettingsManager (BaseManager ):
576+ obj_cls = ApplicationSettings
577+
578+
552579class GroupMember (GitlabObject ):
553580 _url = '/groups/%(group_id)s/members'
554581 canGet = 'from_list'
@@ -784,7 +811,7 @@ class ProjectIssue(GitlabObject):
784811 managers = [('notes' , ProjectIssueNoteManager ,
785812 [('project_id' , 'project_id' ), ('issue_id' , 'id' )])]
786813
787- def _data_for_gitlab (self , extra_parameters = {}):
814+ def _data_for_gitlab (self , extra_parameters = {}, update = False ):
788815 # Gitlab-api returns labels in a json list and takes them in a
789816 # comma separated list.
790817 if hasattr (self , "labels" ):
0 commit comments