1# coding=utf-8
2# --------------------------------------------------------------------------
3# Copyright (c) Microsoft Corporation. All rights reserved.
4# Licensed under the MIT License. See License.txt in the project root for license information.
5# Code generated by Microsoft (R) AutoRest Code Generator.
6# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7# --------------------------------------------------------------------------
8from typing import TYPE_CHECKING
9import warnings
10
11from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
12from azure.core.pipeline import PipelineResponse
13from azure.core.pipeline.transport import HttpRequest, HttpResponse
14from azure.mgmt.core.exceptions import ARMErrorFormat
15
16from .. import models as _models
17
18if TYPE_CHECKING:
19    # pylint: disable=unused-import,ungrouped-imports
20    from typing import Any, Callable, Dict, Generic, Optional, TypeVar
21
22    T = TypeVar('T')
23    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
24
25class VpnSiteLinkConnectionsOperations(object):
26    """VpnSiteLinkConnectionsOperations operations.
27
28    You should not instantiate this class directly. Instead, you should create a Client instance that
29    instantiates it for you and attaches it as an attribute.
30
31    :ivar models: Alias to model classes used in this operation group.
32    :type models: ~azure.mgmt.network.v2019_11_01.models
33    :param client: Client for service requests.
34    :param config: Configuration of service client.
35    :param serializer: An object model serializer.
36    :param deserializer: An object model deserializer.
37    """
38
39    models = _models
40
41    def __init__(self, client, config, serializer, deserializer):
42        self._client = client
43        self._serialize = serializer
44        self._deserialize = deserializer
45        self._config = config
46
47    def get(
48        self,
49        resource_group_name,  # type: str
50        gateway_name,  # type: str
51        connection_name,  # type: str
52        link_connection_name,  # type: str
53        **kwargs  # type: Any
54    ):
55        # type: (...) -> "_models.VpnSiteLinkConnection"
56        """Retrieves the details of a vpn site link connection.
57
58        :param resource_group_name: The resource group name of the VpnGateway.
59        :type resource_group_name: str
60        :param gateway_name: The name of the gateway.
61        :type gateway_name: str
62        :param connection_name: The name of the vpn connection.
63        :type connection_name: str
64        :param link_connection_name: The name of the vpn connection.
65        :type link_connection_name: str
66        :keyword callable cls: A custom type or function that will be passed the direct response
67        :return: VpnSiteLinkConnection, or the result of cls(response)
68        :rtype: ~azure.mgmt.network.v2019_11_01.models.VpnSiteLinkConnection
69        :raises: ~azure.core.exceptions.HttpResponseError
70        """
71        cls = kwargs.pop('cls', None)  # type: ClsType["_models.VpnSiteLinkConnection"]
72        error_map = {
73            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
74        }
75        error_map.update(kwargs.pop('error_map', {}))
76        api_version = "2019-11-01"
77        accept = "application/json"
78
79        # Construct URL
80        url = self.get.metadata['url']  # type: ignore
81        path_format_arguments = {
82            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
83            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
84            'gatewayName': self._serialize.url("gateway_name", gateway_name, 'str'),
85            'connectionName': self._serialize.url("connection_name", connection_name, 'str'),
86            'linkConnectionName': self._serialize.url("link_connection_name", link_connection_name, 'str'),
87        }
88        url = self._client.format_url(url, **path_format_arguments)
89
90        # Construct parameters
91        query_parameters = {}  # type: Dict[str, Any]
92        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
93
94        # Construct headers
95        header_parameters = {}  # type: Dict[str, Any]
96        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
97
98        request = self._client.get(url, query_parameters, header_parameters)
99        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
100        response = pipeline_response.http_response
101
102        if response.status_code not in [200]:
103            map_error(status_code=response.status_code, response=response, error_map=error_map)
104            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
105
106        deserialized = self._deserialize('VpnSiteLinkConnection', pipeline_response)
107
108        if cls:
109            return cls(pipeline_response, deserialized, {})
110
111        return deserialized
112    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnGateways/{gatewayName}/vpnConnections/{connectionName}/vpnLinkConnections/{linkConnectionName}'}  # type: ignore
113