@@ -340,10 +340,11 @@ def iot_hub_create(cmd, client, hub_name, resource_group_name, location=None, sk
340
340
sku = IotHubSkuInfo (name = sku , capacity = unit )
341
341
342
342
event_hub_dic = {}
343
- event_hub_dic ['events' ] = EventHubProperties (1 , partition_count )
344
- properties = IotHubProperties (None , None , event_hub_dic )
345
- hub_description = IotHubDescription (location , client .iot_hub_resource .config .subscription_id , resource_group_name ,
346
- sku , None , None , properties )
343
+ event_hub_dic ['events' ] = EventHubProperties (retention_time_in_days = 1 , partition_count = partition_count )
344
+ properties = IotHubProperties (event_hub_endpoints = event_hub_dic )
345
+ hub_description = IotHubDescription (location = location ,
346
+ sku = sku ,
347
+ properties = properties )
347
348
return client .iot_hub_resource .create_or_update (resource_group_name , hub_name , hub_description )
348
349
349
350
@@ -376,15 +377,15 @@ def iot_hub_delete(client, hub_name, resource_group_name=None):
376
377
377
378
378
379
# pylint: disable=inconsistent-return-statements
379
- def iot_hub_show_connection_string (client , hub_name = None , resource_group_name = None , policy_name = 'iothubowner' ,
380
+ def iot_hub_show_connection_string (client , hub_name , resource_group_name = None , policy_name = 'iothubowner' ,
380
381
key_type = KeyType .primary .value ):
381
382
if hub_name is None :
382
383
hubs = iot_hub_list (client , resource_group_name )
383
384
if hubs is None :
384
385
raise CLIError ("No IoT Hub found." )
385
386
386
387
def conn_str_getter (h ):
387
- return _get_single_hub_connection_string (client , h .name , h .resourcegroup , policy_name , key_type )
388
+ return _get_single_hub_connection_string (client , h .name , h .additional_properties [ ' resourcegroup' ] , policy_name , key_type )
388
389
return [{'name' : h .name , 'connectionString' : conn_str_getter (h )} for h in hubs ]
389
390
else :
390
391
resource_group_name = _ensure_resource_group_name (client , resource_group_name , hub_name )
@@ -438,23 +439,23 @@ def iot_hub_policy_create(client, hub_name, policy_name, permissions, resource_g
438
439
rights = _convert_perms_to_access_rights (permissions )
439
440
hub = iot_hub_get (client , hub_name , resource_group_name )
440
441
policies = []
441
- policies .extend (iot_hub_policy_list (client , hub_name , hub .resourcegroup ))
442
+ policies .extend (iot_hub_policy_list (client , hub_name , hub .additional_properties [ ' resourcegroup' ] ))
442
443
if _is_policy_existed (policies , policy_name ):
443
444
raise CLIError ("Policy {0} already existed." .format (policy_name ))
444
- policies .append (SharedAccessSignatureAuthorizationRule (policy_name , rights ))
445
+ policies .append (SharedAccessSignatureAuthorizationRule (key_name = policy_name , rights = rights ))
445
446
hub .properties .authorization_policies = policies
446
- return client .iot_hub_resource .create_or_update (hub .resourcegroup , hub_name , hub , {'IF-MATCH' : hub .etag })
447
+ return client .iot_hub_resource .create_or_update (hub .additional_properties [ ' resourcegroup' ] , hub_name , hub , {'IF-MATCH' : hub .etag })
447
448
448
449
449
450
def iot_hub_policy_delete (client , hub_name , policy_name , resource_group_name = None ):
450
451
import copy
451
452
hub = iot_hub_get (client , hub_name , resource_group_name )
452
- policies = iot_hub_policy_list (client , hub_name , hub .resourcegroup )
453
+ policies = iot_hub_policy_list (client , hub_name , hub .additional_properties [ ' resourcegroup' ] )
453
454
if not _is_policy_existed (copy .deepcopy (policies ), policy_name ):
454
455
raise CLIError ("Policy {0} not found." .format (policy_name ))
455
456
updated_policies = [p for p in policies if p .key_name .lower () != policy_name .lower ()]
456
457
hub .properties .authorization_policies = updated_policies
457
- return client .iot_hub_resource .create_or_update (hub .resourcegroup , hub_name , hub , {'IF-MATCH' : hub .etag })
458
+ return client .iot_hub_resource .create_or_update (hub .additional_properties [ ' resourcegroup' ] , hub_name , hub , {'IF-MATCH' : hub .etag })
458
459
459
460
460
461
def _is_policy_existed (policies , policy_name ):
@@ -655,7 +656,7 @@ def _ensure_location(cli_ctx, resource_group_name, location):
655
656
656
657
def _ensure_resource_group_name (client , resource_group_name , hub_name ):
657
658
if resource_group_name is None :
658
- return _get_iot_hub_by_name (client , hub_name ).resourcegroup
659
+ return _get_iot_hub_by_name (client , hub_name ).additional_properties [ ' resourcegroup' ]
659
660
return resource_group_name
660
661
661
662
0 commit comments