|
| 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 |
| 5 | +# license information. |
| 6 | +# |
| 7 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 8 | +# Changes may cause incorrect behavior and will be lost if the code is |
| 9 | +# regenerated. |
| 10 | +# -------------------------------------------------------------------------- |
| 11 | + |
| 12 | +from msrest.service_client import SDKClient |
| 13 | +from msrest import Serializer, Deserializer |
| 14 | +from msrestazure import AzureConfiguration |
| 15 | +from .version import VERSION |
| 16 | +from msrest.pipeline import ClientRawResponse |
| 17 | +from msrestazure.azure_exceptions import CloudError |
| 18 | +from msrest.polling import LROPoller, NoPolling |
| 19 | +from msrestazure.polling.arm_polling import ARMPolling |
| 20 | +import uuid |
| 21 | +from .operations.front_doors_operations import FrontDoorsOperations |
| 22 | +from .operations.routing_rules_operations import RoutingRulesOperations |
| 23 | +from .operations.health_probe_settings_operations import HealthProbeSettingsOperations |
| 24 | +from .operations.load_balancing_settings_operations import LoadBalancingSettingsOperations |
| 25 | +from .operations.backend_pools_operations import BackendPoolsOperations |
| 26 | +from .operations.frontend_endpoints_operations import FrontendEndpointsOperations |
| 27 | +from .operations.endpoints_operations import EndpointsOperations |
| 28 | +from .operations.policies_operations import PoliciesOperations |
| 29 | +from . import models |
| 30 | + |
| 31 | + |
| 32 | +class FrontdoorManagementClientConfiguration(AzureConfiguration): |
| 33 | + """Configuration for FrontdoorManagementClient |
| 34 | + Note that all parameters used to create this instance are saved as instance |
| 35 | + attributes. |
| 36 | +
|
| 37 | + :param credentials: Credentials needed for the client to connect to Azure. |
| 38 | + :type credentials: :mod:`A msrestazure Credentials |
| 39 | + object<msrestazure.azure_active_directory>` |
| 40 | + :param subscription_id: The subscription credentials which uniquely |
| 41 | + identify the Microsoft Azure subscription. The subscription ID forms part |
| 42 | + of the URI for every service call. |
| 43 | + :type subscription_id: str |
| 44 | + :param str base_url: Service URL |
| 45 | + """ |
| 46 | + |
| 47 | + def __init__( |
| 48 | + self, credentials, subscription_id, base_url=None): |
| 49 | + |
| 50 | + if credentials is None: |
| 51 | + raise ValueError("Parameter 'credentials' must not be None.") |
| 52 | + if subscription_id is None: |
| 53 | + raise ValueError("Parameter 'subscription_id' must not be None.") |
| 54 | + if not base_url: |
| 55 | + base_url = 'https://management.azure.com' |
| 56 | + |
| 57 | + super(FrontdoorManagementClientConfiguration, self).__init__(base_url) |
| 58 | + |
| 59 | + self.add_user_agent('azure-mgmt-frontdoor/{}'.format(VERSION)) |
| 60 | + self.add_user_agent('Azure-SDK-For-Python') |
| 61 | + |
| 62 | + self.credentials = credentials |
| 63 | + self.subscription_id = subscription_id |
| 64 | + |
| 65 | + |
| 66 | +class FrontdoorManagementClient(SDKClient): |
| 67 | + """Frontdoor Client |
| 68 | +
|
| 69 | + :ivar config: Configuration for client. |
| 70 | + :vartype config: FrontdoorManagementClientConfiguration |
| 71 | +
|
| 72 | + :ivar front_doors: FrontDoors operations |
| 73 | + :vartype front_doors: azure.mgmt.frontdoor.operations.FrontDoorsOperations |
| 74 | + :ivar routing_rules: RoutingRules operations |
| 75 | + :vartype routing_rules: azure.mgmt.frontdoor.operations.RoutingRulesOperations |
| 76 | + :ivar health_probe_settings: HealthProbeSettings operations |
| 77 | + :vartype health_probe_settings: azure.mgmt.frontdoor.operations.HealthProbeSettingsOperations |
| 78 | + :ivar load_balancing_settings: LoadBalancingSettings operations |
| 79 | + :vartype load_balancing_settings: azure.mgmt.frontdoor.operations.LoadBalancingSettingsOperations |
| 80 | + :ivar backend_pools: BackendPools operations |
| 81 | + :vartype backend_pools: azure.mgmt.frontdoor.operations.BackendPoolsOperations |
| 82 | + :ivar frontend_endpoints: FrontendEndpoints operations |
| 83 | + :vartype frontend_endpoints: azure.mgmt.frontdoor.operations.FrontendEndpointsOperations |
| 84 | + :ivar endpoints: Endpoints operations |
| 85 | + :vartype endpoints: azure.mgmt.frontdoor.operations.EndpointsOperations |
| 86 | + :ivar policies: Policies operations |
| 87 | + :vartype policies: azure.mgmt.frontdoor.operations.PoliciesOperations |
| 88 | +
|
| 89 | + :param credentials: Credentials needed for the client to connect to Azure. |
| 90 | + :type credentials: :mod:`A msrestazure Credentials |
| 91 | + object<msrestazure.azure_active_directory>` |
| 92 | + :param subscription_id: The subscription credentials which uniquely |
| 93 | + identify the Microsoft Azure subscription. The subscription ID forms part |
| 94 | + of the URI for every service call. |
| 95 | + :type subscription_id: str |
| 96 | + :param str base_url: Service URL |
| 97 | + """ |
| 98 | + |
| 99 | + def __init__( |
| 100 | + self, credentials, subscription_id, base_url=None): |
| 101 | + |
| 102 | + self.config = FrontdoorManagementClientConfiguration(credentials, subscription_id, base_url) |
| 103 | + super(FrontdoorManagementClient, self).__init__(self.config.credentials, self.config) |
| 104 | + |
| 105 | + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
| 106 | + self._serialize = Serializer(client_models) |
| 107 | + self._deserialize = Deserializer(client_models) |
| 108 | + |
| 109 | + self.front_doors = FrontDoorsOperations( |
| 110 | + self._client, self.config, self._serialize, self._deserialize) |
| 111 | + self.routing_rules = RoutingRulesOperations( |
| 112 | + self._client, self.config, self._serialize, self._deserialize) |
| 113 | + self.health_probe_settings = HealthProbeSettingsOperations( |
| 114 | + self._client, self.config, self._serialize, self._deserialize) |
| 115 | + self.load_balancing_settings = LoadBalancingSettingsOperations( |
| 116 | + self._client, self.config, self._serialize, self._deserialize) |
| 117 | + self.backend_pools = BackendPoolsOperations( |
| 118 | + self._client, self.config, self._serialize, self._deserialize) |
| 119 | + self.frontend_endpoints = FrontendEndpointsOperations( |
| 120 | + self._client, self.config, self._serialize, self._deserialize) |
| 121 | + self.endpoints = EndpointsOperations( |
| 122 | + self._client, self.config, self._serialize, self._deserialize) |
| 123 | + self.policies = PoliciesOperations( |
| 124 | + self._client, self.config, self._serialize, self._deserialize) |
| 125 | + |
| 126 | + def check_front_door_name_availability( |
| 127 | + self, name, type, custom_headers=None, raw=False, **operation_config): |
| 128 | + """Check the availability of a Front Door resource name. |
| 129 | +
|
| 130 | + :param name: The resource name to validate. |
| 131 | + :type name: str |
| 132 | + :param type: The type of the resource whose name is to be validated. |
| 133 | + Possible values include: 'Microsoft.Network/frontDoors', |
| 134 | + 'Microsoft.Network/frontDoors/frontendEndpoints' |
| 135 | + :type type: str or ~azure.mgmt.frontdoor.models.ResourceType |
| 136 | + :param dict custom_headers: headers that will be added to the request |
| 137 | + :param bool raw: returns the direct response alongside the |
| 138 | + deserialized response |
| 139 | + :param operation_config: :ref:`Operation configuration |
| 140 | + overrides<msrest:optionsforoperations>`. |
| 141 | + :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true |
| 142 | + :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or |
| 143 | + ~msrest.pipeline.ClientRawResponse |
| 144 | + :raises: |
| 145 | + :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>` |
| 146 | + """ |
| 147 | + check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type) |
| 148 | + |
| 149 | + api_version = "2018-08-01" |
| 150 | + |
| 151 | + # Construct URL |
| 152 | + url = self.check_front_door_name_availability.metadata['url'] |
| 153 | + |
| 154 | + # Construct parameters |
| 155 | + query_parameters = {} |
| 156 | + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') |
| 157 | + |
| 158 | + # Construct headers |
| 159 | + header_parameters = {} |
| 160 | + header_parameters['Accept'] = 'application/json' |
| 161 | + header_parameters['Content-Type'] = 'application/json; charset=utf-8' |
| 162 | + if self.config.generate_client_request_id: |
| 163 | + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) |
| 164 | + if custom_headers: |
| 165 | + header_parameters.update(custom_headers) |
| 166 | + if self.config.accept_language is not None: |
| 167 | + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') |
| 168 | + |
| 169 | + # Construct body |
| 170 | + body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput') |
| 171 | + |
| 172 | + # Construct and send request |
| 173 | + request = self._client.post(url, query_parameters, header_parameters, body_content) |
| 174 | + response = self._client.send(request, stream=False, **operation_config) |
| 175 | + |
| 176 | + if response.status_code not in [200]: |
| 177 | + raise models.ErrorResponseException(self._deserialize, response) |
| 178 | + |
| 179 | + deserialized = None |
| 180 | + |
| 181 | + if response.status_code == 200: |
| 182 | + deserialized = self._deserialize('CheckNameAvailabilityOutput', response) |
| 183 | + |
| 184 | + if raw: |
| 185 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 186 | + return client_raw_response |
| 187 | + |
| 188 | + return deserialized |
| 189 | + check_front_door_name_availability.metadata = {'url': '/providers/Microsoft.Network/checkFrontDoorNameAvailability'} |
| 190 | + |
| 191 | + def check_front_door_name_availability_with_subscription( |
| 192 | + self, name, type, custom_headers=None, raw=False, **operation_config): |
| 193 | + """Check the availability of a Front Door subdomain. |
| 194 | +
|
| 195 | + :param name: The resource name to validate. |
| 196 | + :type name: str |
| 197 | + :param type: The type of the resource whose name is to be validated. |
| 198 | + Possible values include: 'Microsoft.Network/frontDoors', |
| 199 | + 'Microsoft.Network/frontDoors/frontendEndpoints' |
| 200 | + :type type: str or ~azure.mgmt.frontdoor.models.ResourceType |
| 201 | + :param dict custom_headers: headers that will be added to the request |
| 202 | + :param bool raw: returns the direct response alongside the |
| 203 | + deserialized response |
| 204 | + :param operation_config: :ref:`Operation configuration |
| 205 | + overrides<msrest:optionsforoperations>`. |
| 206 | + :return: CheckNameAvailabilityOutput or ClientRawResponse if raw=true |
| 207 | + :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput or |
| 208 | + ~msrest.pipeline.ClientRawResponse |
| 209 | + :raises: |
| 210 | + :class:`ErrorResponseException<azure.mgmt.frontdoor.models.ErrorResponseException>` |
| 211 | + """ |
| 212 | + check_front_door_name_availability_input = models.CheckNameAvailabilityInput(name=name, type=type) |
| 213 | + |
| 214 | + api_version = "2018-08-01" |
| 215 | + |
| 216 | + # Construct URL |
| 217 | + url = self.check_front_door_name_availability_with_subscription.metadata['url'] |
| 218 | + path_format_arguments = { |
| 219 | + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') |
| 220 | + } |
| 221 | + url = self._client.format_url(url, **path_format_arguments) |
| 222 | + |
| 223 | + # Construct parameters |
| 224 | + query_parameters = {} |
| 225 | + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') |
| 226 | + |
| 227 | + # Construct headers |
| 228 | + header_parameters = {} |
| 229 | + header_parameters['Accept'] = 'application/json' |
| 230 | + header_parameters['Content-Type'] = 'application/json; charset=utf-8' |
| 231 | + if self.config.generate_client_request_id: |
| 232 | + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) |
| 233 | + if custom_headers: |
| 234 | + header_parameters.update(custom_headers) |
| 235 | + if self.config.accept_language is not None: |
| 236 | + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') |
| 237 | + |
| 238 | + # Construct body |
| 239 | + body_content = self._serialize.body(check_front_door_name_availability_input, 'CheckNameAvailabilityInput') |
| 240 | + |
| 241 | + # Construct and send request |
| 242 | + request = self._client.post(url, query_parameters, header_parameters, body_content) |
| 243 | + response = self._client.send(request, stream=False, **operation_config) |
| 244 | + |
| 245 | + if response.status_code not in [200]: |
| 246 | + raise models.ErrorResponseException(self._deserialize, response) |
| 247 | + |
| 248 | + deserialized = None |
| 249 | + |
| 250 | + if response.status_code == 200: |
| 251 | + deserialized = self._deserialize('CheckNameAvailabilityOutput', response) |
| 252 | + |
| 253 | + if raw: |
| 254 | + client_raw_response = ClientRawResponse(deserialized, response) |
| 255 | + return client_raw_response |
| 256 | + |
| 257 | + return deserialized |
| 258 | + check_front_door_name_availability_with_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability'} |
0 commit comments