@@ -180,41 +180,46 @@ def _sanitize_data(self, data, action):
180
180
return new_data
181
181
182
182
183
- class CurrentUserEmail (GitlabObject ):
184
- _url = '/user/emails'
185
- canUpdate = False
186
- shortPrintAttr = 'email'
187
- requiredCreateAttrs = ['email' ]
183
+ class CurrentUserEmail (RESTObject ):
184
+ _short_print_attr = 'email'
188
185
189
186
190
- class CurrentUserEmailManager (BaseManager ):
191
- obj_cls = CurrentUserEmail
187
+ class CurrentUserEmailManager (RetrieveMixin , CreateMixin , DeleteMixin ,
188
+ RESTManager ):
189
+ _path = '/user/emails'
190
+ _obj_cls = CurrentUserEmail
191
+ _create_attrs = {'required' : ('email' , ), 'optional' : tuple ()}
192
192
193
193
194
- class CurrentUserKey (GitlabObject ):
195
- _url = '/user/keys'
196
- canUpdate = False
197
- shortPrintAttr = 'title'
198
- requiredCreateAttrs = ['title' , 'key' ]
194
+ class CurrentUserKey (RESTObject ):
195
+ _short_print_attr = 'title'
199
196
200
197
201
- class CurrentUserKeyManager (BaseManager ):
202
- obj_cls = CurrentUserKey
198
+ class CurrentUserKeyManager (RetrieveMixin , CreateMixin , DeleteMixin ,
199
+ RESTManager ):
200
+ _path = '/user/keys'
201
+ _obj_cls = CurrentUserKey
202
+ _create_attrs = {'required' : ('title' , 'key' ), 'optional' : tuple ()}
203
203
204
204
205
- class CurrentUser (GitlabObject ):
206
- _url = '/user'
207
- canList = False
208
- canCreate = False
209
- canUpdate = False
210
- canDelete = False
211
- shortPrintAttr = 'username'
212
- managers = (
213
- ('emails' , 'CurrentUserEmailManager' , [('user_id' , 'id' )]),
214
- ('keys' , 'CurrentUserKeyManager' , [('user_id' , 'id' )]),
205
+ class CurrentUser (RESTObject ):
206
+ _id_attr = None
207
+ _short_print_attr = 'username'
208
+ _managers = (
209
+ ('emails' , 'CurrentUserEmailManager' ),
210
+ ('keys' , 'CurrentUserKeyManager' ),
215
211
)
216
212
217
213
214
+ class CurrentUserManager (GetWithoutIdMixin , RESTManager ):
215
+ _path = '/user'
216
+ _obj_cls = CurrentUser
217
+
218
+ def credentials_auth (self , email , password ):
219
+ data = {'email' : email , 'password' : password }
220
+ server_data = self .gitlab .http_post ('/session' , post_data = data )
221
+ return CurrentUser (self , server_data )
222
+
218
223
class ApplicationSettings (SaveMixin , RESTObject ):
219
224
_id_attr = None
220
225
0 commit comments