-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{KeyVault} Modify private link commands to align with storage #12457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -25,7 +25,8 @@ | |||||
| validate_principal, | ||||||
| validate_resource_group_name, validate_x509_certificate_chain, | ||||||
| secret_text_encoding_values, secret_binary_encoding_values, validate_subnet, | ||||||
| validate_vault_id, validate_sas_definition_id, validate_storage_account_id, validate_storage_disabled_attribute, | ||||||
| validate_vault_id, validate_sas_definition_id, | ||||||
| validate_storage_account_id, validate_storage_disabled_attribute, | ||||||
| validate_deleted_vault_name) | ||||||
|
|
||||||
| # CUSTOM CHOICE LISTS | ||||||
|
|
@@ -124,22 +125,21 @@ class CLIJsonWebKeyOperation(str, Enum): | |||||
| c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet) | ||||||
|
|
||||||
| with self.argument_context('keyvault private-endpoint-connection', min_api='2018-02-14') as c: | ||||||
| c.argument('approval_description', help='Comments for the approval.') | ||||||
| c.argument('description', help='Comments for the approval/rejection.') | ||||||
|
||||||
| c.argument('description', help='Comments for {} operation.'.format(item)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can consider my implementation in storage using string format for the help message to customize it in specific scenario.
c.argument('description', help='Comments for {} operation.'.format(item))
Good point.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,25 +166,38 @@ def validate_policy_permissions(ns): | |
| '--certificate-permissions --storage-permissions') | ||
|
|
||
|
|
||
| def validate_private_endpoint_connection_id(cmd, ns): | ||
| connection_id = ns.connection_id | ||
| connection_name = ns.private_endpoint_connection_name | ||
| def validate_pure_vault_id(cmd, ns): | ||
| identifier = ns.identifier | ||
| vault_name = ns.vault_name | ||
|
|
||
| if not connection_id: | ||
| if not all([connection_name, vault_name]): | ||
| raise argparse.ArgumentError( | ||
| None, 'specify both: --name/-n and --vault-name') | ||
| if not identifier: | ||
| if not vault_name: | ||
| raise CLIError('incorrect usage: [--id ID | --vault-name NAME]') | ||
| ns.resource_group_name = _get_resource_group_from_vault_name(cmd.cli_ctx, vault_name) | ||
| else: | ||
| if any([connection_name, vault_name]): | ||
| raise argparse.ArgumentError( | ||
| None, 'you don\'t need to specify --name/-n or --vault-name if --id is specified') | ||
|
|
||
| id_parts = connection_id.split('/') | ||
| ns.private_endpoint_connection_name = id_parts[-1] | ||
| ns.vault_name = id_parts[-3] | ||
| ns.resource_group_name = id_parts[-7] | ||
| if vault_name: | ||
| raise CLIError('you don\'t need to specify --vault-name if --id is specified') | ||
|
|
||
| id_parts = identifier.split('/') | ||
|
||
| ns.vault_name = id_parts[8] | ||
| ns.resource_group_name = id_parts[4] | ||
|
|
||
|
|
||
| def validate_private_endpoint_connection_id(cmd, ns): | ||
| if ns.connection_id: | ||
| from azure.cli.core.util import parse_proxy_resource_id | ||
| result = parse_proxy_resource_id(ns.connection_id) | ||
| ns.resource_group_name = result['resource_group'] | ||
| ns.vault_name = result['name'] | ||
| ns.private_endpoint_connection_name = result['child_name_1'] | ||
|
|
||
| if ns.vault_name and not ns.resource_group_name: | ||
| ns.resource_group_name = _get_resource_group_from_vault_name(cmd.cli_ctx, ns.vault_name) | ||
|
|
||
| if not all([ns.vault_name, ns.resource_group_name, ns.private_endpoint_connection_name]): | ||
| raise CLIError('incorrect usage: [--id ID | --name NAME --vault-name NAME]') | ||
|
|
||
| del ns.connection_id | ||
|
|
||
|
|
||
| def validate_principal(ns): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,8 @@ | |
| keyvault_client_private_link_resources_factory, keyvault_data_plane_factory) | ||
|
|
||
| from ._validators import ( | ||
| process_secret_set_namespace, process_certificate_cancel_namespace, validate_private_endpoint_connection_id) | ||
| process_secret_set_namespace, process_certificate_cancel_namespace, | ||
| validate_private_endpoint_connection_id) | ||
|
|
||
|
|
||
| # pylint: disable=too-many-locals, too-many-statements | ||
|
|
@@ -88,13 +89,15 @@ def load_command_table(self, _): | |
| validator=validate_private_endpoint_connection_id) | ||
| g.command('delete', 'delete', validator=validate_private_endpoint_connection_id) | ||
| g.show_command('show', 'get', validator=validate_private_endpoint_connection_id) | ||
| g.wait_command('wait', validator=validate_private_endpoint_connection_id) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have an additional wait command here, but I don't find you have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nice catch, I noticed this just after I submitted the PR... I will add |
||
|
|
||
| with self.command_group('keyvault private-link-resource', | ||
| kv_private_link_resources_sdk, | ||
| min_api='2018-02-14', | ||
| client_factory=keyvault_client_private_link_resources_factory, | ||
| is_preview=True) as g: | ||
| g.show_command('show', 'list_by_vault') | ||
| from azure.cli.core.commands.transform import gen_dict_to_list_transform | ||
| g.command('list', 'list_by_vault', transform=gen_dict_to_list_transform(key='value')) | ||
|
|
||
| # Data Plane Commands | ||
| with self.command_group('keyvault key', kv_data_sdk) as g: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1178,21 +1178,21 @@ def _update_private_endpoint_connection_status(cmd, client, resource_group_name, | |
|
|
||
|
|
||
| def approve_private_endpoint_connection(cmd, client, resource_group_name, vault_name, private_endpoint_connection_name, | ||
| approval_description=None, connection_id=None): | ||
| description=None, connection_id=None): | ||
| """Approve a private endpoint connection request for a Key Vault.""" | ||
|
|
||
| return _update_private_endpoint_connection_status( | ||
| cmd, client, resource_group_name, vault_name, private_endpoint_connection_name, is_approved=True, | ||
| description=approval_description, connection_id=connection_id | ||
| description=description, connection_id=connection_id | ||
| ) | ||
|
|
||
|
|
||
| def reject_private_endpoint_connection(cmd, client, resource_group_name, vault_name, private_endpoint_connection_name, | ||
| rejection_description=None, connection_id=None): | ||
| description=None, connection_id=None): | ||
| """Reject a private endpoint connection request for a Key Vault.""" | ||
|
|
||
| return _update_private_endpoint_connection_status( | ||
| cmd, client, resource_group_name, vault_name, private_endpoint_connection_name, is_approved=False, | ||
| description=rejection_description, connection_id=connection_id | ||
| description=description, connection_id=connection_id | ||
|
||
| ) | ||
| # endregion | ||
Uh oh!
There was an error while loading. Please reload this page.