Skip to content
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

[Synapse] az synapse: Add for managed private endpoints commands #19117

Merged
merged 6 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,4 @@ pip.log
*.exe

az_command_coverage.txt

Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,23 @@ def cf_synapse_notebook(cli_ctx, workspace_name):

def cf_synapse_spark_pool(cli_ctx, workspace_name):
return cf_synapse_client_artifacts_factory(cli_ctx, workspace_name).big_data_pools


def cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name):
from azure.synapse.managedprivateendpoints import ManagedPrivateEndpointsClient
from azure.cli.core._profile import Profile
from azure.cli.core.commands.client_factory import get_subscription_id
subscription_id = get_subscription_id(cli_ctx)
profile = Profile(cli_ctx=cli_ctx)
cred, _, _ = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.synapse_analytics_resource_id,
subscription_id=subscription_id
)
return ManagedPrivateEndpointsClient(
credential=cred,
endpoint='{}{}{}'.format("https://", workspace_name, cli_ctx.cloud.suffixes.synapse_analytics_endpoint)
)


def cf_synapse_managedprivateendpoints_factory(cli_ctx, workspace_name):
return cf_synapse_client_managedprivateendpoints_factory(cli_ctx, workspace_name).managed_private_endpoints
46 changes: 46 additions & 0 deletions src/azure-cli/azure/cli/command_modules/synapse/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,3 +1678,49 @@
az synapse integration-runtime-node get-ip-address --workspace-name testsynapseworkspace --resource-group rg \\
--name selfhostedintegrationruntime --node-name testnode
"""

helps['synapse managed-private-endpoints'] = """
type: group
short-summary: Manage synapse managed private endpoints.
"""

helps['synapse managed-private-endpoints show'] = """
type: command
short-summary: Get a synapse managed private endpoints.
examples:
- name: Get a synapse managed private endpoints.
text: |-
az synapse managed-private-endpoints show --workspace-name testsynapseworkspace \\
--pe-name testendpointname
"""

helps['synapse managed-private-endpoints create'] = """
type: command
short-summary: Create a synapse managed private endpoints.
examples:
- name: Create a synapse managed private endpoints.
text: |-
az synapse managed-private-endpoints create --workspace-name testsynapseworkspace \\
--pe-name testendpointname \\
--resource-id '/subscriptions/yoursub/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/myStorageAccount' \\
--group-Id blob
"""

helps['synapse managed-private-endpoints list'] = """
type: command
short-summary: List synapse managed private endpoints in a workspace.
examples:
- name: List a synapse managed private endpoints.
text: |-
az synapse managed-private-endpoints list --workspace-name testsynapseworkspace
"""

helps['synapse managed-private-endpoints delete'] = """
type: command
short-summary: delete synapse managed private endpoints in a workspace.
examples:
- name: Delete a synapse managed private endpoints.
text: |-
az synapse managed-private-endpoints delete --workspace-name testsynapseworkspace \\
--pe-name testendpointname
"""
13 changes: 13 additions & 0 deletions src/azure-cli/azure/cli/command_modules/synapse/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,3 +732,16 @@ def load_arguments(self, _):
help='Enable or disable the self-hosted integration runtime auto-update.')
c.argument('update_delay_offset',
help='The time of the day for the self-hosted integration runtime auto-update.')

# synapse managed private endpoints
for scope in ['show', 'create', 'delete']:
with self.argument_context('synapse managed-private-endpoints ' + scope) as c:
c.argument('workspace_name', arg_type=workspace_name_arg_type, id_part='name')
c.argument('managed_private_endpoint_name', options_list=['--pe-name'], help='The managed private endpoint name.')

with self.argument_context('synapse managed-private-endpoints list') as c:
c.argument('workspace_name', arg_type=workspace_name_arg_type)

with self.argument_context('synapse managed-private-endpoints create') as c:
c.argument('private_Link_Resource_Id', options_list=['--resource-id'], help='The ARM resource ID of the resource to which the managed private endpoint is created. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}')
c.argument('group_Id', help='The groupId to which the managed private endpoint is created')
12 changes: 12 additions & 0 deletions src/azure-cli/azure/cli/command_modules/synapse/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ def get_custom_sdk(custom_module, client_factory):
operation_tmpl='azure.synapse.artifacts.operations#NotebookOperations.{}',
client_factory=None)

synapse_managed_private_endpoints_sdk = CliCommandType(
operations_tmpl='azure.synapse.managedprivateendpoints.operations#ManagedPrivateEndpoints.{}',
client_factory=None)

# Management Plane Commands --Workspace
with self.command_group('synapse workspace', command_type=synapse_workspace_sdk,
custom_command_type=get_custom_sdk('workspace', cf_synapse_client_workspace_factory),
Expand Down Expand Up @@ -478,5 +482,13 @@ def get_custom_sdk(custom_module, client_factory):
g.custom_command('export', 'export_notebook')
g.custom_command('delete', 'delete_notebook', confirmation=True, supports_no_wait=True)

# Data Plane Commands --Managed private endpoints operations
with self.command_group('synapse managed-private-endpoints', synapse_managed_private_endpoints_sdk,
custom_command_type=get_custom_sdk('managedprivateendpoints', None)) as g:
g.custom_show_command('show', 'get_Managed_private_endpoints')
g.custom_command('create', 'create_Managed_private_endpoints')
g.custom_command('list', 'list_Managed_private_endpoints')
g.custom_command('delete', 'delete_Managed_private_endpoints', confirmation=True)

with self.command_group('synapse', is_preview=True):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long, too-many-statements, too-many-locals
from azure.cli.core.util import sdk_no_wait
from .._client_factory import cf_synapse_managedprivateendpoints_factory


def create_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name, private_Link_Resource_Id, group_Id, no_wait=False):
client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name)
property_files = {}
property_files['privateLinkResourceId'] = private_Link_Resource_Id
property_files['groupId'] = group_Id
properties = property_files
managed_virtual_network_name = "default"
return sdk_no_wait(no_wait, client.create,
managed_private_endpoint_name, managed_virtual_network_name, properties)


def get_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name):
client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name)
managed_virtual_network_name = "default"
return client.get(managed_private_endpoint_name, managed_virtual_network_name)


def list_Managed_private_endpoints(cmd, workspace_name):
client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name)
managed_virtual_network_name = "default"
return client.list(managed_virtual_network_name)


def delete_Managed_private_endpoints(cmd, workspace_name, managed_private_endpoint_name, no_wait=False):
client = cf_synapse_managedprivateendpoints_factory(cmd.cli_ctx, workspace_name)
managed_virtual_network_name = "default"
return sdk_no_wait(no_wait, client.delete, managed_private_endpoint_name, managed_virtual_network_name)
Loading