File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2709,3 +2709,22 @@ def delete_bypass_code_by_id(self, bypass_code_id):
27092709 path = '/admin/v1/bypass_codes/' + bypass_code_id
27102710 response = self .json_api_call ('DELETE' , path , {})
27112711 return response
2712+
2713+ def sync_user (self , username , directory_key ):
2714+ """ Syncronize a single user immediately with a specified directory.
2715+
2716+ Params:
2717+ username (str) - The username of the user to be synchronized.
2718+ directory_key (str) - The unique id of the directory.
2719+
2720+ Notes:
2721+ Raises RuntimeError on error.
2722+ """
2723+ params = {
2724+ 'username' : username ,
2725+ }
2726+ directory_key = six .moves .urllib .parse .quote_plus (directory_key )
2727+ path = (
2728+ '/admin/v1/users/directorysync/{directory_key}/syncuser' ).format (
2729+ directory_key = directory_key )
2730+ return self .json_api_call ('POST' , path , params )
Original file line number Diff line number Diff line change @@ -160,3 +160,14 @@ def test_update_user(self):
160160 'alias3' : ['alias3' ],
161161 'alias4' : ['alias4' ],
162162 })
163+
164+ def test_sync_user (self ):
165+ """ Test to synchronize a single user in a directory for a username.
166+ """
167+ response = self .client .sync_user ('foo' , 'test_dir_key' )
168+ self .assertEqual (response ['method' ], 'POST' )
169+ self .assertEqual (response ['uri' ],
170+ '/admin/v1/users/directorysync/test_dir_key/syncuser' )
171+ self .assertEqual (
172+ util .params_to_dict (response ['body' ]),
173+ {'username' : ['foo' ], 'account_id' : [self .client .account_id ]})
You can’t perform that action at this time.
0 commit comments