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 ProviderResourceTypesOperations(object): 26 """ProviderResourceTypesOperations 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.resource.resources.v2020_10_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 list( 48 self, 49 resource_provider_namespace, # type: str 50 expand=None, # type: Optional[str] 51 **kwargs # type: Any 52 ): 53 # type: (...) -> "_models.ProviderResourceTypeListResult" 54 """List the resource types for a specified resource provider. 55 56 :param resource_provider_namespace: The namespace of the resource provider. 57 :type resource_provider_namespace: str 58 :param expand: The $expand query parameter. For example, to include property aliases in 59 response, use $expand=resourceTypes/aliases. 60 :type expand: str 61 :keyword callable cls: A custom type or function that will be passed the direct response 62 :return: ProviderResourceTypeListResult, or the result of cls(response) 63 :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.ProviderResourceTypeListResult 64 :raises: ~azure.core.exceptions.HttpResponseError 65 """ 66 cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderResourceTypeListResult"] 67 error_map = { 68 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 69 } 70 error_map.update(kwargs.pop('error_map', {})) 71 api_version = "2020-10-01" 72 accept = "application/json" 73 74 # Construct URL 75 url = self.list.metadata['url'] # type: ignore 76 path_format_arguments = { 77 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 78 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 79 } 80 url = self._client.format_url(url, **path_format_arguments) 81 82 # Construct parameters 83 query_parameters = {} # type: Dict[str, Any] 84 if expand is not None: 85 query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') 86 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 87 88 # Construct headers 89 header_parameters = {} # type: Dict[str, Any] 90 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 91 92 request = self._client.get(url, query_parameters, header_parameters) 93 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 94 response = pipeline_response.http_response 95 96 if response.status_code not in [200]: 97 map_error(status_code=response.status_code, response=response, error_map=error_map) 98 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 99 100 deserialized = self._deserialize('ProviderResourceTypeListResult', pipeline_response) 101 102 if cls: 103 return cls(pipeline_response, deserialized, {}) 104 105 return deserialized 106 list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/resourceTypes'} # type: ignore 107