Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
00f92e8
add rmpl and pla operation for cli
tjegbejimba Apr 14, 2022
4498064
fix merge conflicts
tjegbejimba Apr 14, 2022
412cfe8
add help section for private links
tjegbejimba Apr 18, 2022
7720169
update test class for privateLinks
tjegbejimba Apr 20, 2022
b0f5f59
add more tests for rmpl and pla
tjegbejimba Apr 22, 2022
c168e43
add rmpl test recordings
tjegbejimba Apr 22, 2022
890e12d
add test recordings for pla
tjegbejimba Apr 22, 2022
fa18172
fix linter issues
tjegbejimba Apr 22, 2022
310ec97
remove workaournd from custom.py
tjegbejimba Apr 23, 2022
07caa6a
Merge branch 'dev' into arm-privateLinks
tjegbejimba Apr 23, 2022
d4b2b6c
Revert "fix linter issues"
tjegbejimba Apr 28, 2022
e926c54
Merge branch 'dev' into arm-privateLinks
tjegbejimba Apr 28, 2022
6ba5f80
Update src/azure-cli/azure/cli/command_modules/resource/_params.py
tjegbejimba Apr 29, 2022
3cc537b
Update src/azure-cli/azure/cli/command_modules/resource/custom.py
tjegbejimba Apr 29, 2022
6cd6bdf
add servicenames and fix formatting
tjegbejimba Apr 29, 2022
d200f2d
fix service names
tjegbejimba Apr 29, 2022
5b42bd1
add newlines
tjegbejimba Apr 29, 2022
2e240ba
fix service names
tjegbejimba Apr 29, 2022
40bc665
fix help
tjegbejimba Apr 29, 2022
0676cfa
fix --privatelink param
tjegbejimba Apr 29, 2022
6e224f8
add newlines
tjegbejimba Apr 29, 2022
9d459b2
fix public network access param
tjegbejimba Apr 29, 2022
bccadcc
fix public network access param
tjegbejimba Apr 29, 2022
fe4543f
fix help
tjegbejimba Apr 29, 2022
31bb467
update recordings and delete pla command
tjegbejimba May 2, 2022
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
6 changes: 6 additions & 0 deletions src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
MGMT_RESOURCE_SUBSCRIPTIONS = ('azure.mgmt.resource.subscriptions', 'SubscriptionClient')
MGMT_RESOURCE_DEPLOYMENTSCRIPTS = ('azure.mgmt.resource.deploymentscripts', 'DeploymentScriptsClient')
MGMT_RESOURCE_TEMPLATESPECS = ('azure.mgmt.resource.templatespecs', 'TemplateSpecsClient')
MGMT_RESOURCE_PRIVATELINKS = ('azure.mgmt.resource.privatelinks', 'ResourcePrivateLinkClient')
MGMT_MONITOR = ('azure.mgmt.monitor', 'MonitorManagementClient')
MGMT_MSI = ('azure.mgmt.msi', 'ManagedServiceIdentityClient')
DATA_KEYVAULT = ('azure.keyvault', 'KeyVaultClient')
Expand Down Expand Up @@ -169,6 +170,7 @@ def default_api_version(self):
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2019-11-01',
ResourceType.MGMT_RESOURCE_DEPLOYMENTSCRIPTS: '2020-10-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2021-05-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_NETWORK_DNS: '2018-05-01',
ResourceType.MGMT_KEYVAULT: SDKProfile('2021-04-01-preview', {
'vaults': '2021-06-01-preview'
Expand Down Expand Up @@ -268,6 +270,7 @@ def default_api_version(self):
ResourceType.MGMT_RESOURCE_RESOURCES: '2019-10-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
'classic_administrators': '2015-06-01',
Expand Down Expand Up @@ -310,6 +313,7 @@ def default_api_version(self):
ResourceType.MGMT_RESOURCE_RESOURCES: '2018-05-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
Expand Down Expand Up @@ -347,6 +351,7 @@ def default_api_version(self):
ResourceType.MGMT_RESOURCE_RESOURCES: '2018-02-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
Expand All @@ -373,6 +378,7 @@ def default_api_version(self):
ResourceType.MGMT_RESOURCE_POLICY: '2015-10-01-preview',
ResourceType.MGMT_RESOURCE_RESOURCES: '2016-02-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def _resource_templatespecs_client_factory(cli_ctx, **_):
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_TEMPLATESPECS)


def _resource_privatelinks_client_factory(cli_ctx, **_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from azure.cli.core.profiles import ResourceType
return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_PRIVATELINKS)


def cf_resource_groups(cli_ctx, _):
return _resource_client_factory(cli_ctx).resource_groups

Expand Down Expand Up @@ -150,3 +156,11 @@ def cf_hierarchy_settings(cli_ctx, _):

def cf_resource_templatespecs(cli_ctx, _):
return _resource_templatespecs_client_factory(cli_ctx).template_specs


def cf_resource_privatelinkassociations(cli_ctx, _):
return _resource_privatelinks_client_factory(cli_ctx).private_link_association


def cf_resource_resourcemanagementprivatelinks(cli_ctx, _):
return _resource_privatelinks_client_factory(cli_ctx).resource_management_private_link
76 changes: 76 additions & 0 deletions src/azure-cli/azure/cli/command_modules/resource/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,3 +2758,79 @@
type: command
short-summary: List out all available versions of Bicep CLI.
"""

helps['resourcemanagement'] = """
type: group
short-summary: resourcemanagement CLI command group.
"""
helps['resourcemanagement private-link'] = """
type: group
short-summary: resourcemanagement private-link management on a resource.
"""
helps['private-link'] = """
type: group
short-summary: private-link association CLI command group.
"""
helps['private-link association'] = """
type: group
short-summary: private-link association management on a resource.
"""

helps['resourcemanagement private-link create'] = """
type: command
short-summary: Create a resource management group private link.
examples:
- name: Create a resource management group private link.
text: az resourcemanagement private-link create --resource-group testRG --name TestRMPL --location WestUS
"""
helps['resourcemanagement private-link show'] = """
type: command
short-summary: Get resource management private.
examples:
- name: Get single resource management private link.
text: az resourcemanagement private-link show --resource-group testRG --name TestRMPL
"""
helps['resourcemanagement private-link list'] = """
type: command
short-summary: Get all the resource management private links at scope.
examples:
- name: List all resource management private links in a subscription.
text: az resourcemanagement private-link list
- name: List all resource management private links in a resource group.
text: az resourcemanagement private-link list --resource-group testRG
"""
helps['resourcemanagement private-link delete'] = """
type: command
short-summary: Delete a resource management private link.
examples:
- name: Delete a resource management private link.
text: az resourcemanagement private-link delete --resource-group TestRG --name testRMPL
"""
helps['private-link association create'] = """
type: command
short-summary: Create a PrivateLinkAssociation.
examples:
- name: Create a PrivateLinkAssociation.
text: az private-link association create --management-group-id TestMG --name testPLA --privatelink testPL --public-network-access enabled
"""
helps['private-link association show'] = """
type: command
short-summary: Get a private link association.
examples:
- name: Get a single private link association.
text: az private-link association show --management-group-id TestMG --name testPLA
"""
helps['private-link association list'] = """
type: command
short-summary: Get a private link association for a management group scope.
examples:
- name: Get a private link association for a management group scope.
text: az private-link association list --management-group-id TestMG
"""
helps['private-link association delete'] = """
type: command
short-summary: Delete a PrivateLinkAssociation.
examples:
- name: Delete a PrivateLinkAssociation.
text: az private-link association delete --management-group-id TestMG --name testPLA
"""
50 changes: 49 additions & 1 deletion src/azure-cli/azure/cli/command_modules/resource/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def load_arguments(self, _):
from azure.mgmt.resource.locks.models import LockLevel
from azure.mgmt.resource.managedapplications.models import ApplicationLockLevel
from azure.mgmt.resource.policy.models import (ExemptionCategory, EnforcementMode)
from azure.cli.core.commands.validators import get_default_location_from_resource_group

from azure.cli.core.api import get_subscription_id_list
from azure.cli.core.commands.parameters import (
Expand Down Expand Up @@ -97,7 +98,8 @@ def load_arguments(self, _):
help="A path to a uiFormDefinition file in the file system")

bicep_target_platform_type = CLIArgumentType(options_list=['--target-platform', '-t'],
arg_type=get_enum_type(["win-x64", "linux-musl-x64", "linux-x64", "osx-x64"]),
arg_type=get_enum_type(
["win-x64", "linux-musl-x64", "linux-x64", "osx-x64"]),
help="The platform the Bicep CLI will be running on. Set this to skip automatic platform detection if it does not work properly.")

_PROVIDER_HELP_TEXT = 'the resource namespace, aka \'provider\''
Expand Down Expand Up @@ -663,3 +665,49 @@ def load_arguments(self, _):

with self.argument_context('bicep upgrade') as c:
c.argument('target_platform', arg_type=bicep_target_platform_type)

with self.argument_context('resourcemanagement private-link create') as c:
c.argument('resource_group', arg_type=resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the resource management private link.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group,
help='the region to create the resource management private link')

with self.argument_context('resourcemanagement private-link show') as c:
c.argument('resource_group', arg_type=resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the resource management private link.')

with self.argument_context('resourcemanagement private-link list') as c:
c.argument('resource_group', arg_type=resource_group_name_type,
help='The name of the resource group.')

with self.argument_context('resourcemanagement private-link delete') as c:
c.argument('resource_group', arg_type=resource_group_name_type,
help='The name of the resource group.')
c.argument('name', options_list=[
'--name', '-n'], help='The name of the resource management private link.')

with self.argument_context('private-link association create') as c:
c.argument('management_group_id', arg_type=management_group_id_type)
c.argument('name', options_list=[
'--name', '-n'], help='The name of the private link association')
c.argument('privatelink', options_list=[
'--privatelink', '-p'], help='The name of the private link')
c.argument('public_network_access', options_list=['--public-network-access', '-a'], arg_type=get_enum_type(
['enabled', 'disabled']), help='restrict traffic to private link')

with self.argument_context('private-link association show') as c:
c.argument('management_group_id', arg_type=management_group_id_type)
c.argument('name', options_list=[
'--name', '-n'], help='The name of the private link association')

with self.argument_context('private-link association list') as c:
c.argument('management_group_id', arg_type=management_group_id_type)

with self.argument_context('private-link association delete') as c:
c.argument('management_group_id', arg_type=management_group_id_type)
c.argument('name', options_list=[
'--name', '-n'], help='The name of the private link association')
26 changes: 25 additions & 1 deletion src/azure-cli/azure/cli/command_modules/resource/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from azure.cli.command_modules.resource._client_factory import (
cf_resource_groups, cf_providers, cf_features, cf_feature_registrations, cf_tags, cf_deployments,
cf_deployment_operations, cf_policy_definitions, cf_policy_set_definitions, cf_policy_exemptions, cf_resource_links,
cf_resource_deploymentscripts, cf_resource_managedapplications, cf_resource_managedappdefinitions, cf_management_groups, cf_management_groups_mixin, cf_management_group_subscriptions, cf_management_group_entities, cf_hierarchy_settings, cf_resource_templatespecs)
cf_resource_deploymentscripts, cf_resource_managedapplications, cf_resource_managedappdefinitions, cf_management_groups, cf_management_groups_mixin, cf_management_group_subscriptions, cf_management_group_entities, cf_hierarchy_settings, cf_resource_templatespecs, cf_resource_resourcemanagementprivatelinks, cf_resource_privatelinkassociations)
from azure.cli.command_modules.resource._validators import (
process_deployment_create_namespace, process_ts_create_or_update_namespace, _validate_template_spec, _validate_template_spec_out,
process_assign_identity_namespace, process_assignment_create_namespace)
Expand Down Expand Up @@ -44,6 +44,18 @@
exception_handler=managementgroups_exception_handler
)

resource_resourcemanagementprivatelink_sdk = CliCommandType(
operations_tmpl='azure.mgmt.resource.privatelinks.operations#ResourceManagementPrivateLinkOperations.{}',
client_factory=cf_resource_resourcemanagementprivatelinks,
resource_type=ResourceType.MGMT_RESOURCE_PRIVATELINKS
)

resource_privatelinksassociation_sdk = CliCommandType(
operations_tmpl='azure.mgmt.resource.privatelinks.operations#PrivateLinkAssociationOperations.{}',
client_factory=cf_resource_privatelinkassociations,
resource_type=ResourceType.MGMT_RESOURCE_PRIVATELINKS
)


# Resource group commands
def transform_resource_group_list(result):
Expand Down Expand Up @@ -532,3 +544,15 @@ def load_command_table(self, _):
g.custom_command('publish', 'publish_bicep_file')
g.custom_command('version', 'show_bicep_cli_version')
g.custom_command('list-versions', 'list_bicep_cli_versions')

with self.command_group('resourcemanagement private-link', resource_resourcemanagementprivatelink_sdk, resource_type=ResourceType.MGMT_RESOURCE_PRIVATELINKS) as g:
g.custom_command('create', 'create_resourcemanager_privatelink')
g.custom_show_command('show', 'get_resourcemanager_privatelink')
g.custom_command('list', 'list_resourcemanager_privatelink')
g.custom_command('delete', 'delete_resourcemanager_privatelink', confirmation=True)

with self.command_group('private-link association', resource_privatelinksassociation_sdk, resource_type=ResourceType.MGMT_RESOURCE_PRIVATELINKS) as g:
g.custom_command('create', 'create_private_link_association')
g.custom_show_command('show', 'get_private_link_association')
g.custom_command('list', 'list_private_link_association')
g.custom_command('delete', 'delete_private_link_association', confirmation=True)
53 changes: 52 additions & 1 deletion src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from azure.cli.command_modules.resource._client_factory import (
_resource_client_factory, _resource_policy_client_factory, _resource_lock_client_factory,
_resource_links_client_factory, _resource_deploymentscripts_client_factory, _authorization_management_client, _resource_managedapps_client_factory, _resource_templatespecs_client_factory)
_resource_links_client_factory, _resource_deploymentscripts_client_factory, _authorization_management_client, _resource_managedapps_client_factory, _resource_templatespecs_client_factory, _resource_privatelinks_client_factory)
from azure.cli.command_modules.resource._validators import _parse_lock_id

from azure.core.pipeline.policies import SansIOHTTPPolicy
Expand Down Expand Up @@ -3702,3 +3702,54 @@ def show_bicep_cli_version(cmd):

def list_bicep_cli_versions(cmd):
return get_bicep_available_release_tags()


def create_resourcemanager_privatelink(
cmd, resource_group, name, location):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
ResourceManagementPrivateLinkLocation = cmd.get_models(
'ResourceManagementPrivateLinkLocation')
resource_management_private_link_location = ResourceManagementPrivateLinkLocation(
location=location)
return rcf.resource_management_private_link.put(resource_group, name, resource_management_private_link_location)


def get_resourcemanager_privatelink(cmd, resource_group, name):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
return rcf.resource_management_private_link.get(resource_group, name)


def list_resourcemanager_privatelink(cmd, resource_group=None):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
if resource_group:
return rcf.resource_management_private_link.list_by_resource_group(resource_group)
return rcf.resource_management_private_link.list()


def delete_resourcemanager_privatelink(cmd, resource_group, name):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
return rcf.resource_management_private_link.delete(resource_group, name)


def create_private_link_association(cmd, management_group_id, name, privatelink, public_network_access):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
PrivateLinkProperties, PrivateLinkObject = cmd.get_models(
'PrivateLinkAssociationProperties', 'PrivateLinkAssociationObject')
pl = PrivateLinkObject(properties=PrivateLinkProperties(
private_link=privatelink, public_network_access=public_network_access))
return rcf.private_link_association.put(group_id=management_group_id, pla_id=name, parameters=pl)


def get_private_link_association(cmd, management_group_id, name):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
return rcf.private_link_association.get(group_id=management_group_id, pla_id=name)


def delete_private_link_association(cmd, management_group_id, name):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
return rcf.private_link_association.delete(group_id=management_group_id, pla_id=name)


def list_private_link_association(cmd, management_group_id):
rcf = _resource_privatelinks_client_factory(cmd.cli_ctx)
return rcf.private_link_association.list(group_id=management_group_id)
Loading