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
12import uuid
13from msrest.pipeline import ClientRawResponse
14from msrestazure.azure_exceptions import CloudError
15from msrest.polling import LROPoller, NoPolling
16from msrestazure.polling.arm_polling import ARMPolling
17
18from .. import models
19
20
21class VirtualMachinesOperations(object):
22    """VirtualMachinesOperations operations.
23
24    You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.
25
26    :param client: Client for service requests.
27    :param config: Configuration of service client.
28    :param serializer: An object model serializer.
29    :param deserializer: An object model deserializer.
30    :ivar api_version: Client API version. Constant value: "2018-09-15".
31    """
32
33    models = models
34
35    def __init__(self, client, config, serializer, deserializer):
36
37        self._client = client
38        self._serialize = serializer
39        self._deserialize = deserializer
40        self.api_version = "2018-09-15"
41
42        self.config = config
43
44    def list(
45            self, resource_group_name, lab_name, expand=None, filter=None, top=None, orderby=None, custom_headers=None, raw=False, **operation_config):
46        """List virtual machines in a given lab.
47
48        :param resource_group_name: The name of the resource group.
49        :type resource_group_name: str
50        :param lab_name: The name of the lab.
51        :type lab_name: str
52        :param expand: Specify the $expand query. Example:
53         'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
54        :type expand: str
55        :param filter: The filter to apply to the operation. Example:
56         '$filter=contains(name,'myName')
57        :type filter: str
58        :param top: The maximum number of resources to return from the
59         operation. Example: '$top=10'
60        :type top: int
61        :param orderby: The ordering expression for the results, using OData
62         notation. Example: '$orderby=name desc'
63        :type orderby: str
64        :param dict custom_headers: headers that will be added to the request
65        :param bool raw: returns the direct response alongside the
66         deserialized response
67        :param operation_config: :ref:`Operation configuration
68         overrides<msrest:optionsforoperations>`.
69        :return: An iterator like instance of LabVirtualMachine
70        :rtype:
71         ~azure.mgmt.devtestlabs.models.LabVirtualMachinePaged[~azure.mgmt.devtestlabs.models.LabVirtualMachine]
72        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
73        """
74        def prepare_request(next_link=None):
75            if not next_link:
76                # Construct URL
77                url = self.list.metadata['url']
78                path_format_arguments = {
79                    'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
80                    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
81                    'labName': self._serialize.url("lab_name", lab_name, 'str')
82                }
83                url = self._client.format_url(url, **path_format_arguments)
84
85                # Construct parameters
86                query_parameters = {}
87                if expand is not None:
88                    query_parameters['$expand'] = self._serialize.query("expand", expand, 'str')
89                if filter is not None:
90                    query_parameters['$filter'] = self._serialize.query("filter", filter, 'str')
91                if top is not None:
92                    query_parameters['$top'] = self._serialize.query("top", top, 'int')
93                if orderby is not None:
94                    query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str')
95                query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
96
97            else:
98                url = next_link
99                query_parameters = {}
100
101            # Construct headers
102            header_parameters = {}
103            header_parameters['Accept'] = 'application/json'
104            if self.config.generate_client_request_id:
105                header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
106            if custom_headers:
107                header_parameters.update(custom_headers)
108            if self.config.accept_language is not None:
109                header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
110
111            # Construct and send request
112            request = self._client.get(url, query_parameters, header_parameters)
113            return request
114
115        def internal_paging(next_link=None):
116            request = prepare_request(next_link)
117
118            response = self._client.send(request, stream=False, **operation_config)
119
120            if response.status_code not in [200]:
121                exp = CloudError(response)
122                exp.request_id = response.headers.get('x-ms-request-id')
123                raise exp
124
125            return response
126
127        # Deserialize response
128        header_dict = None
129        if raw:
130            header_dict = {}
131        deserialized = models.LabVirtualMachinePaged(internal_paging, self._deserialize.dependencies, header_dict)
132
133        return deserialized
134    list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines'}
135
136    def get(
137            self, resource_group_name, lab_name, name, expand=None, custom_headers=None, raw=False, **operation_config):
138        """Get virtual machine.
139
140        :param resource_group_name: The name of the resource group.
141        :type resource_group_name: str
142        :param lab_name: The name of the lab.
143        :type lab_name: str
144        :param name: The name of the virtual machine.
145        :type name: str
146        :param expand: Specify the $expand query. Example:
147         'properties($expand=artifacts,computeVm,networkInterface,applicableSchedule)'
148        :type expand: str
149        :param dict custom_headers: headers that will be added to the request
150        :param bool raw: returns the direct response alongside the
151         deserialized response
152        :param operation_config: :ref:`Operation configuration
153         overrides<msrest:optionsforoperations>`.
154        :return: LabVirtualMachine or ClientRawResponse if raw=true
155        :rtype: ~azure.mgmt.devtestlabs.models.LabVirtualMachine or
156         ~msrest.pipeline.ClientRawResponse
157        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
158        """
159        # Construct URL
160        url = self.get.metadata['url']
161        path_format_arguments = {
162            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
163            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
164            'labName': self._serialize.url("lab_name", lab_name, 'str'),
165            'name': self._serialize.url("name", name, 'str')
166        }
167        url = self._client.format_url(url, **path_format_arguments)
168
169        # Construct parameters
170        query_parameters = {}
171        if expand is not None:
172            query_parameters['$expand'] = self._serialize.query("expand", expand, 'str')
173        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
174
175        # Construct headers
176        header_parameters = {}
177        header_parameters['Accept'] = 'application/json'
178        if self.config.generate_client_request_id:
179            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
180        if custom_headers:
181            header_parameters.update(custom_headers)
182        if self.config.accept_language is not None:
183            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
184
185        # Construct and send request
186        request = self._client.get(url, query_parameters, header_parameters)
187        response = self._client.send(request, stream=False, **operation_config)
188
189        if response.status_code not in [200]:
190            exp = CloudError(response)
191            exp.request_id = response.headers.get('x-ms-request-id')
192            raise exp
193
194        deserialized = None
195        if response.status_code == 200:
196            deserialized = self._deserialize('LabVirtualMachine', response)
197
198        if raw:
199            client_raw_response = ClientRawResponse(deserialized, response)
200            return client_raw_response
201
202        return deserialized
203    get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'}
204
205
206    def _create_or_update_initial(
207            self, resource_group_name, lab_name, name, lab_virtual_machine, custom_headers=None, raw=False, **operation_config):
208        # Construct URL
209        url = self.create_or_update.metadata['url']
210        path_format_arguments = {
211            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
212            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
213            'labName': self._serialize.url("lab_name", lab_name, 'str'),
214            'name': self._serialize.url("name", name, 'str')
215        }
216        url = self._client.format_url(url, **path_format_arguments)
217
218        # Construct parameters
219        query_parameters = {}
220        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
221
222        # Construct headers
223        header_parameters = {}
224        header_parameters['Accept'] = 'application/json'
225        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
226        if self.config.generate_client_request_id:
227            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
228        if custom_headers:
229            header_parameters.update(custom_headers)
230        if self.config.accept_language is not None:
231            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
232
233        # Construct body
234        body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachine')
235
236        # Construct and send request
237        request = self._client.put(url, query_parameters, header_parameters, body_content)
238        response = self._client.send(request, stream=False, **operation_config)
239
240        if response.status_code not in [200, 201]:
241            exp = CloudError(response)
242            exp.request_id = response.headers.get('x-ms-request-id')
243            raise exp
244
245        deserialized = None
246
247        if response.status_code == 200:
248            deserialized = self._deserialize('LabVirtualMachine', response)
249        if response.status_code == 201:
250            deserialized = self._deserialize('LabVirtualMachine', response)
251
252        if raw:
253            client_raw_response = ClientRawResponse(deserialized, response)
254            return client_raw_response
255
256        return deserialized
257
258    def create_or_update(
259            self, resource_group_name, lab_name, name, lab_virtual_machine, custom_headers=None, raw=False, polling=True, **operation_config):
260        """Create or replace an existing virtual machine. This operation can take
261        a while to complete.
262
263        :param resource_group_name: The name of the resource group.
264        :type resource_group_name: str
265        :param lab_name: The name of the lab.
266        :type lab_name: str
267        :param name: The name of the virtual machine.
268        :type name: str
269        :param lab_virtual_machine: A virtual machine.
270        :type lab_virtual_machine:
271         ~azure.mgmt.devtestlabs.models.LabVirtualMachine
272        :param dict custom_headers: headers that will be added to the request
273        :param bool raw: The poller return type is ClientRawResponse, the
274         direct response alongside the deserialized response
275        :param polling: True for ARMPolling, False for no polling, or a
276         polling object for personal polling strategy
277        :return: An instance of LROPoller that returns LabVirtualMachine or
278         ClientRawResponse<LabVirtualMachine> if raw==True
279        :rtype:
280         ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.devtestlabs.models.LabVirtualMachine]
281         or
282         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.devtestlabs.models.LabVirtualMachine]]
283        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
284        """
285        raw_result = self._create_or_update_initial(
286            resource_group_name=resource_group_name,
287            lab_name=lab_name,
288            name=name,
289            lab_virtual_machine=lab_virtual_machine,
290            custom_headers=custom_headers,
291            raw=True,
292            **operation_config
293        )
294
295        def get_long_running_output(response):
296            deserialized = self._deserialize('LabVirtualMachine', response)
297
298            if raw:
299                client_raw_response = ClientRawResponse(deserialized, response)
300                return client_raw_response
301
302            return deserialized
303
304        lro_delay = operation_config.get(
305            'long_running_operation_timeout',
306            self.config.long_running_operation_timeout)
307        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
308        elif polling is False: polling_method = NoPolling()
309        else: polling_method = polling
310        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
311    create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'}
312
313
314    def _delete_initial(
315            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
316        # Construct URL
317        url = self.delete.metadata['url']
318        path_format_arguments = {
319            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
320            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
321            'labName': self._serialize.url("lab_name", lab_name, 'str'),
322            'name': self._serialize.url("name", name, 'str')
323        }
324        url = self._client.format_url(url, **path_format_arguments)
325
326        # Construct parameters
327        query_parameters = {}
328        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
329
330        # Construct headers
331        header_parameters = {}
332        if self.config.generate_client_request_id:
333            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
334        if custom_headers:
335            header_parameters.update(custom_headers)
336        if self.config.accept_language is not None:
337            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
338
339        # Construct and send request
340        request = self._client.delete(url, query_parameters, header_parameters)
341        response = self._client.send(request, stream=False, **operation_config)
342
343        if response.status_code not in [200, 202, 204]:
344            exp = CloudError(response)
345            exp.request_id = response.headers.get('x-ms-request-id')
346            raise exp
347
348        if raw:
349            client_raw_response = ClientRawResponse(None, response)
350            return client_raw_response
351
352    def delete(
353            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
354        """Delete virtual machine. This operation can take a while to complete.
355
356        :param resource_group_name: The name of the resource group.
357        :type resource_group_name: str
358        :param lab_name: The name of the lab.
359        :type lab_name: str
360        :param name: The name of the virtual machine.
361        :type name: str
362        :param dict custom_headers: headers that will be added to the request
363        :param bool raw: The poller return type is ClientRawResponse, the
364         direct response alongside the deserialized response
365        :param polling: True for ARMPolling, False for no polling, or a
366         polling object for personal polling strategy
367        :return: An instance of LROPoller that returns None or
368         ClientRawResponse<None> if raw==True
369        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
370         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
371        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
372        """
373        raw_result = self._delete_initial(
374            resource_group_name=resource_group_name,
375            lab_name=lab_name,
376            name=name,
377            custom_headers=custom_headers,
378            raw=True,
379            **operation_config
380        )
381
382        def get_long_running_output(response):
383            if raw:
384                client_raw_response = ClientRawResponse(None, response)
385                return client_raw_response
386
387        lro_delay = operation_config.get(
388            'long_running_operation_timeout',
389            self.config.long_running_operation_timeout)
390        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
391        elif polling is False: polling_method = NoPolling()
392        else: polling_method = polling
393        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
394    delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'}
395
396    def update(
397            self, resource_group_name, lab_name, name, lab_virtual_machine, custom_headers=None, raw=False, **operation_config):
398        """Allows modifying tags of virtual machines. All other properties will be
399        ignored.
400
401        :param resource_group_name: The name of the resource group.
402        :type resource_group_name: str
403        :param lab_name: The name of the lab.
404        :type lab_name: str
405        :param name: The name of the virtual machine.
406        :type name: str
407        :param lab_virtual_machine: A virtual machine.
408        :type lab_virtual_machine:
409         ~azure.mgmt.devtestlabs.models.LabVirtualMachineFragment
410        :param dict custom_headers: headers that will be added to the request
411        :param bool raw: returns the direct response alongside the
412         deserialized response
413        :param operation_config: :ref:`Operation configuration
414         overrides<msrest:optionsforoperations>`.
415        :return: LabVirtualMachine or ClientRawResponse if raw=true
416        :rtype: ~azure.mgmt.devtestlabs.models.LabVirtualMachine or
417         ~msrest.pipeline.ClientRawResponse
418        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
419        """
420        # Construct URL
421        url = self.update.metadata['url']
422        path_format_arguments = {
423            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
424            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
425            'labName': self._serialize.url("lab_name", lab_name, 'str'),
426            'name': self._serialize.url("name", name, 'str')
427        }
428        url = self._client.format_url(url, **path_format_arguments)
429
430        # Construct parameters
431        query_parameters = {}
432        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
433
434        # Construct headers
435        header_parameters = {}
436        header_parameters['Accept'] = 'application/json'
437        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
438        if self.config.generate_client_request_id:
439            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
440        if custom_headers:
441            header_parameters.update(custom_headers)
442        if self.config.accept_language is not None:
443            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
444
445        # Construct body
446        body_content = self._serialize.body(lab_virtual_machine, 'LabVirtualMachineFragment')
447
448        # Construct and send request
449        request = self._client.patch(url, query_parameters, header_parameters, body_content)
450        response = self._client.send(request, stream=False, **operation_config)
451
452        if response.status_code not in [200]:
453            exp = CloudError(response)
454            exp.request_id = response.headers.get('x-ms-request-id')
455            raise exp
456
457        deserialized = None
458        if response.status_code == 200:
459            deserialized = self._deserialize('LabVirtualMachine', response)
460
461        if raw:
462            client_raw_response = ClientRawResponse(deserialized, response)
463            return client_raw_response
464
465        return deserialized
466    update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}'}
467
468
469    def _add_data_disk_initial(
470            self, resource_group_name, lab_name, name, data_disk_properties, custom_headers=None, raw=False, **operation_config):
471        # Construct URL
472        url = self.add_data_disk.metadata['url']
473        path_format_arguments = {
474            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
475            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
476            'labName': self._serialize.url("lab_name", lab_name, 'str'),
477            'name': self._serialize.url("name", name, 'str')
478        }
479        url = self._client.format_url(url, **path_format_arguments)
480
481        # Construct parameters
482        query_parameters = {}
483        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
484
485        # Construct headers
486        header_parameters = {}
487        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
488        if self.config.generate_client_request_id:
489            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
490        if custom_headers:
491            header_parameters.update(custom_headers)
492        if self.config.accept_language is not None:
493            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
494
495        # Construct body
496        body_content = self._serialize.body(data_disk_properties, 'DataDiskProperties')
497
498        # Construct and send request
499        request = self._client.post(url, query_parameters, header_parameters, body_content)
500        response = self._client.send(request, stream=False, **operation_config)
501
502        if response.status_code not in [200, 202]:
503            exp = CloudError(response)
504            exp.request_id = response.headers.get('x-ms-request-id')
505            raise exp
506
507        if raw:
508            client_raw_response = ClientRawResponse(None, response)
509            return client_raw_response
510
511    def add_data_disk(
512            self, resource_group_name, lab_name, name, data_disk_properties, custom_headers=None, raw=False, polling=True, **operation_config):
513        """Attach a new or existing data disk to virtual machine. This operation
514        can take a while to complete.
515
516        :param resource_group_name: The name of the resource group.
517        :type resource_group_name: str
518        :param lab_name: The name of the lab.
519        :type lab_name: str
520        :param name: The name of the virtual machine.
521        :type name: str
522        :param data_disk_properties: Request body for adding a new or existing
523         data disk to a virtual machine.
524        :type data_disk_properties:
525         ~azure.mgmt.devtestlabs.models.DataDiskProperties
526        :param dict custom_headers: headers that will be added to the request
527        :param bool raw: The poller return type is ClientRawResponse, the
528         direct response alongside the deserialized response
529        :param polling: True for ARMPolling, False for no polling, or a
530         polling object for personal polling strategy
531        :return: An instance of LROPoller that returns None or
532         ClientRawResponse<None> if raw==True
533        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
534         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
535        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
536        """
537        raw_result = self._add_data_disk_initial(
538            resource_group_name=resource_group_name,
539            lab_name=lab_name,
540            name=name,
541            data_disk_properties=data_disk_properties,
542            custom_headers=custom_headers,
543            raw=True,
544            **operation_config
545        )
546
547        def get_long_running_output(response):
548            if raw:
549                client_raw_response = ClientRawResponse(None, response)
550                return client_raw_response
551
552        lro_delay = operation_config.get(
553            'long_running_operation_timeout',
554            self.config.long_running_operation_timeout)
555        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
556        elif polling is False: polling_method = NoPolling()
557        else: polling_method = polling
558        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
559    add_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/addDataDisk'}
560
561
562    def _apply_artifacts_initial(
563            self, resource_group_name, lab_name, name, artifacts=None, custom_headers=None, raw=False, **operation_config):
564        apply_artifacts_request = models.ApplyArtifactsRequest(artifacts=artifacts)
565
566        # Construct URL
567        url = self.apply_artifacts.metadata['url']
568        path_format_arguments = {
569            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
570            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
571            'labName': self._serialize.url("lab_name", lab_name, 'str'),
572            'name': self._serialize.url("name", name, 'str')
573        }
574        url = self._client.format_url(url, **path_format_arguments)
575
576        # Construct parameters
577        query_parameters = {}
578        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
579
580        # Construct headers
581        header_parameters = {}
582        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
583        if self.config.generate_client_request_id:
584            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
585        if custom_headers:
586            header_parameters.update(custom_headers)
587        if self.config.accept_language is not None:
588            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
589
590        # Construct body
591        body_content = self._serialize.body(apply_artifacts_request, 'ApplyArtifactsRequest')
592
593        # Construct and send request
594        request = self._client.post(url, query_parameters, header_parameters, body_content)
595        response = self._client.send(request, stream=False, **operation_config)
596
597        if response.status_code not in [200, 202]:
598            exp = CloudError(response)
599            exp.request_id = response.headers.get('x-ms-request-id')
600            raise exp
601
602        if raw:
603            client_raw_response = ClientRawResponse(None, response)
604            return client_raw_response
605
606    def apply_artifacts(
607            self, resource_group_name, lab_name, name, artifacts=None, custom_headers=None, raw=False, polling=True, **operation_config):
608        """Apply artifacts to virtual machine. This operation can take a while to
609        complete.
610
611        :param resource_group_name: The name of the resource group.
612        :type resource_group_name: str
613        :param lab_name: The name of the lab.
614        :type lab_name: str
615        :param name: The name of the virtual machine.
616        :type name: str
617        :param artifacts: The list of artifacts to apply.
618        :type artifacts:
619         list[~azure.mgmt.devtestlabs.models.ArtifactInstallProperties]
620        :param dict custom_headers: headers that will be added to the request
621        :param bool raw: The poller return type is ClientRawResponse, the
622         direct response alongside the deserialized response
623        :param polling: True for ARMPolling, False for no polling, or a
624         polling object for personal polling strategy
625        :return: An instance of LROPoller that returns None or
626         ClientRawResponse<None> if raw==True
627        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
628         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
629        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
630        """
631        raw_result = self._apply_artifacts_initial(
632            resource_group_name=resource_group_name,
633            lab_name=lab_name,
634            name=name,
635            artifacts=artifacts,
636            custom_headers=custom_headers,
637            raw=True,
638            **operation_config
639        )
640
641        def get_long_running_output(response):
642            if raw:
643                client_raw_response = ClientRawResponse(None, response)
644                return client_raw_response
645
646        lro_delay = operation_config.get(
647            'long_running_operation_timeout',
648            self.config.long_running_operation_timeout)
649        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
650        elif polling is False: polling_method = NoPolling()
651        else: polling_method = polling
652        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
653    apply_artifacts.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/applyArtifacts'}
654
655
656    def _claim_initial(
657            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
658        # Construct URL
659        url = self.claim.metadata['url']
660        path_format_arguments = {
661            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
662            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
663            'labName': self._serialize.url("lab_name", lab_name, 'str'),
664            'name': self._serialize.url("name", name, 'str')
665        }
666        url = self._client.format_url(url, **path_format_arguments)
667
668        # Construct parameters
669        query_parameters = {}
670        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
671
672        # Construct headers
673        header_parameters = {}
674        if self.config.generate_client_request_id:
675            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
676        if custom_headers:
677            header_parameters.update(custom_headers)
678        if self.config.accept_language is not None:
679            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
680
681        # Construct and send request
682        request = self._client.post(url, query_parameters, header_parameters)
683        response = self._client.send(request, stream=False, **operation_config)
684
685        if response.status_code not in [200, 202]:
686            exp = CloudError(response)
687            exp.request_id = response.headers.get('x-ms-request-id')
688            raise exp
689
690        if raw:
691            client_raw_response = ClientRawResponse(None, response)
692            return client_raw_response
693
694    def claim(
695            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
696        """Take ownership of an existing virtual machine This operation can take a
697        while to complete.
698
699        :param resource_group_name: The name of the resource group.
700        :type resource_group_name: str
701        :param lab_name: The name of the lab.
702        :type lab_name: str
703        :param name: The name of the virtual machine.
704        :type name: str
705        :param dict custom_headers: headers that will be added to the request
706        :param bool raw: The poller return type is ClientRawResponse, the
707         direct response alongside the deserialized response
708        :param polling: True for ARMPolling, False for no polling, or a
709         polling object for personal polling strategy
710        :return: An instance of LROPoller that returns None or
711         ClientRawResponse<None> if raw==True
712        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
713         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
714        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
715        """
716        raw_result = self._claim_initial(
717            resource_group_name=resource_group_name,
718            lab_name=lab_name,
719            name=name,
720            custom_headers=custom_headers,
721            raw=True,
722            **operation_config
723        )
724
725        def get_long_running_output(response):
726            if raw:
727                client_raw_response = ClientRawResponse(None, response)
728                return client_raw_response
729
730        lro_delay = operation_config.get(
731            'long_running_operation_timeout',
732            self.config.long_running_operation_timeout)
733        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
734        elif polling is False: polling_method = NoPolling()
735        else: polling_method = polling
736        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
737    claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/claim'}
738
739
740    def _detach_data_disk_initial(
741            self, resource_group_name, lab_name, name, existing_lab_disk_id=None, custom_headers=None, raw=False, **operation_config):
742        detach_data_disk_properties = models.DetachDataDiskProperties(existing_lab_disk_id=existing_lab_disk_id)
743
744        # Construct URL
745        url = self.detach_data_disk.metadata['url']
746        path_format_arguments = {
747            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
748            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
749            'labName': self._serialize.url("lab_name", lab_name, 'str'),
750            'name': self._serialize.url("name", name, 'str')
751        }
752        url = self._client.format_url(url, **path_format_arguments)
753
754        # Construct parameters
755        query_parameters = {}
756        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
757
758        # Construct headers
759        header_parameters = {}
760        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
761        if self.config.generate_client_request_id:
762            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
763        if custom_headers:
764            header_parameters.update(custom_headers)
765        if self.config.accept_language is not None:
766            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
767
768        # Construct body
769        body_content = self._serialize.body(detach_data_disk_properties, 'DetachDataDiskProperties')
770
771        # Construct and send request
772        request = self._client.post(url, query_parameters, header_parameters, body_content)
773        response = self._client.send(request, stream=False, **operation_config)
774
775        if response.status_code not in [200, 202]:
776            exp = CloudError(response)
777            exp.request_id = response.headers.get('x-ms-request-id')
778            raise exp
779
780        if raw:
781            client_raw_response = ClientRawResponse(None, response)
782            return client_raw_response
783
784    def detach_data_disk(
785            self, resource_group_name, lab_name, name, existing_lab_disk_id=None, custom_headers=None, raw=False, polling=True, **operation_config):
786        """Detach the specified disk from the virtual machine. This operation can
787        take a while to complete.
788
789        :param resource_group_name: The name of the resource group.
790        :type resource_group_name: str
791        :param lab_name: The name of the lab.
792        :type lab_name: str
793        :param name: The name of the virtual machine.
794        :type name: str
795        :param existing_lab_disk_id: Specifies the disk resource ID to detach
796         from virtual machine.
797        :type existing_lab_disk_id: str
798        :param dict custom_headers: headers that will be added to the request
799        :param bool raw: The poller return type is ClientRawResponse, the
800         direct response alongside the deserialized response
801        :param polling: True for ARMPolling, False for no polling, or a
802         polling object for personal polling strategy
803        :return: An instance of LROPoller that returns None or
804         ClientRawResponse<None> if raw==True
805        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
806         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
807        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
808        """
809        raw_result = self._detach_data_disk_initial(
810            resource_group_name=resource_group_name,
811            lab_name=lab_name,
812            name=name,
813            existing_lab_disk_id=existing_lab_disk_id,
814            custom_headers=custom_headers,
815            raw=True,
816            **operation_config
817        )
818
819        def get_long_running_output(response):
820            if raw:
821                client_raw_response = ClientRawResponse(None, response)
822                return client_raw_response
823
824        lro_delay = operation_config.get(
825            'long_running_operation_timeout',
826            self.config.long_running_operation_timeout)
827        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
828        elif polling is False: polling_method = NoPolling()
829        else: polling_method = polling
830        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
831    detach_data_disk.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/detachDataDisk'}
832
833    def get_rdp_file_contents(
834            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
835        """Gets a string that represents the contents of the RDP file for the
836        virtual machine.
837
838        :param resource_group_name: The name of the resource group.
839        :type resource_group_name: str
840        :param lab_name: The name of the lab.
841        :type lab_name: str
842        :param name: The name of the virtual machine.
843        :type name: str
844        :param dict custom_headers: headers that will be added to the request
845        :param bool raw: returns the direct response alongside the
846         deserialized response
847        :param operation_config: :ref:`Operation configuration
848         overrides<msrest:optionsforoperations>`.
849        :return: RdpConnection or ClientRawResponse if raw=true
850        :rtype: ~azure.mgmt.devtestlabs.models.RdpConnection or
851         ~msrest.pipeline.ClientRawResponse
852        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
853        """
854        # Construct URL
855        url = self.get_rdp_file_contents.metadata['url']
856        path_format_arguments = {
857            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
858            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
859            'labName': self._serialize.url("lab_name", lab_name, 'str'),
860            'name': self._serialize.url("name", name, 'str')
861        }
862        url = self._client.format_url(url, **path_format_arguments)
863
864        # Construct parameters
865        query_parameters = {}
866        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
867
868        # Construct headers
869        header_parameters = {}
870        header_parameters['Accept'] = 'application/json'
871        if self.config.generate_client_request_id:
872            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
873        if custom_headers:
874            header_parameters.update(custom_headers)
875        if self.config.accept_language is not None:
876            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
877
878        # Construct and send request
879        request = self._client.post(url, query_parameters, header_parameters)
880        response = self._client.send(request, stream=False, **operation_config)
881
882        if response.status_code not in [200]:
883            exp = CloudError(response)
884            exp.request_id = response.headers.get('x-ms-request-id')
885            raise exp
886
887        deserialized = None
888        if response.status_code == 200:
889            deserialized = self._deserialize('RdpConnection', response)
890
891        if raw:
892            client_raw_response = ClientRawResponse(deserialized, response)
893            return client_raw_response
894
895        return deserialized
896    get_rdp_file_contents.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/getRdpFileContents'}
897
898    def list_applicable_schedules(
899            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
900        """Lists the applicable start/stop schedules, if any.
901
902        :param resource_group_name: The name of the resource group.
903        :type resource_group_name: str
904        :param lab_name: The name of the lab.
905        :type lab_name: str
906        :param name: The name of the virtual machine.
907        :type name: str
908        :param dict custom_headers: headers that will be added to the request
909        :param bool raw: returns the direct response alongside the
910         deserialized response
911        :param operation_config: :ref:`Operation configuration
912         overrides<msrest:optionsforoperations>`.
913        :return: ApplicableSchedule or ClientRawResponse if raw=true
914        :rtype: ~azure.mgmt.devtestlabs.models.ApplicableSchedule or
915         ~msrest.pipeline.ClientRawResponse
916        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
917        """
918        # Construct URL
919        url = self.list_applicable_schedules.metadata['url']
920        path_format_arguments = {
921            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
922            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
923            'labName': self._serialize.url("lab_name", lab_name, 'str'),
924            'name': self._serialize.url("name", name, 'str')
925        }
926        url = self._client.format_url(url, **path_format_arguments)
927
928        # Construct parameters
929        query_parameters = {}
930        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
931
932        # Construct headers
933        header_parameters = {}
934        header_parameters['Accept'] = 'application/json'
935        if self.config.generate_client_request_id:
936            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
937        if custom_headers:
938            header_parameters.update(custom_headers)
939        if self.config.accept_language is not None:
940            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
941
942        # Construct and send request
943        request = self._client.post(url, query_parameters, header_parameters)
944        response = self._client.send(request, stream=False, **operation_config)
945
946        if response.status_code not in [200]:
947            exp = CloudError(response)
948            exp.request_id = response.headers.get('x-ms-request-id')
949            raise exp
950
951        deserialized = None
952        if response.status_code == 200:
953            deserialized = self._deserialize('ApplicableSchedule', response)
954
955        if raw:
956            client_raw_response = ClientRawResponse(deserialized, response)
957            return client_raw_response
958
959        return deserialized
960    list_applicable_schedules.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/listApplicableSchedules'}
961
962
963    def _redeploy_initial(
964            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
965        # Construct URL
966        url = self.redeploy.metadata['url']
967        path_format_arguments = {
968            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
969            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
970            'labName': self._serialize.url("lab_name", lab_name, 'str'),
971            'name': self._serialize.url("name", name, 'str')
972        }
973        url = self._client.format_url(url, **path_format_arguments)
974
975        # Construct parameters
976        query_parameters = {}
977        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
978
979        # Construct headers
980        header_parameters = {}
981        if self.config.generate_client_request_id:
982            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
983        if custom_headers:
984            header_parameters.update(custom_headers)
985        if self.config.accept_language is not None:
986            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
987
988        # Construct and send request
989        request = self._client.post(url, query_parameters, header_parameters)
990        response = self._client.send(request, stream=False, **operation_config)
991
992        if response.status_code not in [200, 202]:
993            exp = CloudError(response)
994            exp.request_id = response.headers.get('x-ms-request-id')
995            raise exp
996
997        if raw:
998            client_raw_response = ClientRawResponse(None, response)
999            return client_raw_response
1000
1001    def redeploy(
1002            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1003        """Redeploy a virtual machine This operation can take a while to complete.
1004
1005        :param resource_group_name: The name of the resource group.
1006        :type resource_group_name: str
1007        :param lab_name: The name of the lab.
1008        :type lab_name: str
1009        :param name: The name of the virtual machine.
1010        :type name: str
1011        :param dict custom_headers: headers that will be added to the request
1012        :param bool raw: The poller return type is ClientRawResponse, the
1013         direct response alongside the deserialized response
1014        :param polling: True for ARMPolling, False for no polling, or a
1015         polling object for personal polling strategy
1016        :return: An instance of LROPoller that returns None or
1017         ClientRawResponse<None> if raw==True
1018        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1019         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1020        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1021        """
1022        raw_result = self._redeploy_initial(
1023            resource_group_name=resource_group_name,
1024            lab_name=lab_name,
1025            name=name,
1026            custom_headers=custom_headers,
1027            raw=True,
1028            **operation_config
1029        )
1030
1031        def get_long_running_output(response):
1032            if raw:
1033                client_raw_response = ClientRawResponse(None, response)
1034                return client_raw_response
1035
1036        lro_delay = operation_config.get(
1037            'long_running_operation_timeout',
1038            self.config.long_running_operation_timeout)
1039        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1040        elif polling is False: polling_method = NoPolling()
1041        else: polling_method = polling
1042        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1043    redeploy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/redeploy'}
1044
1045
1046    def _resize_initial(
1047            self, resource_group_name, lab_name, name, size=None, custom_headers=None, raw=False, **operation_config):
1048        resize_lab_virtual_machine_properties = models.ResizeLabVirtualMachineProperties(size=size)
1049
1050        # Construct URL
1051        url = self.resize.metadata['url']
1052        path_format_arguments = {
1053            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1054            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1055            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1056            'name': self._serialize.url("name", name, 'str')
1057        }
1058        url = self._client.format_url(url, **path_format_arguments)
1059
1060        # Construct parameters
1061        query_parameters = {}
1062        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1063
1064        # Construct headers
1065        header_parameters = {}
1066        header_parameters['Content-Type'] = 'application/json; charset=utf-8'
1067        if self.config.generate_client_request_id:
1068            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1069        if custom_headers:
1070            header_parameters.update(custom_headers)
1071        if self.config.accept_language is not None:
1072            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1073
1074        # Construct body
1075        body_content = self._serialize.body(resize_lab_virtual_machine_properties, 'ResizeLabVirtualMachineProperties')
1076
1077        # Construct and send request
1078        request = self._client.post(url, query_parameters, header_parameters, body_content)
1079        response = self._client.send(request, stream=False, **operation_config)
1080
1081        if response.status_code not in [200, 202]:
1082            exp = CloudError(response)
1083            exp.request_id = response.headers.get('x-ms-request-id')
1084            raise exp
1085
1086        if raw:
1087            client_raw_response = ClientRawResponse(None, response)
1088            return client_raw_response
1089
1090    def resize(
1091            self, resource_group_name, lab_name, name, size=None, custom_headers=None, raw=False, polling=True, **operation_config):
1092        """Resize Virtual Machine. This operation can take a while to complete.
1093
1094        :param resource_group_name: The name of the resource group.
1095        :type resource_group_name: str
1096        :param lab_name: The name of the lab.
1097        :type lab_name: str
1098        :param name: The name of the virtual machine.
1099        :type name: str
1100        :param size: Specifies the size of the virtual machine.
1101        :type size: str
1102        :param dict custom_headers: headers that will be added to the request
1103        :param bool raw: The poller return type is ClientRawResponse, the
1104         direct response alongside the deserialized response
1105        :param polling: True for ARMPolling, False for no polling, or a
1106         polling object for personal polling strategy
1107        :return: An instance of LROPoller that returns None or
1108         ClientRawResponse<None> if raw==True
1109        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1110         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1111        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1112        """
1113        raw_result = self._resize_initial(
1114            resource_group_name=resource_group_name,
1115            lab_name=lab_name,
1116            name=name,
1117            size=size,
1118            custom_headers=custom_headers,
1119            raw=True,
1120            **operation_config
1121        )
1122
1123        def get_long_running_output(response):
1124            if raw:
1125                client_raw_response = ClientRawResponse(None, response)
1126                return client_raw_response
1127
1128        lro_delay = operation_config.get(
1129            'long_running_operation_timeout',
1130            self.config.long_running_operation_timeout)
1131        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1132        elif polling is False: polling_method = NoPolling()
1133        else: polling_method = polling
1134        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1135    resize.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/resize'}
1136
1137
1138    def _restart_initial(
1139            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
1140        # Construct URL
1141        url = self.restart.metadata['url']
1142        path_format_arguments = {
1143            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1144            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1145            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1146            'name': self._serialize.url("name", name, 'str')
1147        }
1148        url = self._client.format_url(url, **path_format_arguments)
1149
1150        # Construct parameters
1151        query_parameters = {}
1152        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1153
1154        # Construct headers
1155        header_parameters = {}
1156        if self.config.generate_client_request_id:
1157            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1158        if custom_headers:
1159            header_parameters.update(custom_headers)
1160        if self.config.accept_language is not None:
1161            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1162
1163        # Construct and send request
1164        request = self._client.post(url, query_parameters, header_parameters)
1165        response = self._client.send(request, stream=False, **operation_config)
1166
1167        if response.status_code not in [200, 202]:
1168            exp = CloudError(response)
1169            exp.request_id = response.headers.get('x-ms-request-id')
1170            raise exp
1171
1172        if raw:
1173            client_raw_response = ClientRawResponse(None, response)
1174            return client_raw_response
1175
1176    def restart(
1177            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1178        """Restart a virtual machine. This operation can take a while to complete.
1179
1180        :param resource_group_name: The name of the resource group.
1181        :type resource_group_name: str
1182        :param lab_name: The name of the lab.
1183        :type lab_name: str
1184        :param name: The name of the virtual machine.
1185        :type name: str
1186        :param dict custom_headers: headers that will be added to the request
1187        :param bool raw: The poller return type is ClientRawResponse, the
1188         direct response alongside the deserialized response
1189        :param polling: True for ARMPolling, False for no polling, or a
1190         polling object for personal polling strategy
1191        :return: An instance of LROPoller that returns None or
1192         ClientRawResponse<None> if raw==True
1193        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1194         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1195        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1196        """
1197        raw_result = self._restart_initial(
1198            resource_group_name=resource_group_name,
1199            lab_name=lab_name,
1200            name=name,
1201            custom_headers=custom_headers,
1202            raw=True,
1203            **operation_config
1204        )
1205
1206        def get_long_running_output(response):
1207            if raw:
1208                client_raw_response = ClientRawResponse(None, response)
1209                return client_raw_response
1210
1211        lro_delay = operation_config.get(
1212            'long_running_operation_timeout',
1213            self.config.long_running_operation_timeout)
1214        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1215        elif polling is False: polling_method = NoPolling()
1216        else: polling_method = polling
1217        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1218    restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/restart'}
1219
1220
1221    def _start_initial(
1222            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
1223        # Construct URL
1224        url = self.start.metadata['url']
1225        path_format_arguments = {
1226            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1227            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1228            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1229            'name': self._serialize.url("name", name, 'str')
1230        }
1231        url = self._client.format_url(url, **path_format_arguments)
1232
1233        # Construct parameters
1234        query_parameters = {}
1235        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1236
1237        # Construct headers
1238        header_parameters = {}
1239        if self.config.generate_client_request_id:
1240            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1241        if custom_headers:
1242            header_parameters.update(custom_headers)
1243        if self.config.accept_language is not None:
1244            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1245
1246        # Construct and send request
1247        request = self._client.post(url, query_parameters, header_parameters)
1248        response = self._client.send(request, stream=False, **operation_config)
1249
1250        if response.status_code not in [200, 202]:
1251            exp = CloudError(response)
1252            exp.request_id = response.headers.get('x-ms-request-id')
1253            raise exp
1254
1255        if raw:
1256            client_raw_response = ClientRawResponse(None, response)
1257            return client_raw_response
1258
1259    def start(
1260            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1261        """Start a virtual machine. This operation can take a while to complete.
1262
1263        :param resource_group_name: The name of the resource group.
1264        :type resource_group_name: str
1265        :param lab_name: The name of the lab.
1266        :type lab_name: str
1267        :param name: The name of the virtual machine.
1268        :type name: str
1269        :param dict custom_headers: headers that will be added to the request
1270        :param bool raw: The poller return type is ClientRawResponse, the
1271         direct response alongside the deserialized response
1272        :param polling: True for ARMPolling, False for no polling, or a
1273         polling object for personal polling strategy
1274        :return: An instance of LROPoller that returns None or
1275         ClientRawResponse<None> if raw==True
1276        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1277         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1278        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1279        """
1280        raw_result = self._start_initial(
1281            resource_group_name=resource_group_name,
1282            lab_name=lab_name,
1283            name=name,
1284            custom_headers=custom_headers,
1285            raw=True,
1286            **operation_config
1287        )
1288
1289        def get_long_running_output(response):
1290            if raw:
1291                client_raw_response = ClientRawResponse(None, response)
1292                return client_raw_response
1293
1294        lro_delay = operation_config.get(
1295            'long_running_operation_timeout',
1296            self.config.long_running_operation_timeout)
1297        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1298        elif polling is False: polling_method = NoPolling()
1299        else: polling_method = polling
1300        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1301    start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/start'}
1302
1303
1304    def _stop_initial(
1305            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
1306        # Construct URL
1307        url = self.stop.metadata['url']
1308        path_format_arguments = {
1309            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1310            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1311            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1312            'name': self._serialize.url("name", name, 'str')
1313        }
1314        url = self._client.format_url(url, **path_format_arguments)
1315
1316        # Construct parameters
1317        query_parameters = {}
1318        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1319
1320        # Construct headers
1321        header_parameters = {}
1322        if self.config.generate_client_request_id:
1323            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1324        if custom_headers:
1325            header_parameters.update(custom_headers)
1326        if self.config.accept_language is not None:
1327            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1328
1329        # Construct and send request
1330        request = self._client.post(url, query_parameters, header_parameters)
1331        response = self._client.send(request, stream=False, **operation_config)
1332
1333        if response.status_code not in [200, 202]:
1334            exp = CloudError(response)
1335            exp.request_id = response.headers.get('x-ms-request-id')
1336            raise exp
1337
1338        if raw:
1339            client_raw_response = ClientRawResponse(None, response)
1340            return client_raw_response
1341
1342    def stop(
1343            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1344        """Stop a virtual machine This operation can take a while to complete.
1345
1346        :param resource_group_name: The name of the resource group.
1347        :type resource_group_name: str
1348        :param lab_name: The name of the lab.
1349        :type lab_name: str
1350        :param name: The name of the virtual machine.
1351        :type name: str
1352        :param dict custom_headers: headers that will be added to the request
1353        :param bool raw: The poller return type is ClientRawResponse, the
1354         direct response alongside the deserialized response
1355        :param polling: True for ARMPolling, False for no polling, or a
1356         polling object for personal polling strategy
1357        :return: An instance of LROPoller that returns None or
1358         ClientRawResponse<None> if raw==True
1359        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1360         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1361        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1362        """
1363        raw_result = self._stop_initial(
1364            resource_group_name=resource_group_name,
1365            lab_name=lab_name,
1366            name=name,
1367            custom_headers=custom_headers,
1368            raw=True,
1369            **operation_config
1370        )
1371
1372        def get_long_running_output(response):
1373            if raw:
1374                client_raw_response = ClientRawResponse(None, response)
1375                return client_raw_response
1376
1377        lro_delay = operation_config.get(
1378            'long_running_operation_timeout',
1379            self.config.long_running_operation_timeout)
1380        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1381        elif polling is False: polling_method = NoPolling()
1382        else: polling_method = polling
1383        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1384    stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/stop'}
1385
1386
1387    def _transfer_disks_initial(
1388            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
1389        # Construct URL
1390        url = self.transfer_disks.metadata['url']
1391        path_format_arguments = {
1392            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1393            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1394            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1395            'name': self._serialize.url("name", name, 'str')
1396        }
1397        url = self._client.format_url(url, **path_format_arguments)
1398
1399        # Construct parameters
1400        query_parameters = {}
1401        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1402
1403        # Construct headers
1404        header_parameters = {}
1405        if self.config.generate_client_request_id:
1406            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1407        if custom_headers:
1408            header_parameters.update(custom_headers)
1409        if self.config.accept_language is not None:
1410            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1411
1412        # Construct and send request
1413        request = self._client.post(url, query_parameters, header_parameters)
1414        response = self._client.send(request, stream=False, **operation_config)
1415
1416        if response.status_code not in [200, 202]:
1417            exp = CloudError(response)
1418            exp.request_id = response.headers.get('x-ms-request-id')
1419            raise exp
1420
1421        if raw:
1422            client_raw_response = ClientRawResponse(None, response)
1423            return client_raw_response
1424
1425    def transfer_disks(
1426            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1427        """Transfers all data disks attached to the virtual machine to be owned by
1428        the current user. This operation can take a while to complete.
1429
1430        :param resource_group_name: The name of the resource group.
1431        :type resource_group_name: str
1432        :param lab_name: The name of the lab.
1433        :type lab_name: str
1434        :param name: The name of the virtual machine.
1435        :type name: str
1436        :param dict custom_headers: headers that will be added to the request
1437        :param bool raw: The poller return type is ClientRawResponse, the
1438         direct response alongside the deserialized response
1439        :param polling: True for ARMPolling, False for no polling, or a
1440         polling object for personal polling strategy
1441        :return: An instance of LROPoller that returns None or
1442         ClientRawResponse<None> if raw==True
1443        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1444         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1445        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1446        """
1447        raw_result = self._transfer_disks_initial(
1448            resource_group_name=resource_group_name,
1449            lab_name=lab_name,
1450            name=name,
1451            custom_headers=custom_headers,
1452            raw=True,
1453            **operation_config
1454        )
1455
1456        def get_long_running_output(response):
1457            if raw:
1458                client_raw_response = ClientRawResponse(None, response)
1459                return client_raw_response
1460
1461        lro_delay = operation_config.get(
1462            'long_running_operation_timeout',
1463            self.config.long_running_operation_timeout)
1464        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1465        elif polling is False: polling_method = NoPolling()
1466        else: polling_method = polling
1467        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1468    transfer_disks.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/transferDisks'}
1469
1470
1471    def _un_claim_initial(
1472            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, **operation_config):
1473        # Construct URL
1474        url = self.un_claim.metadata['url']
1475        path_format_arguments = {
1476            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
1477            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
1478            'labName': self._serialize.url("lab_name", lab_name, 'str'),
1479            'name': self._serialize.url("name", name, 'str')
1480        }
1481        url = self._client.format_url(url, **path_format_arguments)
1482
1483        # Construct parameters
1484        query_parameters = {}
1485        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')
1486
1487        # Construct headers
1488        header_parameters = {}
1489        if self.config.generate_client_request_id:
1490            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
1491        if custom_headers:
1492            header_parameters.update(custom_headers)
1493        if self.config.accept_language is not None:
1494            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
1495
1496        # Construct and send request
1497        request = self._client.post(url, query_parameters, header_parameters)
1498        response = self._client.send(request, stream=False, **operation_config)
1499
1500        if response.status_code not in [200, 202]:
1501            exp = CloudError(response)
1502            exp.request_id = response.headers.get('x-ms-request-id')
1503            raise exp
1504
1505        if raw:
1506            client_raw_response = ClientRawResponse(None, response)
1507            return client_raw_response
1508
1509    def un_claim(
1510            self, resource_group_name, lab_name, name, custom_headers=None, raw=False, polling=True, **operation_config):
1511        """Release ownership of an existing virtual machine This operation can
1512        take a while to complete.
1513
1514        :param resource_group_name: The name of the resource group.
1515        :type resource_group_name: str
1516        :param lab_name: The name of the lab.
1517        :type lab_name: str
1518        :param name: The name of the virtual machine.
1519        :type name: str
1520        :param dict custom_headers: headers that will be added to the request
1521        :param bool raw: The poller return type is ClientRawResponse, the
1522         direct response alongside the deserialized response
1523        :param polling: True for ARMPolling, False for no polling, or a
1524         polling object for personal polling strategy
1525        :return: An instance of LROPoller that returns None or
1526         ClientRawResponse<None> if raw==True
1527        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
1528         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
1529        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
1530        """
1531        raw_result = self._un_claim_initial(
1532            resource_group_name=resource_group_name,
1533            lab_name=lab_name,
1534            name=name,
1535            custom_headers=custom_headers,
1536            raw=True,
1537            **operation_config
1538        )
1539
1540        def get_long_running_output(response):
1541            if raw:
1542                client_raw_response = ClientRawResponse(None, response)
1543                return client_raw_response
1544
1545        lro_delay = operation_config.get(
1546            'long_running_operation_timeout',
1547            self.config.long_running_operation_timeout)
1548        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
1549        elif polling is False: polling_method = NoPolling()
1550        else: polling_method = polling
1551        return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
1552    un_claim.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines/{name}/unClaim'}
1553