3232
3333
3434PERMISSIONS_OBJ_TYPES = [
35- 'catalog' , 'schema' , 'table' , 'storage-credential' , 'external-location'
35+ 'metastore' , ' catalog' , 'schema' , 'table' , 'storage-credential' , 'external-location'
3636]
3737
3838
39- def _get_perm_securable_name_and_type (catalog_name , schema_full_name , table_full_name ,
40- credential_name , location_name ):
41- if catalog_name :
39+ def _get_perm_securable_name_and_type (metastore_id , catalog_name , schema_full_name ,
40+ table_full_name , credential_name , location_name ):
41+ if metastore_id :
42+ return ('metastore' , metastore_id )
43+ elif catalog_name :
4244 return ('catalog' , catalog_name )
4345 elif schema_full_name :
4446 return ('schema' , schema_full_name )
@@ -52,6 +54,9 @@ def _get_perm_securable_name_and_type(catalog_name, schema_full_name, table_full
5254
5355@click .command (context_settings = CONTEXT_SETTINGS ,
5456 short_help = 'Get permissions on a securable.' )
57+ @click .option ('--metastore' , cls = OneOfOption , default = None ,
58+ one_of = PERMISSIONS_OBJ_TYPES ,
59+ help = 'ID of metastore of interest' )
5560@click .option ('--catalog' , cls = OneOfOption , default = None ,
5661 one_of = PERMISSIONS_OBJ_TYPES ,
5762 help = 'Name of catalog of interest' )
@@ -73,12 +78,12 @@ def _get_perm_securable_name_and_type(catalog_name, schema_full_name, table_full
7378@profile_option
7479@eat_exceptions
7580@provide_api_client
76- def get_permissions_cli (api_client , catalog , schema , table , storage_credential ,
81+ def get_permissions_cli (api_client , metastore , catalog , schema , table , storage_credential ,
7782 external_location , effective ):
7883 """
7984 Get permissions on a securable.
8085 """
81- sec_type , sec_name = _get_perm_securable_name_and_type (catalog , schema , table ,
86+ sec_type , sec_name = _get_perm_securable_name_and_type (metastore , catalog , schema , table ,
8287 storage_credential , external_location )
8388
8489 if effective :
@@ -90,6 +95,9 @@ def get_permissions_cli(api_client, catalog, schema, table, storage_credential,
9095
9196@click .command (context_settings = CONTEXT_SETTINGS ,
9297 short_help = 'update permissions on a securable.' )
98+ @click .option ('--metastore' , cls = OneOfOption , default = None ,
99+ one_of = PERMISSIONS_OBJ_TYPES ,
100+ help = 'ID of metastore of interest' )
93101@click .option ('--catalog' , cls = OneOfOption , default = None ,
94102 one_of = PERMISSIONS_OBJ_TYPES ,
95103 help = 'Name of catalog of interest' )
@@ -113,14 +121,14 @@ def get_permissions_cli(api_client, catalog, schema, table, storage_credential,
113121@profile_option
114122@eat_exceptions
115123@provide_api_client
116- def update_permissions_cli (api_client , catalog , schema , table , storage_credential ,
124+ def update_permissions_cli (api_client , metastore , catalog , schema , table , storage_credential ,
117125 external_location , json_file , json ):
118126 """
119127 Update permissions on a securable.
120128
121129 The public specification for the JSON request is in development.
122130 """
123- sec_type , sec_name = _get_perm_securable_name_and_type (catalog , schema , table ,
131+ sec_type , sec_name = _get_perm_securable_name_and_type (metastore , catalog , schema , table ,
124132 storage_credential , external_location )
125133
126134 json_cli_base (json_file , json ,
0 commit comments