From 9b6be1a64143c2e385ba0747e2afa1a00fe06766 Mon Sep 17 00:00:00 2001 From: Zeng Taoxu <96050289+ZengTaoxu@users.noreply.github.com> Date: Tue, 23 Aug 2022 15:59:26 +0800 Subject: [PATCH] [NetworkManager] `az network manager connection management-group`: Reopen the set of commands (#5260) * Update test_network_manager_static_member_crud.yaml * Update _params.py * fix various broken commands * fix network manager connection update command * add test recordings for network manager connections * Update test_network_manager_scope_connection.yaml Co-authored-by: Jared Gorthy --- src/network-manager/HISTORY.rst | 4 + .../azext_network_manager/_help.py | 104 ++--- .../azext_network_manager/_params.py | 78 ++-- .../azext_network_manager/azext_metadata.json | 1 - .../azext_network_manager/commands.py | 20 +- .../azext_network_manager/custom.py | 102 +++-- ...network_manager_connection_management.yaml | 391 ++++++++++++++++++ .../tests/latest/test_network_scenario.py | 32 ++ src/network-manager/setup.py | 2 +- 9 files changed, 581 insertions(+), 153 deletions(-) create mode 100644 src/network-manager/azext_network_manager/tests/latest/recordings/test_network_manager_connection_management.yaml diff --git a/src/network-manager/HISTORY.rst b/src/network-manager/HISTORY.rst index 49c25ee65b9..cca22bf5823 100644 --- a/src/network-manager/HISTORY.rst +++ b/src/network-manager/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +0.5.2 ++++++ +* 'az network manager connection management-group': reopen the set of commands. + 0.5.1 +++++ * 'az network manager group': remove parameters '--member-type' and '--display-name' diff --git a/src/network-manager/azext_network_manager/_help.py b/src/network-manager/azext_network_manager/_help.py index 3a7089de2ad..0269a8238c6 100644 --- a/src/network-manager/azext_network_manager/_help.py +++ b/src/network-manager/azext_network_manager/_help.py @@ -778,56 +778,60 @@ short-summary: Manage connection with network manager """ -# helps['network manager connection management-group'] = """ -# type: group -# short-summary: Manage management-group connection with network -# """ -# -# helps['network manager connection management-group list'] = """ -# type: command -# short-summary: "List all network manager connections created by this management group." -# examples: -# - name: List management-group connections in a network manager -# text: |- -# az network manager connection management-group list --management-group-id "testManagementGroupId" \ -# --resource-group "rg1" -# """ -# -# helps['network manager connection management-group show'] = """ -# type: command -# short-summary: "Get a specified connection created by this management group." -# examples: -# - name: Get network manager connection management-group -# text: |- -# az network manager connection management-group show --management-group-id "testManagementGroupId" \ -# --connection-name "testNetworkManagerConnection" --resource-group "rg1" -# """ -# -# helps['network manager connection management-group create'] = """ -# type: command -# short-summary: Create a connection to a cross tenant network manager" -# examples: -# - name: Create network manager connection management-group -# text: |- -# az network manager connection management-group create --management-group-id "testManagementGroupId" \ -# --connection-name "testNetworkManagerConnection" --resource-group "rg1" --network-manager "testNetworkManagerId" \ -# --description "A sample policy" -# """ -# -# helps['network manager connection management-group update'] = """ -# type: command -# short-summary: "Update a connection to a cross tenant network manager" -# """ -# -# helps['network manager connection management-group delete'] = """ -# type: command -# short-summary: "Delete specified pending connection created by this management group." -# examples: -# - name: Delete network manager connection management-group -# text: |- -# az network manager connection management-group delete --management-group-id "testManagementGroupId" \ -# --connection-name "testNetworkManagerConnection" --resource-group "rg1" -# """ +helps['network manager connection management-group'] = """ + type: group + short-summary: Manage management-group connection with network +""" + +helps['network manager connection management-group list'] = """ + type: command + short-summary: "List all network manager connections created by this management group." + examples: + - name: List management-group connections in a network manager + text: |- + az network manager connection management-group list --management-group-id "testManagementGroupId" +""" + +helps['network manager connection management-group show'] = """ + type: command + short-summary: "Get a specified connection created by this management group." + examples: + - name: Get network manager connection management-group + text: |- + az network manager connection management-group show --management-group-id "testManagementGroupId" \ +--connection-name "testNetworkManagerConnection" +""" + +helps['network manager connection management-group create'] = """ + type: command + short-summary: Create a connection to a cross tenant network manager" + examples: + - name: Create network manager connection management-group + text: |- + az network manager connection management-group create --management-group-id "testManagementGroupId" \ +--connection-name "testNetworkManagerConnection" --network-manager "testNetworkManagerId" \ +--description "A sample policy" +""" + +helps['network manager connection management-group update'] = """ + type: command + short-summary: "Update a connection to a cross tenant network manager" + examples: + - name: Update network manager connection management-group + text: |- + az network manager connection management-group update --management-group-id "testManagementGroupId" \ +--connection-name "testNetworkManagerConnection" --description "My Test Network Manager Connection" +""" + +helps['network manager connection management-group delete'] = """ + type: command + short-summary: "Delete specified pending connection created by this management group." + examples: + - name: Delete network manager connection management-group + text: |- + az network manager connection management-group delete --management-group-id "testManagementGroupId" \ +--connection-name "testNetworkManagerConnection" +""" helps['network manager scope-connection'] = """ type: group diff --git a/src/network-manager/azext_network_manager/_params.py b/src/network-manager/azext_network_manager/_params.py index b910731a9c0..581a8de3a74 100644 --- a/src/network-manager/azext_network_manager/_params.py +++ b/src/network-manager/azext_network_manager/_params.py @@ -576,45 +576,45 @@ def load_arguments(self, _): c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, help='The name of the network manager connection.', id_part='name') -# with self.argument_context('network manager connection management-group create') as c: -# c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, -# help='The name of the network manager connection.') -# c.argument('management_group_id', type=str, -# help='The management group id which uniquely identify the microsoft azure management group') -# c.argument('network_manager_id', options_list=['--network-manager', '--network-manager-id'], type=str, -# help='the name or id of the network manager.', validator=validate_network_manager) -# c.argument('description', type=str, help='A description of the scope connection.') -# -# with self.argument_context('network manager connection management-group update') as c: -# c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, -# help='The name of the network manager connection.', id_part='child_name_1') -# c.argument('management_group_id', type=str, help='The management group id which uniquely identify ' -# 'the microsoft azure management group', id_part='name') -# c.argument('network_manager_id', options_list=['--network-manager', '--network-manager-id'], type=str, -# help='the name or id of the network manager.', validator=validate_network_manager) -# c.argument('description', type=str, help='A description of the scope connection.') -# c.ignore('parameters') -# -# with self.argument_context('network manager connection management-group list') as c: -# c.argument('management_group_id', type=str, -# help='The management group id which uniquely identify the microsoft azure management group') -# c.argument('top', type=int, help='An optional query parameter which specifies the maximum number of records to ' -# 'be returned by the server.') -# c.argument('skip_token', type=str, help='SkipToken is only used if a previous operation returned a partial ' -# 'result. If a previous response contains a nextLink element, the value of the nextLink element will ' -# 'include a skipToken parameter that specifies a starting point to use for subsequent calls.') -# -# with self.argument_context('network manager connection management-group show') as c: -# c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, -# help='The name of the network manager connection.', id_part='name') -# c.argument('management_group_id', type=str, -# help='The management group id which uniquely identify the microsoft azure management group') -# -# with self.argument_context('network manager connection management-group delete') as c: -# c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, -# help='The name of the network manager connection.', id_part='name') -# c.argument('management_group_id', type=str, -# help='The management group id which uniquely identify the microsoft azure management group') + with self.argument_context('network manager connection management-group create') as c: + c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, + help='The name of the network manager connection.') + c.argument('management_group_id', type=str, + help='The management group id which uniquely identify the microsoft azure management group') + c.argument('network_manager_id', options_list=['--network-manager', '--network-manager-id'], type=str, + help='the name or id of the network manager.') + c.argument('description', type=str, help='A description of the scope connection.') + + with self.argument_context('network manager connection management-group update') as c: + c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, + help='The name of the network manager connection.', id_part='child_name_1') + c.argument('management_group_id', type=str, help='The management group id which uniquely identify ' + 'the microsoft azure management group', required=True, id_part='name') + c.argument('network_manager_id', options_list=['--network-manager', '--network-manager-id'], type=str, + help='the name or id of the network manager.') + c.argument('description', type=str, help='A description of the scope connection.') + c.ignore('parameters') + + with self.argument_context('network manager connection management-group list') as c: + c.argument('management_group_id', type=str, + help='The management group id which uniquely identify the microsoft azure management group') + c.argument('top', type=int, help='An optional query parameter which specifies the maximum number of records to ' + 'be returned by the server.') + c.argument('skip_token', type=str, help='SkipToken is only used if a previous operation returned a partial ' + 'result. If a previous response contains a nextLink element, the value of the nextLink element will ' + 'include a skipToken parameter that specifies a starting point to use for subsequent calls.') + + with self.argument_context('network manager connection management-group show') as c: + c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, + help='The name of the network manager connection.', id_part='name') + c.argument('management_group_id', type=str, + help='The management group id which uniquely identify the microsoft azure management group') + + with self.argument_context('network manager connection management-group delete') as c: + c.argument('network_manager_connection_name', options_list=['--name', '-n', '--connection-name'], type=str, + help='The name of the network manager connection.', id_part='name') + c.argument('management_group_id', type=str, + help='The management group id which uniquely identify the microsoft azure management group') with self.argument_context('network manager scope-connection create') as c: c.argument('resource_group_name', resource_group_name_type) diff --git a/src/network-manager/azext_network_manager/azext_metadata.json b/src/network-manager/azext_network_manager/azext_metadata.json index 30fdaf614ee..3695b0d7077 100644 --- a/src/network-manager/azext_network_manager/azext_metadata.json +++ b/src/network-manager/azext_network_manager/azext_metadata.json @@ -1,4 +1,3 @@ { - "azext.isPreview": true, "azext.minCliCoreVersion": "2.15.0" } \ No newline at end of file diff --git a/src/network-manager/azext_network_manager/commands.py b/src/network-manager/azext_network_manager/commands.py index ae74c997a03..9070749764a 100644 --- a/src/network-manager/azext_network_manager/commands.py +++ b/src/network-manager/azext_network_manager/commands.py @@ -81,10 +81,10 @@ def load_command_table(self, _): client_factory=cf_subscriptionconnection ) -# network_managementgroupconnection = CliCommandType( -# operations_tmpl='azext_network_manager.vendored_sdks.operations._management_group_network_manager_connections_operations#ManagementGroupNetworkManagerConnectionsOperations.{}', -# client_factory=cf_managementgroupconnection -# ) + network_managementgroupconnection = CliCommandType( + operations_tmpl='azext_network_manager.vendored_sdks.operations._operations#ManagementGroupNetworkManagerConnectionsOperations.{}', + client_factory=cf_managementgroupconnection + ) with self.command_group('network manager', network_networkmanager, client_factory=cf_networkmanager) as g: g.custom_command('create', 'network_manager_create') @@ -171,12 +171,12 @@ def load_command_table(self, _): g.custom_show_command('show', 'network_manager_connection_subscription_show') g.custom_command('delete', 'network_manager_connection_subscription_delete', confirmation=True) -# with self.command_group('network manager connection management-group', network_managementgroupconnection, client_factory=cf_managementgroupconnection) as g: -# g.custom_command('create', 'network_manager_connection_management_group_create') -# g.generic_update_command('update', setter_arg_name='connection_management_group', custom_func_name='network_manager_connection_management_group_update') -# g.custom_command('list', 'network_manager_connection_management_group_list') -# g.custom_show_command('show', 'network_manager_connection_management_group_show') -# g.custom_command('delete', 'network_manager_connection_management_group_delete', confirmation=True) + with self.command_group('network manager connection management-group', network_managementgroupconnection, client_factory=cf_managementgroupconnection) as g: + g.custom_command('create', 'network_manager_connection_management_group_create') + g.generic_update_command('update', custom_func_name='network_manager_connection_management_group_update') + g.custom_command('list', 'network_manager_connection_management_group_list') + g.custom_show_command('show', 'network_manager_connection_management_group_show') + g.custom_command('delete', 'network_manager_connection_management_group_delete', confirmation=True) with self.command_group('network manager scope-connection', network_scopeconnection, client_factory=cf_scopeconnection) as g: g.custom_command('create', 'network_manager_scope_connection_create') diff --git a/src/network-manager/azext_network_manager/custom.py b/src/network-manager/azext_network_manager/custom.py index c4f8b452eda..7e6709a9ead 100644 --- a/src/network-manager/azext_network_manager/custom.py +++ b/src/network-manager/azext_network_manager/custom.py @@ -113,9 +113,9 @@ def network_manager_commit_post(cmd, parameters['target_locations'] = target_locations parameters['configuration_ids'] = configuration_ids parameters['commit_type'] = commit_type - return client.post(resource_group_name=resource_group_name, - network_manager_name=network_manager_name, - parameters=parameters) + return client.begin_post(resource_group_name=resource_group_name, + network_manager_name=network_manager_name, + parameters=parameters) def network_manager_deploy_status_list(cmd, @@ -366,7 +366,10 @@ def network_manager_group_create(client, if_match=None, description=None): parameters = {} - parameters['description'] = description + if description is not None: + parameters['description'] = description + else: + parameters['description'] = "" return client.create_or_update(resource_group_name=resource_group_name, network_manager_name=network_manager_name, network_group_name=network_group_name, @@ -1025,54 +1028,49 @@ def network_manager_connection_subscription_delete(client, return client.delete(network_manager_connection_name=network_manager_connection_name) -# def network_manager_connection_management_group_list(client, -# top=None, -# skip_token=None): -# return client.list(top=top, -# skip_token=skip_token) -# -# -# def network_manager_connection_management_group_create(client, -# resource_group_name, -# network_manager_connection_name, -# management_group_id, -# network_manager_id, -# description=None): -# parameters = {} -# parameters['description'] = description -# parameters['network_manager_id'] = network_manager_id -# return client.create_or_update(resource_group_name=resource_group_name, -# network_manager_connection_name=network_manager_connection_name, -# management_group_id=management_group_id, -# parameters=parameters) -# -# -# def network_manager_connection_management_group_update(instance, -# management_group_id, -# description=None): -# if description is not None: -# instance.description = description -# if management_group_id is not None: -# instance.management_group_id = management_group_id -# return instance -# -# -# def network_manager_connection_management_group_show(client, -# resource_group_name, -# network_manager_connection_name, -# management_group_id): -# return client.get(resource_group_name=resource_group_name, -# network_manager_connection_name=network_manager_connection_name, -# management_group_id=management_group_id) -# -# -# def network_manager_connection_management_group_delete(client, -# resource_group_name, -# network_manager_connection_name, -# management_group_id): -# return client.begin_delete(resource_group_name=resource_group_name, -# network_manager_connection_name=network_manager_connection_name, -# management_group_id=management_group_id) +def network_manager_connection_management_group_list(client, + management_group_id, + top=None, + skip_token=None): + return client.list(management_group_id=management_group_id, + top=top, + skip_token=skip_token) + + +def network_manager_connection_management_group_create(client, + network_manager_connection_name, + management_group_id, + network_manager_id, + description=None): + parameters = {} + parameters['description'] = description + parameters['network_manager_id'] = network_manager_id + return client.create_or_update(network_manager_connection_name=network_manager_connection_name, + management_group_id=management_group_id, + parameters=parameters) + + +def network_manager_connection_management_group_update(instance, + management_group_id, + network_manager_connection_name, + description=None): + if description is not None: + instance.description = description + return instance + + +def network_manager_connection_management_group_show(client, + network_manager_connection_name, + management_group_id): + return client.get(network_manager_connection_name=network_manager_connection_name, + management_group_id=management_group_id) + + +def network_manager_connection_management_group_delete(client, + network_manager_connection_name, + management_group_id): + return client.delete(network_manager_connection_name=network_manager_connection_name, + management_group_id=management_group_id) def network_manager_scope_connection_list(client, diff --git a/src/network-manager/azext_network_manager/tests/latest/recordings/test_network_manager_connection_management.yaml b/src/network-manager/azext_network_manager/tests/latest/recordings/test_network_manager_connection_management.yaml new file mode 100644 index 00000000000..1f1b2886fab --- /dev/null +++ b/src/network-manager/azext_network_manager/tests/latest/recordings/test_network_manager_connection_management.yaml @@ -0,0 +1,391 @@ +interactions: +- request: + body: '{"location": "eastus2euap", "properties": {"description": "My Test Network + Manager", "networkManagerScopes": {"subscriptions": ["/subscriptions/00000000-0000-0000-0000-000000000000"]}, + "networkManagerScopeAccesses": ["SecurityAdmin"]}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager create + Connection: + - keep-alive + Content-Length: + - '235' + Content-Type: + - application/json + ParameterSetName: + - --name --description --display-name --scope-accesses --network-manager-scopes + -l --resource-group + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager?api-version=2022-01-01 + response: + body: + string: '{"name":"TestNetworkManager","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","location":"eastus2euap","type":"Microsoft.Network/networkManagers","tags":{},"etag":"","properties":{"displayName":"","description":"My + Test Network Manager","networkManagerScopes":{"managementGroups":[],"subscriptions":["/subscriptions/00000000-0000-0000-0000-000000000000"],"crossTenantScopes":[]},"provisioningState":"Succeeded","networkManagerScopeAccesses":["SecurityAdmin"],"resourceGuid":"21bc899b-b6c7-490f-8884-685afdc575af"},"systemData":{"createdBy":"jaredgorthy@microsoft.com","createdByType":"User","createdAt":"2022-08-19T02:46:38.5177872Z","lastModifiedBy":"jaredgorthy@microsoft.com","lastModifiedByType":"User","lastModifiedAt":"2022-08-19T02:46:38.5177872Z"}}' + headers: + cache-control: + - no-cache + content-length: + - '893' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:39 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: '{"properties": {"networkManagerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group create + Connection: + - keep-alive + Content-Length: + - '218' + Content-Type: + - application/json + ParameterSetName: + - --connection-name --management-group-id --network-manager-id + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection?api-version=2022-01-01 + response: + body: + string: '{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection","name":"myTestNetworkManagerConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","connectionState":"Pending","description":""}}' + headers: + cache-control: + - no-cache + content-length: + - '519' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:41 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group show + Connection: + - keep-alive + ParameterSetName: + - --management-group-id --connection-name + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection?api-version=2022-01-01 + response: + body: + string: '{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection","name":"myTestNetworkManagerConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","connectionState":"Pending","description":""}}' + headers: + cache-control: + - no-cache + content-length: + - '519' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:42 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group update + Connection: + - keep-alive + ParameterSetName: + - --management-group-id --connection-name --description + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection?api-version=2022-01-01 + response: + body: + string: '{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection","name":"myTestNetworkManagerConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","connectionState":"Pending","description":""}}' + headers: + cache-control: + - no-cache + content-length: + - '519' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:42 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"networkManagerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager", + "description": "My Test Network Manager Connection"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group update + Connection: + - keep-alive + Content-Length: + - '271' + Content-Type: + - application/json + ParameterSetName: + - --management-group-id --connection-name --description + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: PUT + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection?api-version=2022-01-01 + response: + body: + string: '{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection","name":"myTestNetworkManagerConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","connectionState":"Pending","description":"My + Test Network Manager Connection"}}' + headers: + cache-control: + - no-cache + content-length: + - '553' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:44 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group list + Connection: + - keep-alive + ParameterSetName: + - --management-group-id + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: GET + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections?api-version=2022-01-01 + response: + body: + string: '{"value":[{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/crossTenantConnectionNoNM","name":"crossTenantConnectionNoNM","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"","connectionState":"Conflict","description":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/newConnectionMG","name":"newConnectionMG","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"","connectionState":"Pending","description":""}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/managementGroupConnection","name":"managementGroupConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"","connectionState":"Pending","description":""}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/newConnection1234","name":"newConnection1234","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy","connectionState":"Pending","description":""}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/willThisPublish","name":"willThisPublish","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy","connectionState":"Pending","description":""}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/cli","name":"cli","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/jaredgorthy-testResources/providers/Microsoft.Network/networkManagers/jaredgorthy","connectionState":"Pending","description":"hello"}},{"id":"/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection","name":"myTestNetworkManagerConnection","type":"Microsoft.Network/networkManagerConnections","location":"","properties":{"networkManagerId":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager","connectionState":"Pending","description":"My + Test Network Manager Connection"}}],"nextLink":""}' + headers: + cache-control: + - no-cache + content-length: + - '7545' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 19 Aug 2022 02:46:46 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager connection management-group delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --connection-name --management-group-id --yes + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: DELETE + uri: https://management.azure.com/providers/Microsoft.Management/managementGroups/anotherMG/providers/Microsoft.Network/networkManagerConnections/myTestNetworkManagerConnection?api-version=2022-01-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 19 Aug 2022 02:46:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-tenant-deletes: + - '14999' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - network manager delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - --resource-group --name --force --yes + User-Agent: + - AZURECLI/2.39.0 azsdk-python-mgmt-network/1.0.0b1 Python/3.10.6 (Windows-10-10.0.19044-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test_network_manager_connection_management000001/providers/Microsoft.Network/networkManagers/TestNetworkManager?api-version=2022-01-01&force=true + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Fri, 19 Aug 2022 02:46:51 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Kestrel + 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/network-manager/azext_network_manager/tests/latest/test_network_scenario.py b/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py index ca65aed59a1..c0c0853ac74 100644 --- a/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py +++ b/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py @@ -495,6 +495,38 @@ def test_network_manager_connection_subscription(self, resource_group): self.cmd('network manager connection subscription delete --connection-name {connection_name} --yes') self.cmd('network manager delete --resource-group {rg} --name {manager_name} --force --yes') + @ResourceGroupPreparer(name_prefix='test_network_manager_connection_management', location='eastus2euap') + def test_network_manager_connection_management(self, resource_group): + self.kwargs.update({ + 'subId': self.get_subscription_id(), + 'sub': '/subscriptions/{}'.format(self.get_subscription_id()), + 'manager_name': 'TestNetworkManager', + 'connection_name': 'myTestNetworkManagerConnection', + 'rg2': self.create_random_name('clitest', 16), + 'mg': 'anotherMG' + }) + + network_manager = self.cmd( + 'network manager create --name {manager_name} --description "My Test Network Manager" ' + '--display-name "TestNetworkManager" ' + '--scope-accesses "SecurityAdmin" ' + '--network-manager-scopes ' + ' subscriptions={sub} ' + '-l eastus2euap ' + '--resource-group {rg}').get_output_in_json() + self.kwargs['manager_id'] = network_manager['id'] + # self.cmd('group create -n {rg2} -l eastus2euap') + self.cmd('network manager connection management-group create --connection-name {connection_name} ' + '--management-group-id {mg} --network-manager-id {manager_id}') + self.cmd('network manager connection management-group show --management-group-id {mg} --connection-name {connection_name} ') + self.cmd('network manager connection management-group update --management-group-id {mg} --connection-name {connection_name} ' + '--description "My Test Network Manager Connection"') + + self.cmd('network manager connection management-group list --management-group-id {mg}') + self.cmd('network manager connection management-group delete --connection-name {connection_name} ' + '--management-group-id {mg} --yes') + self.cmd('network manager delete --resource-group {rg} --name {manager_name} --force --yes') + @ResourceGroupPreparer(name_prefix='test_network_manager_security_admin_config_v2', location='eastus2euap') def test_network_manager_security_admin_config_v2(self, resource_group): diff --git a/src/network-manager/setup.py b/src/network-manager/setup.py index b5d5dc4ea8b..9fecabe5bcc 100644 --- a/src/network-manager/setup.py +++ b/src/network-manager/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages # HISTORY.rst entry. -VERSION = '0.5.1' +VERSION = '0.5.2' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers