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.mgmt.core.exceptions import ARMErrorFormat
16
17from .. import models as _models
18
19if TYPE_CHECKING:
20    # pylint: disable=unused-import,ungrouped-imports
21    from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar
22
23    T = TypeVar('T')
24    ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
25
26class DeploymentOperationsOperations(object):
27    """DeploymentOperationsOperations operations.
28
29    You should not instantiate this class directly. Instead, you should create a Client instance that
30    instantiates it for you and attaches it as an attribute.
31
32    :ivar models: Alias to model classes used in this operation group.
33    :type models: ~azure.mgmt.resource.resources.v2020_10_01.models
34    :param client: Client for service requests.
35    :param config: Configuration of service client.
36    :param serializer: An object model serializer.
37    :param deserializer: An object model deserializer.
38    """
39
40    models = _models
41
42    def __init__(self, client, config, serializer, deserializer):
43        self._client = client
44        self._serialize = serializer
45        self._deserialize = deserializer
46        self._config = config
47
48    def get_at_scope(
49        self,
50        scope,  # type: str
51        deployment_name,  # type: str
52        operation_id,  # type: str
53        **kwargs  # type: Any
54    ):
55        # type: (...) -> "_models.DeploymentOperation"
56        """Gets a deployments operation.
57
58        :param scope: The resource scope.
59        :type scope: str
60        :param deployment_name: The name of the deployment.
61        :type deployment_name: str
62        :param operation_id: The ID of the operation to get.
63        :type operation_id: str
64        :keyword callable cls: A custom type or function that will be passed the direct response
65        :return: DeploymentOperation, or the result of cls(response)
66        :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation
67        :raises: ~azure.core.exceptions.HttpResponseError
68        """
69        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperation"]
70        error_map = {
71            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
72        }
73        error_map.update(kwargs.pop('error_map', {}))
74        api_version = "2020-10-01"
75        accept = "application/json"
76
77        # Construct URL
78        url = self.get_at_scope.metadata['url']  # type: ignore
79        path_format_arguments = {
80            'scope': self._serialize.url("scope", scope, 'str', skip_quote=True),
81            'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
82            'operationId': self._serialize.url("operation_id", operation_id, 'str'),
83        }
84        url = self._client.format_url(url, **path_format_arguments)
85
86        # Construct parameters
87        query_parameters = {}  # type: Dict[str, Any]
88        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
89
90        # Construct headers
91        header_parameters = {}  # type: Dict[str, Any]
92        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
93
94        request = self._client.get(url, query_parameters, header_parameters)
95        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
96        response = pipeline_response.http_response
97
98        if response.status_code not in [200]:
99            map_error(status_code=response.status_code, response=response, error_map=error_map)
100            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
101
102        deserialized = self._deserialize('DeploymentOperation', pipeline_response)
103
104        if cls:
105            return cls(pipeline_response, deserialized, {})
106
107        return deserialized
108    get_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'}  # type: ignore
109
110    def list_at_scope(
111        self,
112        scope,  # type: str
113        deployment_name,  # type: str
114        top=None,  # type: Optional[int]
115        **kwargs  # type: Any
116    ):
117        # type: (...) -> Iterable["_models.DeploymentOperationsListResult"]
118        """Gets all deployments operations for a deployment.
119
120        :param scope: The resource scope.
121        :type scope: str
122        :param deployment_name: The name of the deployment.
123        :type deployment_name: str
124        :param top: The number of results to return.
125        :type top: int
126        :keyword callable cls: A custom type or function that will be passed the direct response
127        :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response)
128        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult]
129        :raises: ~azure.core.exceptions.HttpResponseError
130        """
131        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperationsListResult"]
132        error_map = {
133            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
134        }
135        error_map.update(kwargs.pop('error_map', {}))
136        api_version = "2020-10-01"
137        accept = "application/json"
138
139        def prepare_request(next_link=None):
140            # Construct headers
141            header_parameters = {}  # type: Dict[str, Any]
142            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
143
144            if not next_link:
145                # Construct URL
146                url = self.list_at_scope.metadata['url']  # type: ignore
147                path_format_arguments = {
148                    'scope': self._serialize.url("scope", scope, 'str', skip_quote=True),
149                    'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
150                }
151                url = self._client.format_url(url, **path_format_arguments)
152                # Construct parameters
153                query_parameters = {}  # type: Dict[str, Any]
154                if top is not None:
155                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
156                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
157
158                request = self._client.get(url, query_parameters, header_parameters)
159            else:
160                url = next_link
161                query_parameters = {}  # type: Dict[str, Any]
162                request = self._client.get(url, query_parameters, header_parameters)
163            return request
164
165        def extract_data(pipeline_response):
166            deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response)
167            list_of_elem = deserialized.value
168            if cls:
169                list_of_elem = cls(list_of_elem)
170            return deserialized.next_link or None, iter(list_of_elem)
171
172        def get_next(next_link=None):
173            request = prepare_request(next_link)
174
175            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
176            response = pipeline_response.http_response
177
178            if response.status_code not in [200]:
179                map_error(status_code=response.status_code, response=response, error_map=error_map)
180                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
181
182            return pipeline_response
183
184        return ItemPaged(
185            get_next, extract_data
186        )
187    list_at_scope.metadata = {'url': '/{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'}  # type: ignore
188
189    def get_at_tenant_scope(
190        self,
191        deployment_name,  # type: str
192        operation_id,  # type: str
193        **kwargs  # type: Any
194    ):
195        # type: (...) -> "_models.DeploymentOperation"
196        """Gets a deployments operation.
197
198        :param deployment_name: The name of the deployment.
199        :type deployment_name: str
200        :param operation_id: The ID of the operation to get.
201        :type operation_id: str
202        :keyword callable cls: A custom type or function that will be passed the direct response
203        :return: DeploymentOperation, or the result of cls(response)
204        :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation
205        :raises: ~azure.core.exceptions.HttpResponseError
206        """
207        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperation"]
208        error_map = {
209            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
210        }
211        error_map.update(kwargs.pop('error_map', {}))
212        api_version = "2020-10-01"
213        accept = "application/json"
214
215        # Construct URL
216        url = self.get_at_tenant_scope.metadata['url']  # type: ignore
217        path_format_arguments = {
218            'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
219            'operationId': self._serialize.url("operation_id", operation_id, 'str'),
220        }
221        url = self._client.format_url(url, **path_format_arguments)
222
223        # Construct parameters
224        query_parameters = {}  # type: Dict[str, Any]
225        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
226
227        # Construct headers
228        header_parameters = {}  # type: Dict[str, Any]
229        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
230
231        request = self._client.get(url, query_parameters, header_parameters)
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        deserialized = self._deserialize('DeploymentOperation', pipeline_response)
240
241        if cls:
242            return cls(pipeline_response, deserialized, {})
243
244        return deserialized
245    get_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'}  # type: ignore
246
247    def list_at_tenant_scope(
248        self,
249        deployment_name,  # type: str
250        top=None,  # type: Optional[int]
251        **kwargs  # type: Any
252    ):
253        # type: (...) -> Iterable["_models.DeploymentOperationsListResult"]
254        """Gets all deployments operations for a deployment.
255
256        :param deployment_name: The name of the deployment.
257        :type deployment_name: str
258        :param top: The number of results to return.
259        :type top: int
260        :keyword callable cls: A custom type or function that will be passed the direct response
261        :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response)
262        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult]
263        :raises: ~azure.core.exceptions.HttpResponseError
264        """
265        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperationsListResult"]
266        error_map = {
267            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
268        }
269        error_map.update(kwargs.pop('error_map', {}))
270        api_version = "2020-10-01"
271        accept = "application/json"
272
273        def prepare_request(next_link=None):
274            # Construct headers
275            header_parameters = {}  # type: Dict[str, Any]
276            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
277
278            if not next_link:
279                # Construct URL
280                url = self.list_at_tenant_scope.metadata['url']  # type: ignore
281                path_format_arguments = {
282                    'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
283                }
284                url = self._client.format_url(url, **path_format_arguments)
285                # Construct parameters
286                query_parameters = {}  # type: Dict[str, Any]
287                if top is not None:
288                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
289                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
290
291                request = self._client.get(url, query_parameters, header_parameters)
292            else:
293                url = next_link
294                query_parameters = {}  # type: Dict[str, Any]
295                request = self._client.get(url, query_parameters, header_parameters)
296            return request
297
298        def extract_data(pipeline_response):
299            deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response)
300            list_of_elem = deserialized.value
301            if cls:
302                list_of_elem = cls(list_of_elem)
303            return deserialized.next_link or None, iter(list_of_elem)
304
305        def get_next(next_link=None):
306            request = prepare_request(next_link)
307
308            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
309            response = pipeline_response.http_response
310
311            if response.status_code not in [200]:
312                map_error(status_code=response.status_code, response=response, error_map=error_map)
313                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
314
315            return pipeline_response
316
317        return ItemPaged(
318            get_next, extract_data
319        )
320    list_at_tenant_scope.metadata = {'url': '/providers/Microsoft.Resources/deployments/{deploymentName}/operations'}  # type: ignore
321
322    def get_at_management_group_scope(
323        self,
324        group_id,  # type: str
325        deployment_name,  # type: str
326        operation_id,  # type: str
327        **kwargs  # type: Any
328    ):
329        # type: (...) -> "_models.DeploymentOperation"
330        """Gets a deployments operation.
331
332        :param group_id: The management group ID.
333        :type group_id: str
334        :param deployment_name: The name of the deployment.
335        :type deployment_name: str
336        :param operation_id: The ID of the operation to get.
337        :type operation_id: str
338        :keyword callable cls: A custom type or function that will be passed the direct response
339        :return: DeploymentOperation, or the result of cls(response)
340        :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation
341        :raises: ~azure.core.exceptions.HttpResponseError
342        """
343        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperation"]
344        error_map = {
345            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
346        }
347        error_map.update(kwargs.pop('error_map', {}))
348        api_version = "2020-10-01"
349        accept = "application/json"
350
351        # Construct URL
352        url = self.get_at_management_group_scope.metadata['url']  # type: ignore
353        path_format_arguments = {
354            'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1),
355            'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
356            'operationId': self._serialize.url("operation_id", operation_id, 'str'),
357        }
358        url = self._client.format_url(url, **path_format_arguments)
359
360        # Construct parameters
361        query_parameters = {}  # type: Dict[str, Any]
362        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
363
364        # Construct headers
365        header_parameters = {}  # type: Dict[str, Any]
366        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
367
368        request = self._client.get(url, query_parameters, header_parameters)
369        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
370        response = pipeline_response.http_response
371
372        if response.status_code not in [200]:
373            map_error(status_code=response.status_code, response=response, error_map=error_map)
374            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
375
376        deserialized = self._deserialize('DeploymentOperation', pipeline_response)
377
378        if cls:
379            return cls(pipeline_response, deserialized, {})
380
381        return deserialized
382    get_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'}  # type: ignore
383
384    def list_at_management_group_scope(
385        self,
386        group_id,  # type: str
387        deployment_name,  # type: str
388        top=None,  # type: Optional[int]
389        **kwargs  # type: Any
390    ):
391        # type: (...) -> Iterable["_models.DeploymentOperationsListResult"]
392        """Gets all deployments operations for a deployment.
393
394        :param group_id: The management group ID.
395        :type group_id: str
396        :param deployment_name: The name of the deployment.
397        :type deployment_name: str
398        :param top: The number of results to return.
399        :type top: int
400        :keyword callable cls: A custom type or function that will be passed the direct response
401        :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response)
402        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult]
403        :raises: ~azure.core.exceptions.HttpResponseError
404        """
405        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperationsListResult"]
406        error_map = {
407            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
408        }
409        error_map.update(kwargs.pop('error_map', {}))
410        api_version = "2020-10-01"
411        accept = "application/json"
412
413        def prepare_request(next_link=None):
414            # Construct headers
415            header_parameters = {}  # type: Dict[str, Any]
416            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
417
418            if not next_link:
419                # Construct URL
420                url = self.list_at_management_group_scope.metadata['url']  # type: ignore
421                path_format_arguments = {
422                    'groupId': self._serialize.url("group_id", group_id, 'str', max_length=90, min_length=1),
423                    'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
424                }
425                url = self._client.format_url(url, **path_format_arguments)
426                # Construct parameters
427                query_parameters = {}  # type: Dict[str, Any]
428                if top is not None:
429                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
430                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
431
432                request = self._client.get(url, query_parameters, header_parameters)
433            else:
434                url = next_link
435                query_parameters = {}  # type: Dict[str, Any]
436                request = self._client.get(url, query_parameters, header_parameters)
437            return request
438
439        def extract_data(pipeline_response):
440            deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response)
441            list_of_elem = deserialized.value
442            if cls:
443                list_of_elem = cls(list_of_elem)
444            return deserialized.next_link or None, iter(list_of_elem)
445
446        def get_next(next_link=None):
447            request = prepare_request(next_link)
448
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]:
453                map_error(status_code=response.status_code, response=response, error_map=error_map)
454                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
455
456            return pipeline_response
457
458        return ItemPaged(
459            get_next, extract_data
460        )
461    list_at_management_group_scope.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'}  # type: ignore
462
463    def get_at_subscription_scope(
464        self,
465        deployment_name,  # type: str
466        operation_id,  # type: str
467        **kwargs  # type: Any
468    ):
469        # type: (...) -> "_models.DeploymentOperation"
470        """Gets a deployments operation.
471
472        :param deployment_name: The name of the deployment.
473        :type deployment_name: str
474        :param operation_id: The ID of the operation to get.
475        :type operation_id: str
476        :keyword callable cls: A custom type or function that will be passed the direct response
477        :return: DeploymentOperation, or the result of cls(response)
478        :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation
479        :raises: ~azure.core.exceptions.HttpResponseError
480        """
481        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperation"]
482        error_map = {
483            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
484        }
485        error_map.update(kwargs.pop('error_map', {}))
486        api_version = "2020-10-01"
487        accept = "application/json"
488
489        # Construct URL
490        url = self.get_at_subscription_scope.metadata['url']  # type: ignore
491        path_format_arguments = {
492            'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
493            'operationId': self._serialize.url("operation_id", operation_id, 'str'),
494            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
495        }
496        url = self._client.format_url(url, **path_format_arguments)
497
498        # Construct parameters
499        query_parameters = {}  # type: Dict[str, Any]
500        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
501
502        # Construct headers
503        header_parameters = {}  # type: Dict[str, Any]
504        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
505
506        request = self._client.get(url, query_parameters, header_parameters)
507        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
508        response = pipeline_response.http_response
509
510        if response.status_code not in [200]:
511            map_error(status_code=response.status_code, response=response, error_map=error_map)
512            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
513
514        deserialized = self._deserialize('DeploymentOperation', pipeline_response)
515
516        if cls:
517            return cls(pipeline_response, deserialized, {})
518
519        return deserialized
520    get_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}'}  # type: ignore
521
522    def list_at_subscription_scope(
523        self,
524        deployment_name,  # type: str
525        top=None,  # type: Optional[int]
526        **kwargs  # type: Any
527    ):
528        # type: (...) -> Iterable["_models.DeploymentOperationsListResult"]
529        """Gets all deployments operations for a deployment.
530
531        :param deployment_name: The name of the deployment.
532        :type deployment_name: str
533        :param top: The number of results to return.
534        :type top: int
535        :keyword callable cls: A custom type or function that will be passed the direct response
536        :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response)
537        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult]
538        :raises: ~azure.core.exceptions.HttpResponseError
539        """
540        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperationsListResult"]
541        error_map = {
542            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
543        }
544        error_map.update(kwargs.pop('error_map', {}))
545        api_version = "2020-10-01"
546        accept = "application/json"
547
548        def prepare_request(next_link=None):
549            # Construct headers
550            header_parameters = {}  # type: Dict[str, Any]
551            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
552
553            if not next_link:
554                # Construct URL
555                url = self.list_at_subscription_scope.metadata['url']  # type: ignore
556                path_format_arguments = {
557                    'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
558                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
559                }
560                url = self._client.format_url(url, **path_format_arguments)
561                # Construct parameters
562                query_parameters = {}  # type: Dict[str, Any]
563                if top is not None:
564                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
565                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
566
567                request = self._client.get(url, query_parameters, header_parameters)
568            else:
569                url = next_link
570                query_parameters = {}  # type: Dict[str, Any]
571                request = self._client.get(url, query_parameters, header_parameters)
572            return request
573
574        def extract_data(pipeline_response):
575            deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response)
576            list_of_elem = deserialized.value
577            if cls:
578                list_of_elem = cls(list_of_elem)
579            return deserialized.next_link or None, iter(list_of_elem)
580
581        def get_next(next_link=None):
582            request = prepare_request(next_link)
583
584            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
585            response = pipeline_response.http_response
586
587            if response.status_code not in [200]:
588                map_error(status_code=response.status_code, response=response, error_map=error_map)
589                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
590
591            return pipeline_response
592
593        return ItemPaged(
594            get_next, extract_data
595        )
596    list_at_subscription_scope.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations'}  # type: ignore
597
598    def get(
599        self,
600        resource_group_name,  # type: str
601        deployment_name,  # type: str
602        operation_id,  # type: str
603        **kwargs  # type: Any
604    ):
605        # type: (...) -> "_models.DeploymentOperation"
606        """Gets a deployments operation.
607
608        :param resource_group_name: The name of the resource group. The name is case insensitive.
609        :type resource_group_name: str
610        :param deployment_name: The name of the deployment.
611        :type deployment_name: str
612        :param operation_id: The ID of the operation to get.
613        :type operation_id: str
614        :keyword callable cls: A custom type or function that will be passed the direct response
615        :return: DeploymentOperation, or the result of cls(response)
616        :rtype: ~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperation
617        :raises: ~azure.core.exceptions.HttpResponseError
618        """
619        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperation"]
620        error_map = {
621            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
622        }
623        error_map.update(kwargs.pop('error_map', {}))
624        api_version = "2020-10-01"
625        accept = "application/json"
626
627        # Construct URL
628        url = self.get.metadata['url']  # type: ignore
629        path_format_arguments = {
630            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1),
631            'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
632            'operationId': self._serialize.url("operation_id", operation_id, 'str'),
633            'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
634        }
635        url = self._client.format_url(url, **path_format_arguments)
636
637        # Construct parameters
638        query_parameters = {}  # type: Dict[str, Any]
639        query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
640
641        # Construct headers
642        header_parameters = {}  # type: Dict[str, Any]
643        header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
644
645        request = self._client.get(url, query_parameters, header_parameters)
646        pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
647        response = pipeline_response.http_response
648
649        if response.status_code not in [200]:
650            map_error(status_code=response.status_code, response=response, error_map=error_map)
651            raise HttpResponseError(response=response, error_format=ARMErrorFormat)
652
653        deserialized = self._deserialize('DeploymentOperation', pipeline_response)
654
655        if cls:
656            return cls(pipeline_response, deserialized, {})
657
658        return deserialized
659    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}'}  # type: ignore
660
661    def list(
662        self,
663        resource_group_name,  # type: str
664        deployment_name,  # type: str
665        top=None,  # type: Optional[int]
666        **kwargs  # type: Any
667    ):
668        # type: (...) -> Iterable["_models.DeploymentOperationsListResult"]
669        """Gets all deployments operations for a deployment.
670
671        :param resource_group_name: The name of the resource group. The name is case insensitive.
672        :type resource_group_name: str
673        :param deployment_name: The name of the deployment.
674        :type deployment_name: str
675        :param top: The number of results to return.
676        :type top: int
677        :keyword callable cls: A custom type or function that will be passed the direct response
678        :return: An iterator like instance of either DeploymentOperationsListResult or the result of cls(response)
679        :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resource.resources.v2020_10_01.models.DeploymentOperationsListResult]
680        :raises: ~azure.core.exceptions.HttpResponseError
681        """
682        cls = kwargs.pop('cls', None)  # type: ClsType["_models.DeploymentOperationsListResult"]
683        error_map = {
684            401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
685        }
686        error_map.update(kwargs.pop('error_map', {}))
687        api_version = "2020-10-01"
688        accept = "application/json"
689
690        def prepare_request(next_link=None):
691            # Construct headers
692            header_parameters = {}  # type: Dict[str, Any]
693            header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
694
695            if not next_link:
696                # Construct URL
697                url = self.list.metadata['url']  # type: ignore
698                path_format_arguments = {
699                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1),
700                    'deploymentName': self._serialize.url("deployment_name", deployment_name, 'str', max_length=64, min_length=1),
701                    'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
702                }
703                url = self._client.format_url(url, **path_format_arguments)
704                # Construct parameters
705                query_parameters = {}  # type: Dict[str, Any]
706                if top is not None:
707                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
708                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
709
710                request = self._client.get(url, query_parameters, header_parameters)
711            else:
712                url = next_link
713                query_parameters = {}  # type: Dict[str, Any]
714                request = self._client.get(url, query_parameters, header_parameters)
715            return request
716
717        def extract_data(pipeline_response):
718            deserialized = self._deserialize('DeploymentOperationsListResult', pipeline_response)
719            list_of_elem = deserialized.value
720            if cls:
721                list_of_elem = cls(list_of_elem)
722            return deserialized.next_link or None, iter(list_of_elem)
723
724        def get_next(next_link=None):
725            request = prepare_request(next_link)
726
727            pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
728            response = pipeline_response.http_response
729
730            if response.status_code not in [200]:
731                map_error(status_code=response.status_code, response=response, error_map=error_map)
732                raise HttpResponseError(response=response, error_format=ARMErrorFormat)
733
734            return pipeline_response
735
736        return ItemPaged(
737            get_next, extract_data
738        )
739    list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations'}  # type: ignore
740