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.paging import ItemPaged 13from azure.core.pipeline import PipelineResponse 14from azure.core.pipeline.transport import HttpRequest, HttpResponse 15from azure.core.polling import LROPoller, NoPolling, PollingMethod 16from azure.mgmt.core.exceptions import ARMErrorFormat 17from azure.mgmt.core.polling.arm_polling import ARMPolling 18 19from .. import models as _models 20 21if TYPE_CHECKING: 22 # pylint: disable=unused-import,ungrouped-imports 23 from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union 24 25 T = TypeVar('T') 26 ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] 27 28class ResourcesOperations(object): 29 """ResourcesOperations operations. 30 31 You should not instantiate this class directly. Instead, you should create a Client instance that 32 instantiates it for you and attaches it as an attribute. 33 34 :ivar models: Alias to model classes used in this operation group. 35 :type models: ~azure.mgmt.resource.resources.v2016_02_01.models 36 :param client: Client for service requests. 37 :param config: Configuration of service client. 38 :param serializer: An object model serializer. 39 :param deserializer: An object model deserializer. 40 """ 41 42 models = _models 43 44 def __init__(self, client, config, serializer, deserializer): 45 self._client = client 46 self._serialize = serializer 47 self._deserialize = deserializer 48 self._config = config 49 50 def _move_resources_initial( 51 self, 52 source_resource_group_name, # type: str 53 parameters, # type: "_models.ResourcesMoveInfo" 54 **kwargs # type: Any 55 ): 56 # type: (...) -> None 57 cls = kwargs.pop('cls', None) # type: ClsType[None] 58 error_map = { 59 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 60 } 61 error_map.update(kwargs.pop('error_map', {})) 62 api_version = "2016-02-01" 63 content_type = kwargs.pop("content_type", "application/json") 64 65 # Construct URL 66 url = self._move_resources_initial.metadata['url'] # type: ignore 67 path_format_arguments = { 68 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 69 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 70 } 71 url = self._client.format_url(url, **path_format_arguments) 72 73 # Construct parameters 74 query_parameters = {} # type: Dict[str, Any] 75 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 76 77 # Construct headers 78 header_parameters = {} # type: Dict[str, Any] 79 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 80 81 body_content_kwargs = {} # type: Dict[str, Any] 82 body_content = self._serialize.body(parameters, 'ResourcesMoveInfo') 83 body_content_kwargs['content'] = body_content 84 request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) 85 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 86 response = pipeline_response.http_response 87 88 if response.status_code not in [202, 204]: 89 map_error(status_code=response.status_code, response=response, error_map=error_map) 90 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 91 92 if cls: 93 return cls(pipeline_response, None, {}) 94 95 _move_resources_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore 96 97 def begin_move_resources( 98 self, 99 source_resource_group_name, # type: str 100 parameters, # type: "_models.ResourcesMoveInfo" 101 **kwargs # type: Any 102 ): 103 # type: (...) -> LROPoller[None] 104 """Move resources from one resource group to another. The resources being moved should all be in 105 the same resource group. 106 107 :param source_resource_group_name: Source resource group name. 108 :type source_resource_group_name: str 109 :param parameters: move resources' parameters. 110 :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.ResourcesMoveInfo 111 :keyword callable cls: A custom type or function that will be passed the direct response 112 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 113 :keyword polling: By default, your polling method will be ARMPolling. 114 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 115 :paramtype polling: bool or ~azure.core.polling.PollingMethod 116 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 117 :return: An instance of LROPoller that returns either None or the result of cls(response) 118 :rtype: ~azure.core.polling.LROPoller[None] 119 :raises ~azure.core.exceptions.HttpResponseError: 120 """ 121 polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 122 cls = kwargs.pop('cls', None) # type: ClsType[None] 123 lro_delay = kwargs.pop( 124 'polling_interval', 125 self._config.polling_interval 126 ) 127 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 128 if cont_token is None: 129 raw_result = self._move_resources_initial( 130 source_resource_group_name=source_resource_group_name, 131 parameters=parameters, 132 cls=lambda x,y,z: x, 133 **kwargs 134 ) 135 136 kwargs.pop('error_map', None) 137 kwargs.pop('content_type', None) 138 139 def get_long_running_output(pipeline_response): 140 if cls: 141 return cls(pipeline_response, None, {}) 142 143 path_format_arguments = { 144 'sourceResourceGroupName': self._serialize.url("source_resource_group_name", source_resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 145 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 146 } 147 148 if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 149 elif polling is False: polling_method = NoPolling() 150 else: polling_method = polling 151 if cont_token: 152 return LROPoller.from_continuation_token( 153 polling_method=polling_method, 154 continuation_token=cont_token, 155 client=self._client, 156 deserialization_callback=get_long_running_output 157 ) 158 else: 159 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 160 begin_move_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources'} # type: ignore 161 162 def list( 163 self, 164 filter=None, # type: Optional[str] 165 expand=None, # type: Optional[str] 166 top=None, # type: Optional[int] 167 **kwargs # type: Any 168 ): 169 # type: (...) -> Iterable["_models.ResourceListResult"] 170 """Get all of the resources under a subscription. 171 172 :param filter: The filter to apply on the operation. 173 :type filter: str 174 :param expand: Comma-separated list of additional properties to be included in the response. 175 Valid values include ``createdTime``\ , ``changedTime`` and ``provisioningState``. For example, 176 ``$expand=createdTime,changedTime``. 177 :type expand: str 178 :param top: Query parameters. If null is passed returns all resource groups. 179 :type top: int 180 :keyword callable cls: A custom type or function that will be passed the direct response 181 :return: An iterator like instance of either ResourceListResult or the result of cls(response) 182 :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2016_02_01.models.ResourceListResult] 183 :raises: ~azure.core.exceptions.HttpResponseError 184 """ 185 cls = kwargs.pop('cls', None) # type: ClsType["_models.ResourceListResult"] 186 error_map = { 187 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 188 } 189 error_map.update(kwargs.pop('error_map', {})) 190 api_version = "2016-02-01" 191 accept = "application/json" 192 193 def prepare_request(next_link=None): 194 # Construct headers 195 header_parameters = {} # type: Dict[str, Any] 196 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 197 198 if not next_link: 199 # Construct URL 200 url = self.list.metadata['url'] # type: ignore 201 path_format_arguments = { 202 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 203 } 204 url = self._client.format_url(url, **path_format_arguments) 205 # Construct parameters 206 query_parameters = {} # type: Dict[str, Any] 207 if filter is not None: 208 query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') 209 if expand is not None: 210 query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') 211 if top is not None: 212 query_parameters['$top'] = self._serialize.query("top", top, 'int') 213 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 214 215 request = self._client.get(url, query_parameters, header_parameters) 216 else: 217 url = next_link 218 query_parameters = {} # type: Dict[str, Any] 219 request = self._client.get(url, query_parameters, header_parameters) 220 return request 221 222 def extract_data(pipeline_response): 223 deserialized = self._deserialize('ResourceListResult', pipeline_response) 224 list_of_elem = deserialized.value 225 if cls: 226 list_of_elem = cls(list_of_elem) 227 return deserialized.next_link or None, iter(list_of_elem) 228 229 def get_next(next_link=None): 230 request = prepare_request(next_link) 231 232 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 233 response = pipeline_response.http_response 234 235 if response.status_code not in [200]: 236 map_error(status_code=response.status_code, response=response, error_map=error_map) 237 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 238 239 return pipeline_response 240 241 return ItemPaged( 242 get_next, extract_data 243 ) 244 list.metadata = {'url': '/subscriptions/{subscriptionId}/resources'} # type: ignore 245 246 def check_existence( 247 self, 248 resource_group_name, # type: str 249 resource_provider_namespace, # type: str 250 parent_resource_path, # type: str 251 resource_type, # type: str 252 resource_name, # type: str 253 api_version, # type: str 254 **kwargs # type: Any 255 ): 256 # type: (...) -> bool 257 """Checks whether resource exists. 258 259 :param resource_group_name: The name of the resource group. The name is case insensitive. 260 :type resource_group_name: str 261 :param resource_provider_namespace: Resource identity. 262 :type resource_provider_namespace: str 263 :param parent_resource_path: Resource identity. 264 :type parent_resource_path: str 265 :param resource_type: Resource identity. 266 :type resource_type: str 267 :param resource_name: Resource identity. 268 :type resource_name: str 269 :param api_version: 270 :type api_version: str 271 :keyword callable cls: A custom type or function that will be passed the direct response 272 :return: bool, or the result of cls(response) 273 :rtype: bool 274 :raises: ~azure.core.exceptions.HttpResponseError 275 """ 276 cls = kwargs.pop('cls', None) # type: ClsType[None] 277 error_map = { 278 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 279 } 280 error_map.update(kwargs.pop('error_map', {})) 281 282 # Construct URL 283 url = self.check_existence.metadata['url'] # type: ignore 284 path_format_arguments = { 285 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 286 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 287 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 288 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 289 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 290 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 291 } 292 url = self._client.format_url(url, **path_format_arguments) 293 294 # Construct parameters 295 query_parameters = {} # type: Dict[str, Any] 296 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 297 298 # Construct headers 299 header_parameters = {} # type: Dict[str, Any] 300 301 request = self._client.head(url, query_parameters, header_parameters) 302 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 303 response = pipeline_response.http_response 304 305 if response.status_code not in [204, 404]: 306 map_error(status_code=response.status_code, response=response, error_map=error_map) 307 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 308 309 if cls: 310 return cls(pipeline_response, None, {}) 311 312 return 200 <= response.status_code <= 299 313 check_existence.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 314 315 def delete( 316 self, 317 resource_group_name, # type: str 318 resource_provider_namespace, # type: str 319 parent_resource_path, # type: str 320 resource_type, # type: str 321 resource_name, # type: str 322 api_version, # type: str 323 **kwargs # type: Any 324 ): 325 # type: (...) -> None 326 """Delete resource and all of its resources. 327 328 :param resource_group_name: The name of the resource group. The name is case insensitive. 329 :type resource_group_name: str 330 :param resource_provider_namespace: Resource identity. 331 :type resource_provider_namespace: str 332 :param parent_resource_path: Resource identity. 333 :type parent_resource_path: str 334 :param resource_type: Resource identity. 335 :type resource_type: str 336 :param resource_name: Resource identity. 337 :type resource_name: str 338 :param api_version: 339 :type api_version: str 340 :keyword callable cls: A custom type or function that will be passed the direct response 341 :return: None, or the result of cls(response) 342 :rtype: None 343 :raises: ~azure.core.exceptions.HttpResponseError 344 """ 345 cls = kwargs.pop('cls', None) # type: ClsType[None] 346 error_map = { 347 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 348 } 349 error_map.update(kwargs.pop('error_map', {})) 350 351 # Construct URL 352 url = self.delete.metadata['url'] # type: ignore 353 path_format_arguments = { 354 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 355 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 356 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 357 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 358 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 359 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 360 } 361 url = self._client.format_url(url, **path_format_arguments) 362 363 # Construct parameters 364 query_parameters = {} # type: Dict[str, Any] 365 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 366 367 # Construct headers 368 header_parameters = {} # type: Dict[str, Any] 369 370 request = self._client.delete(url, query_parameters, header_parameters) 371 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 372 response = pipeline_response.http_response 373 374 if response.status_code not in [200, 202, 204]: 375 map_error(status_code=response.status_code, response=response, error_map=error_map) 376 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 377 378 if cls: 379 return cls(pipeline_response, None, {}) 380 381 delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 382 383 def create_or_update( 384 self, 385 resource_group_name, # type: str 386 resource_provider_namespace, # type: str 387 parent_resource_path, # type: str 388 resource_type, # type: str 389 resource_name, # type: str 390 api_version, # type: str 391 parameters, # type: "_models.GenericResource" 392 **kwargs # type: Any 393 ): 394 # type: (...) -> "_models.GenericResource" 395 """Create a resource. 396 397 :param resource_group_name: The name of the resource group. The name is case insensitive. 398 :type resource_group_name: str 399 :param resource_provider_namespace: Resource identity. 400 :type resource_provider_namespace: str 401 :param parent_resource_path: Resource identity. 402 :type parent_resource_path: str 403 :param resource_type: Resource identity. 404 :type resource_type: str 405 :param resource_name: Resource identity. 406 :type resource_name: str 407 :param api_version: 408 :type api_version: str 409 :param parameters: Create or update resource parameters. 410 :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource 411 :keyword callable cls: A custom type or function that will be passed the direct response 412 :return: GenericResource, or the result of cls(response) 413 :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource 414 :raises: ~azure.core.exceptions.HttpResponseError 415 """ 416 cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] 417 error_map = { 418 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 419 } 420 error_map.update(kwargs.pop('error_map', {})) 421 content_type = kwargs.pop("content_type", "application/json") 422 accept = "application/json" 423 424 # Construct URL 425 url = self.create_or_update.metadata['url'] # type: ignore 426 path_format_arguments = { 427 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 428 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 429 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 430 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 431 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 432 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 433 } 434 url = self._client.format_url(url, **path_format_arguments) 435 436 # Construct parameters 437 query_parameters = {} # type: Dict[str, Any] 438 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 439 440 # Construct headers 441 header_parameters = {} # type: Dict[str, Any] 442 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 443 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 444 445 body_content_kwargs = {} # type: Dict[str, Any] 446 body_content = self._serialize.body(parameters, 'GenericResource') 447 body_content_kwargs['content'] = body_content 448 request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) 449 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 450 response = pipeline_response.http_response 451 452 if response.status_code not in [200, 201]: 453 map_error(status_code=response.status_code, response=response, error_map=error_map) 454 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 455 456 if response.status_code == 200: 457 deserialized = self._deserialize('GenericResource', pipeline_response) 458 459 if response.status_code == 201: 460 deserialized = self._deserialize('GenericResource', pipeline_response) 461 462 if cls: 463 return cls(pipeline_response, deserialized, {}) 464 465 return deserialized 466 create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 467 468 def _update_initial( 469 self, 470 resource_group_name, # type: str 471 resource_provider_namespace, # type: str 472 parent_resource_path, # type: str 473 resource_type, # type: str 474 resource_name, # type: str 475 api_version, # type: str 476 parameters, # type: "_models.GenericResource" 477 **kwargs # type: Any 478 ): 479 # type: (...) -> Optional["_models.GenericResource"] 480 cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.GenericResource"]] 481 error_map = { 482 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 483 } 484 error_map.update(kwargs.pop('error_map', {})) 485 content_type = kwargs.pop("content_type", "application/json") 486 accept = "application/json" 487 488 # Construct URL 489 url = self._update_initial.metadata['url'] # type: ignore 490 path_format_arguments = { 491 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 492 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 493 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 494 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 495 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 496 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 497 } 498 url = self._client.format_url(url, **path_format_arguments) 499 500 # Construct parameters 501 query_parameters = {} # type: Dict[str, Any] 502 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 503 504 # Construct headers 505 header_parameters = {} # type: Dict[str, Any] 506 header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') 507 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 508 509 body_content_kwargs = {} # type: Dict[str, Any] 510 body_content = self._serialize.body(parameters, 'GenericResource') 511 body_content_kwargs['content'] = body_content 512 request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) 513 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 514 response = pipeline_response.http_response 515 516 if response.status_code not in [200, 202]: 517 map_error(status_code=response.status_code, response=response, error_map=error_map) 518 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 519 520 deserialized = None 521 if response.status_code == 200: 522 deserialized = self._deserialize('GenericResource', pipeline_response) 523 524 if cls: 525 return cls(pipeline_response, deserialized, {}) 526 527 return deserialized 528 _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 529 530 def begin_update( 531 self, 532 resource_group_name, # type: str 533 resource_provider_namespace, # type: str 534 parent_resource_path, # type: str 535 resource_type, # type: str 536 resource_name, # type: str 537 api_version, # type: str 538 parameters, # type: "_models.GenericResource" 539 **kwargs # type: Any 540 ): 541 # type: (...) -> LROPoller["_models.GenericResource"] 542 """Updates a resource. 543 544 :param resource_group_name: The name of the resource group for the resource. The name is case 545 insensitive. 546 :type resource_group_name: str 547 :param resource_provider_namespace: The namespace of the resource provider. 548 :type resource_provider_namespace: str 549 :param parent_resource_path: The parent resource identity. 550 :type parent_resource_path: str 551 :param resource_type: The resource type of the resource to update. 552 :type resource_type: str 553 :param resource_name: The name of the resource to update. 554 :type resource_name: str 555 :param api_version: The API version to use for the operation. 556 :type api_version: str 557 :param parameters: Parameters for updating the resource. 558 :type parameters: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource 559 :keyword callable cls: A custom type or function that will be passed the direct response 560 :keyword str continuation_token: A continuation token to restart a poller from a saved state. 561 :keyword polling: By default, your polling method will be ARMPolling. 562 Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. 563 :paramtype polling: bool or ~azure.core.polling.PollingMethod 564 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. 565 :return: An instance of LROPoller that returns either GenericResource or the result of cls(response) 566 :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource] 567 :raises ~azure.core.exceptions.HttpResponseError: 568 """ 569 polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] 570 cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] 571 lro_delay = kwargs.pop( 572 'polling_interval', 573 self._config.polling_interval 574 ) 575 cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] 576 if cont_token is None: 577 raw_result = self._update_initial( 578 resource_group_name=resource_group_name, 579 resource_provider_namespace=resource_provider_namespace, 580 parent_resource_path=parent_resource_path, 581 resource_type=resource_type, 582 resource_name=resource_name, 583 api_version=api_version, 584 parameters=parameters, 585 cls=lambda x,y,z: x, 586 **kwargs 587 ) 588 589 kwargs.pop('error_map', None) 590 kwargs.pop('content_type', None) 591 592 def get_long_running_output(pipeline_response): 593 deserialized = self._deserialize('GenericResource', pipeline_response) 594 595 if cls: 596 return cls(pipeline_response, deserialized, {}) 597 return deserialized 598 599 path_format_arguments = { 600 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 601 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 602 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 603 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 604 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 605 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 606 } 607 608 if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) 609 elif polling is False: polling_method = NoPolling() 610 else: polling_method = polling 611 if cont_token: 612 return LROPoller.from_continuation_token( 613 polling_method=polling_method, 614 continuation_token=cont_token, 615 client=self._client, 616 deserialization_callback=get_long_running_output 617 ) 618 else: 619 return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 620 begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 621 622 def get( 623 self, 624 resource_group_name, # type: str 625 resource_provider_namespace, # type: str 626 parent_resource_path, # type: str 627 resource_type, # type: str 628 resource_name, # type: str 629 api_version, # type: str 630 **kwargs # type: Any 631 ): 632 # type: (...) -> "_models.GenericResource" 633 """Returns a resource belonging to a resource group. 634 635 :param resource_group_name: The name of the resource group. The name is case insensitive. 636 :type resource_group_name: str 637 :param resource_provider_namespace: Resource identity. 638 :type resource_provider_namespace: str 639 :param parent_resource_path: Resource identity. 640 :type parent_resource_path: str 641 :param resource_type: Resource identity. 642 :type resource_type: str 643 :param resource_name: Resource identity. 644 :type resource_name: str 645 :param api_version: 646 :type api_version: str 647 :keyword callable cls: A custom type or function that will be passed the direct response 648 :return: GenericResource, or the result of cls(response) 649 :rtype: ~azure.mgmt.resource.resources.v2016_02_01.models.GenericResource 650 :raises: ~azure.core.exceptions.HttpResponseError 651 """ 652 cls = kwargs.pop('cls', None) # type: ClsType["_models.GenericResource"] 653 error_map = { 654 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError 655 } 656 error_map.update(kwargs.pop('error_map', {})) 657 accept = "application/json" 658 659 # Construct URL 660 url = self.get.metadata['url'] # type: ignore 661 path_format_arguments = { 662 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), 663 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), 664 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), 665 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), 666 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), 667 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), 668 } 669 url = self._client.format_url(url, **path_format_arguments) 670 671 # Construct parameters 672 query_parameters = {} # type: Dict[str, Any] 673 query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') 674 675 # Construct headers 676 header_parameters = {} # type: Dict[str, Any] 677 header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') 678 679 request = self._client.get(url, query_parameters, header_parameters) 680 pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) 681 response = pipeline_response.http_response 682 683 if response.status_code not in [200]: 684 map_error(status_code=response.status_code, response=response, error_map=error_map) 685 raise HttpResponseError(response=response, error_format=ARMErrorFormat) 686 687 deserialized = self._deserialize('GenericResource', pipeline_response) 688 689 if cls: 690 return cls(pipeline_response, deserialized, {}) 691 692 return deserialized 693 get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}'} # type: ignore 694