|
| 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 | +# -------------------------------------------------------------------------- |
| 8 | +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar |
| 9 | +import warnings |
| 10 | + |
| 11 | +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error |
| 12 | +from azure.core.pipeline import PipelineResponse |
| 13 | +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest |
| 14 | +from azure.mgmt.core.exceptions import ARMErrorFormat |
| 15 | + |
| 16 | +from ... import models as _models |
| 17 | + |
| 18 | +T = TypeVar('T') |
| 19 | +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] |
| 20 | + |
| 21 | +class OutboundNetworkDependenciesEndpointsOperations: |
| 22 | + """OutboundNetworkDependenciesEndpointsOperations async operations. |
| 23 | +
|
| 24 | + You should not instantiate this class directly. Instead, you should create a Client instance that |
| 25 | + instantiates it for you and attaches it as an attribute. |
| 26 | +
|
| 27 | + :ivar models: Alias to model classes used in this operation group. |
| 28 | + :type models: ~azure_databricks_management_client.models |
| 29 | + :param client: Client for service requests. |
| 30 | + :param config: Configuration of service client. |
| 31 | + :param serializer: An object model serializer. |
| 32 | + :param deserializer: An object model deserializer. |
| 33 | + """ |
| 34 | + |
| 35 | + models = _models |
| 36 | + |
| 37 | + def __init__(self, client, config, serializer, deserializer) -> None: |
| 38 | + self._client = client |
| 39 | + self._serialize = serializer |
| 40 | + self._deserialize = deserializer |
| 41 | + self._config = config |
| 42 | + |
| 43 | + async def list( |
| 44 | + self, |
| 45 | + resource_group_name: str, |
| 46 | + workspace_name: str, |
| 47 | + **kwargs: Any |
| 48 | + ) -> List["_models.OutboundEnvironmentEndpoint"]: |
| 49 | + """Gets a list of egress endpoints (network endpoints of all outbound dependencies) in the specified Workspace. |
| 50 | +
|
| 51 | + Gets the list of endpoints that VNET Injected Workspace calls Azure Databricks Control Plane. |
| 52 | + You must configure outbound access with these endpoints. For more information, see |
| 53 | + https://docs.microsoft.com/en-us/azure/databricks/administration-guide/cloud-configurations/azure/udr. |
| 54 | +
|
| 55 | + :param resource_group_name: The name of the resource group. The name is case insensitive. |
| 56 | + :type resource_group_name: str |
| 57 | + :param workspace_name: The name of the workspace. |
| 58 | + :type workspace_name: str |
| 59 | + :keyword callable cls: A custom type or function that will be passed the direct response |
| 60 | + :return: list of OutboundEnvironmentEndpoint, or the result of cls(response) |
| 61 | + :rtype: list[~azure_databricks_management_client.models.OutboundEnvironmentEndpoint] |
| 62 | + :raises: ~azure.core.exceptions.HttpResponseError |
| 63 | + """ |
| 64 | + cls = kwargs.pop('cls', None) # type: ClsType[List["_models.OutboundEnvironmentEndpoint"]] |
| 65 | + error_map = { |
| 66 | + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError |
| 67 | + } |
| 68 | + error_map.update(kwargs.pop('error_map', {})) |
| 69 | + api_version = "2021-04-01-preview" |
| 70 | + accept = "application/json" |
| 71 | + |
| 72 | + # Construct URL |
| 73 | + url = self.list.metadata['url'] # type: ignore |
| 74 | + path_format_arguments = { |
| 75 | + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), |
| 76 | + 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=64, min_length=3), |
| 77 | + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
| 78 | + } |
| 79 | + url = self._client.format_url(url, **path_format_arguments) |
| 80 | + |
| 81 | + # Construct parameters |
| 82 | + query_parameters = {} # type: Dict[str, Any] |
| 83 | + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') |
| 84 | + |
| 85 | + # Construct headers |
| 86 | + header_parameters = {} # type: Dict[str, Any] |
| 87 | + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') |
| 88 | + |
| 89 | + request = self._client.get(url, query_parameters, header_parameters) |
| 90 | + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) |
| 91 | + response = pipeline_response.http_response |
| 92 | + |
| 93 | + if response.status_code not in [200]: |
| 94 | + map_error(status_code=response.status_code, response=response, error_map=error_map) |
| 95 | + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) |
| 96 | + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) |
| 97 | + |
| 98 | + deserialized = self._deserialize('[OutboundEnvironmentEndpoint]', pipeline_response) |
| 99 | + |
| 100 | + if cls: |
| 101 | + return cls(pipeline_response, deserialized, {}) |
| 102 | + |
| 103 | + return deserialized |
| 104 | + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Databricks/workspaces/{workspaceName}/outboundNetworkDependenciesEndpoints'} # type: ignore |
0 commit comments