diff --git a/src/azure-cli-core/azure/cli/core/profiles/_shared.py b/src/azure-cli-core/azure/cli/core/profiles/_shared.py index a205d4e2f5e..22ec4a729da 100644 --- a/src/azure-cli-core/azure/cli/core/profiles/_shared.py +++ b/src/azure-cli-core/azure/cli/core/profiles/_shared.py @@ -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') @@ -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' @@ -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', @@ -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', { @@ -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', { @@ -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', diff --git a/src/azure-cli/azure/cli/command_modules/resource/_client_factory.py b/src/azure-cli/azure/cli/command_modules/resource/_client_factory.py index 9a1a4a987f0..df1ad18a9a4 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_client_factory.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_client_factory.py @@ -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 @@ -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 diff --git a/src/azure-cli/azure/cli/command_modules/resource/_help.py b/src/azure-cli/azure/cli/command_modules/resource/_help.py index 5abb8f6d57b..aea35058195 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_help.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_help.py @@ -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 +""" diff --git a/src/azure-cli/azure/cli/command_modules/resource/_params.py b/src/azure-cli/azure/cli/command_modules/resource/_params.py index da5497c061a..56fbce70ac5 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/_params.py +++ b/src/azure-cli/azure/cli/command_modules/resource/_params.py @@ -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 ( @@ -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\'' @@ -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') diff --git a/src/azure-cli/azure/cli/command_modules/resource/commands.py b/src/azure-cli/azure/cli/command_modules/resource/commands.py index 61f5a257a8a..7b0dbd986fb 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/commands.py +++ b/src/azure-cli/azure/cli/command_modules/resource/commands.py @@ -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) @@ -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): @@ -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) diff --git a/src/azure-cli/azure/cli/command_modules/resource/custom.py b/src/azure-cli/azure/cli/command_modules/resource/custom.py index 61efecbbe4b..29a1595c4ac 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/custom.py +++ b/src/azure-cli/azure/cli/command_modules/resource/custom.py @@ -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 @@ -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) diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_privatelinkassociation.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_privatelinkassociation.yaml new file mode 100644 index 00000000000..afde0bec2d9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_privatelinkassociation.yaml @@ -0,0 +1,179 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '366' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:57:31 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: '{"properties": {"privateLink": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002", + "publicNetworkAccess": "enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association create + Connection: + - keep-alive + Content-Length: + - '268' + Content-Type: + - application/json + ParameterSetName: + - -m -n -p --public-network-access + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}' + headers: + cache-control: + - no-cache + content-length: + - '701' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:57:32 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:57:33 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -m -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:57:33 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_resourcemanagementprivatelink.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_resourcemanagementprivatelink.yaml new file mode 100644 index 00000000000..6ed8682bb86 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_create_resourcemanagementprivatelink.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '366' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:43 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_create000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 21:28:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_privatelinkassociation.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_privatelinkassociation.yaml new file mode 100644 index 00000000000..16d9966bf1f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_privatelinkassociation.yaml @@ -0,0 +1,179 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '366' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:58:08 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: '{"properties": {"privateLink": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002", + "publicNetworkAccess": "enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association create + Connection: + - keep-alive + Content-Length: + - '268' + Content-Type: + - application/json + ParameterSetName: + - -m -n -p --public-network-access + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management//managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management//managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management//managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}' + headers: + cache-control: + - no-cache + content-length: + - '701' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:58:09 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:58:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -m -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management//managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:58:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_resourcemanagementprivatelink.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_resourcemanagementprivatelink.yaml new file mode 100644 index 00000000000..4cb68b16980 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_delete_resourcemanagementprivatelink.yaml @@ -0,0 +1,90 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '366' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_delete000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 21:28:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_privatelinkassociation.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_privatelinkassociation.yaml new file mode 100644 index 00000000000..31bfd0a893a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_privatelinkassociation.yaml @@ -0,0 +1,223 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:47:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: '{"properties": {"privateLink": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002", + "publicNetworkAccess": "enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association create + Connection: + - keep-alive + Content-Length: + - '265' + Content-Type: + - application/json + ParameterSetName: + - -m -n -p --public-network-access + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}' + headers: + cache-control: + - no-cache + content-length: + - '698' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:47:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association show + Connection: + - keep-alive + ParameterSetName: + - -m -n + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}' + headers: + cache-control: + - no-cache + content-length: + - '698' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 22:47:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:47:47 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -m -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 22:47:47 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_resourcemanagementprivatelink.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_resourcemanagementprivatelink.yaml new file mode 100644 index 00000000000..a04e80005d8 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_get_resourcemanagementprivatelink.yaml @@ -0,0 +1,134 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link show + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '363' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_get000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 21:28:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_privatelinkassociation.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_privatelinkassociation.yaml new file mode 100644 index 00000000000..e959e7f8c64 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_privatelinkassociation.yaml @@ -0,0 +1,223 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '364' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 23:15:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: '{"properties": {"privateLink": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002", + "publicNetworkAccess": "enabled"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association create + Connection: + - keep-alive + Content-Length: + - '266' + Content-Type: + - application/json + ParameterSetName: + - -m -n -p --public-network-access + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}' + headers: + cache-control: + - no-cache + content-length: + - '699' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 23:15:27 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association list + Connection: + - keep-alive + ParameterSetName: + - -m + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations?api-version=2020-05-01 + response: + body: + string: '{"value":[{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ARMPrivateLinkRG/providers/Microsoft.Authorization/resourceManagementPrivateLinks/ResourceManagementPrivateLink","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/cb0b487e-7810-572e-97db-383217eb80f2","type":"Microsoft.Authorization/privateLinkAssociations","name":"cb0b487e-7810-572e-97db-383217eb80f2"},{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/PartnerTestSetup/providers/Microsoft.Authorization/resourceManagementPrivateLinks/partnerTestRMPL","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/cb0b487e-7810-572e-97db-383217eb80f3","type":"Microsoft.Authorization/privateLinkAssociations","name":"cb0b487e-7810-572e-97db-383217eb80f3"},{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRMPLCreate/providers/Microsoft.Authorization/resourceManagementPrivateLinks/ContosoRMPL","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/75b9d43e-fa6e-5fc3-ab44-4a8a374bdffc","type":"Microsoft.Authorization/privateLinkAssociations","name":"75b9d43e-fa6e-5fc3-ab44-4a8a374bdffc"},{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nrp-validate/providers/Microsoft.Authorization/resourceManagementPrivateLinks/demo-privatelinkforarm","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/2f40b296-a15f-5a8c-be55-53ca3be52d2e","type":"Microsoft.Authorization/privateLinkAssociations","name":"2f40b296-a15f-5a8c-be55-53ca3be52d2e"},{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/nrp-validate/providers/Microsoft.Authorization/resourceManagementPrivateLinks/DeepDiveRMPL","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/7afcb623-ff23-591c-8cdd-57f5357711f4","type":"Microsoft.Authorization/privateLinkAssociations","name":"7afcb623-ff23-591c-8cdd-57f5357711f4"},{"properties":{"privateLink":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","publicNetworkAccess":"Enabled","tenantId":"00000000-0000-0000-0000-000000000000","scope":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000"},"id":"/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001","type":"Microsoft.Authorization/privateLinkAssociations","name":"88888888-0000-0000-0000-000000000001"}]}' + headers: + cache-control: + - no-cache + content-length: + - '4050' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 23:15:28 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 23:15:29 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - private-link association delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -m -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/privateLinkAssociations/88888888-0000-0000-0000-000000000001?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 23:15:30 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_resourcemanagementprivatelink.yaml b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_resourcemanagementprivatelink.yaml new file mode 100644 index 00000000000..570fe99a6d1 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_list_resourcemanagementprivatelink.yaml @@ -0,0 +1,222 @@ +interactions: +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '364' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:43 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: '{"location": "westus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g -n -l + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000003?api-version=2020-05-01 + response: + body: + string: '{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000003","name":"privatelink000003","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}' + headers: + cache-control: + - no-cache + content-length: + - '364' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:44 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link list + Connection: + - keep-alive + ParameterSetName: + - -g + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks?api-version=2020-05-01 + response: + body: + string: '{"value":[{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002","name":"privatelink000002","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"},{"properties":{"privateEndpointConnections":[]},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000003","name":"privatelink000003","type":"Microsoft.Authorization/resourceManagementPrivateLinks","location":"westus"}]}' + headers: + cache-control: + - no-cache + content-length: + - '741' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 22 Apr 2022 21:28:45 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding,Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000002?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 21:28:46 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - resourcemanagement private-link delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -n --yes + User-Agent: + - AZURECLI/2.35.0 azsdk-python-azure-mgmt-resource/21.0.0 Python/3.10.0 (Windows-10-10.0.22000-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_resourcemanager_privatelink_list000001/providers/Microsoft.Authorization/resourceManagementPrivateLinks/privatelink000003?api-version=2020-05-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 22 Apr 2022 21:28:48 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py index 4659a3334df..4d8b54066ea 100644 --- a/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py +++ b/src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource.py @@ -4106,5 +4106,189 @@ def test_create_template_specs_bicep(self, resource_group, resource_group_locati self.cmd('ts delete --template-spec {template_spec_id} --yes') +class ResourceManagementPrivateLinkTest(ScenarioTest): + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_get', location='westus') + def test_get_resourcemanagementprivatelink(self, resource_group, resource_group_location): + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30) + }) + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}') + self.cmd('resourcemanagement private-link show -g {rg} -n {n}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_create', location='westus') + def test_create_resourcemanagementprivatelink(self, resource_group, resource_group_location): + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30) + }) + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_delete', location='westus') + def test_delete_resourcemanagementprivatelink(self, resource_group, resource_group_location): + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30) + }) + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_list', location='westus') + def test_list_resourcemanagementprivatelink(self, resource_group, resource_group_location): + self.kwargs.update({ + 'loc': resource_group_location, + 'name1': self.create_random_name('privatelink', 30), + 'name2': self.create_random_name('privatelink', 30) + }) + self.cmd('resourcemanagement private-link create -g {rg} -n {name1} -l {loc}') + self.cmd('resourcemanagement private-link create -g {rg} -n {name2} -l {loc}') + self.cmd('resourcemanagement private-link list -g {rg}', checks=[ + self.check('value[0].name', '{name1}'), + self.check('value[1].name', '{name2}'), + self.check('value[0].location', '{loc}'), + self.check('value[1].location', '{loc}') + ]) + self.cmd('resourcemanagement private-link delete -g {rg} -n {name1} --yes', checks=self.is_empty()) + self.cmd('resourcemanagement private-link delete -g {rg} -n {name2} --yes', checks=self.is_empty()) + +class PrivateLinkAssociationTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_get', location='westus') + def test_get_privatelinkassociation(self, resource_group, resource_group_location): + account = self.cmd("account show").get_output_in_json() + tenant_id = account["tenantId"] + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30), + 'mg': tenant_id, + 'pla': self.create_guid(), + 'sub': self.get_subscription_id() + }) + + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.kwargs['pl'] = '/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{n}'.format( + **self.kwargs) + + + self.cmd('private-link association create -m {mg} -n {pla} --privatelink {pl} --public-network-access enabled', checks=[]) + + self.cmd('private-link association show -m {mg} -n {pla}', checks=[ + self.check('name', '{pla}'), + self.check('properties.publicNetworkAccess', 'Enabled'), + self.check('properties.privateLink', '{pl}') + ]) + + # clean + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + self.cmd('private-link association delete -m {mg} -n {pla} --yes', self.is_empty()) + + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_create', location='westus') + def test_create_privatelinkassociation(self, resource_group, resource_group_location): + account = self.cmd("account show").get_output_in_json() + tenant_id = account["tenantId"] + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30), + 'mg': tenant_id, + 'pla': self.create_guid(), + 'sub': self.get_subscription_id() + }) + + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.kwargs['pl'] = '/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{n}'.format( + **self.kwargs) + + self.cmd('private-link association create -m {mg} -n {pla} --privatelink {pl} --public-network-access enabled', checks=[ + self.check('name', '{pla}'), + self.check('properties.publicNetworkAccess', 'Enabled'), + self.check('properties.privateLink', '{pl}') + ]) + + + # clean + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + self.cmd('private-link association delete -m {mg} -n {pla} --yes', self.is_empty()) + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_delete', location='westus') + def test_delete_privatelinkassociation(self, resource_group, resource_group_location): + account = self.cmd("account show").get_output_in_json() + tenant_id = account["tenantId"] + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30), + 'mg': tenant_id, + 'pla': self.create_guid(), + 'sub': self.get_subscription_id() + }) + + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.kwargs['pl'] = '/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{n}'.format( + **self.kwargs) + + + self.cmd('private-link association create -m {mg} -n {pla} --privatelink {pl} --public-network-access enabled', checks=[ + self.check('name', '{pla}'), + self.check('properties.publicNetworkAccess', 'Enabled'), + self.check('properties.privateLink', '{pl}') + ]) + + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + + # clean + self.cmd('private-link association delete -m {mg} -n {pla} --yes', self.is_empty()) + + @ResourceGroupPreparer(name_prefix='cli_test_resourcemanager_privatelink_list', location='westus') + def test_list_privatelinkassociation(self, resource_group, resource_group_location): + account = self.cmd("account show").get_output_in_json() + tenant_id = account["tenantId"] + self.kwargs.update({ + 'loc': resource_group_location, + 'n': self.create_random_name('privatelink', 30), + 'mg': tenant_id, + 'pla': self.create_guid(), + 'sub': self.get_subscription_id() + }) + + self.cmd('resourcemanagement private-link create -g {rg} -n {n} -l {loc}', checks=[ + self.check('name', '{n}'), + self.check('location', '{loc}') + ]) + self.kwargs['pl'] = '/subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Authorization/resourceManagementPrivateLinks/{n}'.format( + **self.kwargs) + + self.cmd('private-link association create -m {mg} -n {pla} --privatelink {pl} --public-network-access enabled', checks=[]) + + self.cmd('private-link association list -m {mg}', checks=[ + self.check('value[5].name', '{pla}'), + self.check('value[5].properties.publicNetworkAccess', 'Enabled'), + self.check('value[5].properties.privateLink', '{pl}') + ]) + + + # clean + self.cmd('resourcemanagement private-link delete -g {rg} -n {n} --yes', checks=self.is_empty()) + self.cmd('private-link association delete -m {mg} -n {pla} --yes', self.is_empty()) + if __name__ == '__main__': unittest.main() diff --git a/src/azure-cli/service_name.json b/src/azure-cli/service_name.json index bf185410b13..a79c95c7156 100644 --- a/src/azure-cli/service_name.json +++ b/src/azure-cli/service_name.json @@ -394,6 +394,11 @@ "AzureServiceName": "Azure Resource Manager", "URL": "https://docs.microsoft.com/azure/azure-resource-manager/management/azure-services-resource-providers" }, + { + "Command": "az private-link", + "AzureServiceName": "Azure Resource Manager", + "URL": "https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/create-private-link-access-portal" + }, { "Command": "az redis", "AzureServiceName": "Azure Cache for Redis", @@ -419,6 +424,11 @@ "AzureServiceName": "Azure Resource Manager", "URL": "https://docs.microsoft.com/azure/azure-resource-manager/management/overview" }, + { + "Command": "az resourcemanagement", + "AzureServiceName": "Azure Resource Manager", + "URL": "https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/create-private-link-access-portal" + }, { "Command": "az rest", "AzureServiceName": "Azure CLI",