Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,29 @@ class NetworkManagementClientConfiguration(AzureConfiguration):
identify the Microsoft Azure subscription. The subscription ID forms part
of the URI for every service call.
:type subscription_id: str
:param resource_group_name: The resource group name of the Microsoft Azure
resource.
:type resource_group_name: str
:param virtual_hub_name: The name of the Virtual Hub resource.
:type virtual_hub_name: str
:param connection_name: The name of the connection resource.
:type connection_name: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, base_url=None):
self, credentials, subscription_id, resource_group_name, virtual_hub_name, connection_name, base_url=None):

if credentials is None:
raise ValueError("Parameter 'credentials' must not be None.")
if subscription_id is None:
raise ValueError("Parameter 'subscription_id' must not be None.")
if resource_group_name is None:
raise ValueError("Parameter 'resource_group_name' must not be None.")
if virtual_hub_name is None:
raise ValueError("Parameter 'virtual_hub_name' must not be None.")
if connection_name is None:
raise ValueError("Parameter 'connection_name' must not be None.")
if not base_url:
base_url = 'https://management.azure.com'

Expand All @@ -121,6 +134,9 @@ def __init__(

self.credentials = credentials
self.subscription_id = subscription_id
self.resource_group_name = resource_group_name
self.virtual_hub_name = virtual_hub_name
self.connection_name = connection_name


class NetworkManagementClient(SDKClient):
Expand Down Expand Up @@ -273,13 +289,20 @@ class NetworkManagementClient(SDKClient):
identify the Microsoft Azure subscription. The subscription ID forms part
of the URI for every service call.
:type subscription_id: str
:param resource_group_name: The resource group name of the Microsoft Azure
resource.
:type resource_group_name: str
:param virtual_hub_name: The name of the Virtual Hub resource.
:type virtual_hub_name: str
:param connection_name: The name of the connection resource.
:type connection_name: str
:param str base_url: Service URL
"""

def __init__(
self, credentials, subscription_id, base_url=None):
self, credentials, subscription_id, resource_group_name, virtual_hub_name, connection_name, base_url=None):

self.config = NetworkManagementClientConfiguration(credentials, subscription_id, base_url)
self.config = NetworkManagementClientConfiguration(credentials, subscription_id, resource_group_name, virtual_hub_name, connection_name, base_url)
super(NetworkManagementClient, self).__init__(self.config.credentials, self.config)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
Expand Down Expand Up @@ -492,11 +515,9 @@ def check_dns_name_availability(
check_dns_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability'}

def supported_security_providers(
self, resource_group_name, virtual_wan_name, custom_headers=None, raw=False, **operation_config):
self, virtual_wan_name, custom_headers=None, raw=False, **operation_config):
"""Gives the supported security providers for the virtual wan.

:param resource_group_name: The resource group name.
:type resource_group_name: str
:param virtual_wan_name: The name of the VirtualWAN for which
supported security providers are needed.
:type virtual_wan_name: str
Expand All @@ -518,7 +539,7 @@ def supported_security_providers(
url = self.supported_security_providers.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str'),
'virtualWANName': self._serialize.url("virtual_wan_name", virtual_wan_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrest.polling import LROPoller, NoPolling
from msrestazure.polling.arm_polling import ARMPolling

from .. import models

Expand All @@ -37,15 +39,9 @@ def __init__(self, client, config, serializer, deserializer):
self.config = config

def get(
self, resource_group_name, virtual_hub_name, connection_name, custom_headers=None, raw=False, **operation_config):
self, custom_headers=None, raw=False, **operation_config):
"""Retrieves the details of a HubVirtualNetworkConnection.

:param resource_group_name: The resource group name of the VirtualHub.
:type resource_group_name: str
:param virtual_hub_name: The name of the VirtualHub.
:type virtual_hub_name: str
:param connection_name: The name of the vpn connection.
:type connection_name: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand All @@ -62,9 +58,9 @@ def get(
url = self.get.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'virtualHubName': self._serialize.url("virtual_hub_name", virtual_hub_name, 'str'),
'connectionName': self._serialize.url("connection_name", connection_name, 'str')
'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str'),
'virtualHubName': self._serialize.url("self.config.virtual_hub_name", self.config.virtual_hub_name, 'str'),
'connectionName': self._serialize.url("self.config.connection_name", self.config.connection_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

Expand Down Expand Up @@ -101,14 +97,209 @@ def get(
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/hubVirtualNetworkConnections/{connectionName}'}


def _create_or_update_initial(
self, hub_virtual_network_connection_parameters, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.create_or_update.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str'),
'virtualHubName': self._serialize.url("self.config.virtual_hub_name", self.config.virtual_hub_name, 'str'),
'connectionName': self._serialize.url("self.config.connection_name", self.config.connection_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
body_content = self._serialize.body(hub_virtual_network_connection_parameters, 'HubVirtualNetworkConnection')

# Construct and send request
request = self._client.put(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200, 201]:
raise models.ErrorException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('HubVirtualNetworkConnection', response)
if response.status_code == 201:
deserialized = self._deserialize('HubVirtualNetworkConnection', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

def create_or_update(
self, hub_virtual_network_connection_parameters, custom_headers=None, raw=False, polling=True, **operation_config):
"""Creates a HubVirtualNetworkConnection resource if it doesn't exist.
Updates the HubVirtualNetworkConnection if one exists.

:param hub_virtual_network_connection_parameters: Parameters supplied
to create or update HubVirtualNetworkConnection.
:type hub_virtual_network_connection_parameters:
~azure.mgmt.network.v2018_12_01.models.HubVirtualNetworkConnection
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
:param polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:return: An instance of LROPoller that returns
HubVirtualNetworkConnection or
ClientRawResponse<HubVirtualNetworkConnection> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.network.v2018_12_01.models.HubVirtualNetworkConnection]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.network.v2018_12_01.models.HubVirtualNetworkConnection]]
:raises:
:class:`ErrorException<azure.mgmt.network.v2018_12_01.models.ErrorException>`
"""
raw_result = self._create_or_update_initial(
hub_virtual_network_connection_parameters=hub_virtual_network_connection_parameters,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
deserialized = self._deserialize('HubVirtualNetworkConnection', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/hubVirtualNetworkConnections/{connectionName}'}


def _update_tags_initial(
self, tags=None, custom_headers=None, raw=False, **operation_config):
hub_virtual_network_connection_parameters = models.TagsObject(tags=tags)

# Construct URL
url = self.update_tags.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str'),
'virtualHubName': self._serialize.url("self.config.virtual_hub_name", self.config.virtual_hub_name, 'str'),
'connectionName': self._serialize.url("self.config.connection_name", self.config.connection_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
body_content = self._serialize.body(hub_virtual_network_connection_parameters, 'TagsObject')

# Construct and send request
request = self._client.patch(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200, 201]:
raise models.ErrorException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('HubVirtualNetworkConnection', response)
if response.status_code == 201:
deserialized = self._deserialize('HubVirtualNetworkConnection', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

def update_tags(
self, tags=None, custom_headers=None, raw=False, polling=True, **operation_config):
"""Updates HubVirtualNetworkConnection tags.

:param tags: Resource tags.
:type tags: dict[str, str]
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
:param polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:return: An instance of LROPoller that returns
HubVirtualNetworkConnection or
ClientRawResponse<HubVirtualNetworkConnection> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.network.v2018_12_01.models.HubVirtualNetworkConnection]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.network.v2018_12_01.models.HubVirtualNetworkConnection]]
:raises:
:class:`ErrorException<azure.mgmt.network.v2018_12_01.models.ErrorException>`
"""
raw_result = self._update_tags_initial(
tags=tags,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
deserialized = self._deserialize('HubVirtualNetworkConnection', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualHubs/{virtualHubName}/hubVirtualNetworkConnections/{connectionName}'}

def list(
self, resource_group_name, virtual_hub_name, custom_headers=None, raw=False, **operation_config):
self, custom_headers=None, raw=False, **operation_config):
"""Retrieves the details of all HubVirtualNetworkConnections.

:param resource_group_name: The resource group name of the VirtualHub.
:type resource_group_name: str
:param virtual_hub_name: The name of the VirtualHub.
:type virtual_hub_name: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
Expand All @@ -127,8 +318,8 @@ def internal_paging(next_link=None, raw=False):
url = self.list.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'virtualHubName': self._serialize.url("virtual_hub_name", virtual_hub_name, 'str')
'resourceGroupName': self._serialize.url("self.config.resource_group_name", self.config.resource_group_name, 'str'),
'virtualHubName': self._serialize.url("self.config.virtual_hub_name", self.config.virtual_hub_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

Expand Down
Loading