2525LOG = logging .getLogger (__name__ )
2626
2727
28+ def _format_region (region ):
29+ columns = ('id' , 'description' , 'parent_region_id' )
30+ column_headers = ('region' , 'description' , 'parent_region' )
31+ return (
32+ column_headers ,
33+ utils .get_item_properties (region , columns ),
34+ )
35+
36+
2837class CreateRegion (command .ShowOne ):
2938 _description = _ ("Create new region" )
3039
@@ -50,18 +59,15 @@ def get_parser(self, prog_name):
5059 return parser
5160
5261 def take_action (self , parsed_args ):
53- identity_client = self .app .client_manager .identity
62+ identity_client = self .app .client_manager .sdk_connection . identity
5463
55- region = identity_client .regions . create (
64+ region = identity_client .create_region (
5665 id = parsed_args .region ,
57- parent_region = parsed_args .parent_region ,
66+ parent_region_id = parsed_args .parent_region ,
5867 description = parsed_args .description ,
5968 )
6069
61- region ._info ['region' ] = region ._info .pop ('id' )
62- region ._info ['parent_region' ] = region ._info .pop ('parent_region_id' )
63- region ._info .pop ('links' , None )
64- return zip (* sorted (region ._info .items ()))
70+ return _format_region (region )
6571
6672
6773class DeleteRegion (command .Command ):
@@ -78,11 +84,11 @@ def get_parser(self, prog_name):
7884 return parser
7985
8086 def take_action (self , parsed_args ):
81- identity_client = self .app .client_manager .identity
87+ identity_client = self .app .client_manager .sdk_connection . identity
8288 result = 0
8389 for i in parsed_args .region :
8490 try :
85- identity_client .regions . delete (i )
91+ identity_client .delete_region (i )
8692 except Exception as e :
8793 result += 1
8894 LOG .error (
@@ -115,7 +121,7 @@ def get_parser(self, prog_name):
115121 return parser
116122
117123 def take_action (self , parsed_args ):
118- identity_client = self .app .client_manager .identity
124+ identity_client = self .app .client_manager .sdk_connection . identity
119125
120126 kwargs = {}
121127 if parsed_args .parent_region :
@@ -124,7 +130,7 @@ def take_action(self, parsed_args):
124130 columns_headers = ('Region' , 'Parent Region' , 'Description' )
125131 columns = ('ID' , 'Parent Region Id' , 'Description' )
126132
127- data = identity_client .regions . list (** kwargs )
133+ data = identity_client .regions (** kwargs )
128134 return (
129135 columns_headers ,
130136 (
@@ -161,15 +167,15 @@ def get_parser(self, prog_name):
161167 return parser
162168
163169 def take_action (self , parsed_args ):
164- identity_client = self .app .client_manager .identity
170+ identity_client = self .app .client_manager .sdk_connection . identity
165171
166172 kwargs = {}
167173 if parsed_args .description :
168174 kwargs ['description' ] = parsed_args .description
169175 if parsed_args .parent_region :
170- kwargs ['parent_region ' ] = parsed_args .parent_region
176+ kwargs ['parent_region_id ' ] = parsed_args .parent_region
171177
172- identity_client .regions . update (parsed_args .region , ** kwargs )
178+ identity_client .update_region (parsed_args .region , ** kwargs )
173179
174180
175181class ShowRegion (command .ShowOne ):
@@ -185,13 +191,8 @@ def get_parser(self, prog_name):
185191 return parser
186192
187193 def take_action (self , parsed_args ):
188- identity_client = self .app .client_manager .identity
194+ identity_client = self .app .client_manager .sdk_connection . identity
189195
190- region = utils .find_resource (
191- identity_client .regions , parsed_args .region
192- )
196+ region = identity_client .get_region (parsed_args .region )
193197
194- region ._info ['region' ] = region ._info .pop ('id' )
195- region ._info ['parent_region' ] = region ._info .pop ('parent_region_id' )
196- region ._info .pop ('links' , None )
197- return zip (* sorted (region ._info .items ()))
198+ return _format_region (region )
0 commit comments