@@ -383,6 +383,17 @@ def delete_share_cli(api_client, name):
383383
384384############## Recipient Commands ##############
385385
386+ def parse_recipient_custom_properties (custom_property_list ):
387+ custom_properties = []
388+ for property_str in custom_property_list :
389+ tokens = property_str .split ('=' , 2 )
390+ if len (tokens ) != 2 :
391+ raise ValueError ('Invalid format for property. '
392+ + 'The format should be <key>=<value>.' )
393+ custom_properties .append ({"key" : tokens [0 ], "value" : tokens [1 ]})
394+ return custom_properties
395+
396+
386397@click .command (context_settings = CONTEXT_SETTINGS ,
387398 short_help = 'Create a new recipient.' )
388399@click .option ('--name' , required = True , help = 'Name of new recipient.' )
@@ -394,16 +405,23 @@ def delete_share_cli(api_client, name):
394405 help = (
395406 'IP address in CIDR notation that is allowed to use delta sharing. '
396407 '(can be specified multiple times).' ))
408+ @click .option ('--property' , 'custom_property' , default = None , required = False , multiple = True ,
409+ help = (
410+ 'Properties of the recipient. Key and value should be provided '
411+ 'at the same time separated by an equal sign. '
412+ 'Example: --property country=US.' ))
397413@debug_option
398414@profile_option
399415@eat_exceptions
400416@provide_api_client
401- def create_recipient_cli (api_client , name , comment , sharing_id , allowed_ip_address ):
417+ def create_recipient_cli (api_client , name , comment , sharing_id ,
418+ allowed_ip_address , custom_property ):
402419 """
403420 Create a new recipient.
404421 """
405422 recipient_json = UnityCatalogApi (api_client ).create_recipient (
406- name , comment , sharing_id , allowed_ip_address )
423+ name , comment , sharing_id ,
424+ allowed_ip_address , parse_recipient_custom_properties (custom_property ))
407425 click .echo (mc_pretty_format (recipient_json ))
408426
409427
@@ -451,6 +469,12 @@ def get_recipient_cli(api_client, name):
451469 'IP address in CIDR notation that is allowed to use delta sharing '
452470 '(can be specified multiple times). Specify a single empty string to disable '
453471 'IP allowlist.' ))
472+ @click .option ('--property' , 'custom_property' , default = None , required = False , multiple = True ,
473+ help = (
474+ 'Properties of the recipient. Key and value should be provided '
475+ 'at the same time separated by an equal sign. '
476+ 'Example: --property country=US. '
477+ 'Specify a single empty string to remove all properties.' ))
454478@click .option ('--json-file' , default = None , type = click .Path (),
455479 help = json_file_help (method = 'PATCH' , path = '/recipients/{name}' ))
456480@click .option ('--json' , default = None , type = JsonClickType (),
@@ -460,21 +484,26 @@ def get_recipient_cli(api_client, name):
460484@eat_exceptions
461485@provide_api_client
462486def update_recipient_cli (api_client , name , new_name , comment , owner ,
463- allowed_ip_address , json_file , json ):
487+ allowed_ip_address , custom_property , json_file , json ):
464488 """
465489 Update a recipient.
466490
467491 The public specification for the JSON request is in development.
468492 """
469493 if ((new_name is not None ) or (comment is not None ) or (owner is not None ) or
470- len (allowed_ip_address ) > 0 ):
494+ len (allowed_ip_address ) or len ( custom_property ) > 0 ):
471495 if (json_file is not None ) or (json is not None ):
472496 raise ValueError ('Cannot specify JSON if any other update flags are specified' )
473497 data = {'name' : new_name , 'comment' : comment , 'owner' : owner }
474498 if len (allowed_ip_address ) > 0 :
475499 data ['ip_access_list' ] = {}
476500 if len (allowed_ip_address ) != 1 or allowed_ip_address [0 ] != '' :
477501 data ['ip_access_list' ]['allowed_ip_addresses' ] = allowed_ip_address
502+ if len (custom_property ) > 0 :
503+ data ['properties_kvpairs' ] = {}
504+ if len (custom_property ) != 1 or custom_property [0 ] != '' :
505+ data ['properties_kvpairs' ]['properties' ] = parse_recipient_custom_properties (
506+ custom_property )
478507 recipient_json = UnityCatalogApi (api_client ).update_recipient (name , data )
479508 click .echo (mc_pretty_format (recipient_json ))
480509 else :
0 commit comments