|
| 1 | +from __future__ import annotations |
| 2 | +from collections.abc import Callable |
| 3 | +from dataclasses import dataclass, field |
| 4 | +from kiota_abstractions.base_request_builder import BaseRequestBuilder |
| 5 | +from kiota_abstractions.base_request_configuration import RequestConfiguration |
| 6 | +from kiota_abstractions.default_query_parameters import QueryParameters |
| 7 | +from kiota_abstractions.get_path_parameters import get_path_parameters |
| 8 | +from kiota_abstractions.method import Method |
| 9 | +from kiota_abstractions.request_adapter import RequestAdapter |
| 10 | +from kiota_abstractions.request_information import RequestInformation |
| 11 | +from kiota_abstractions.request_option import RequestOption |
| 12 | +from kiota_abstractions.serialization import Parsable, ParsableFactory |
| 13 | +from typing import Any, Optional, TYPE_CHECKING, Union |
| 14 | +from warnings import warn |
| 15 | + |
| 16 | +if TYPE_CHECKING: |
| 17 | + from ...models.o_data_errors.o_data_error import ODataError |
| 18 | + from ...models.provision_response import ProvisionResponse |
| 19 | + from .provision_post_request_body import ProvisionPostRequestBody |
| 20 | + |
| 21 | +class ProvisionRequestBuilder(BaseRequestBuilder): |
| 22 | + """ |
| 23 | + Provides operations to call the provision method. |
| 24 | + """ |
| 25 | + def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None: |
| 26 | + """ |
| 27 | + Instantiates a new ProvisionRequestBuilder and sets the default values. |
| 28 | + param path_parameters: The raw url or the url-template parameters for the request. |
| 29 | + param request_adapter: The request adapter to use to execute the requests. |
| 30 | + Returns: None |
| 31 | + """ |
| 32 | + super().__init__(request_adapter, "{+baseurl}/devices/provision", path_parameters) |
| 33 | + |
| 34 | + async def post(self,body: ProvisionPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[ProvisionResponse]: |
| 35 | + """ |
| 36 | + Provision a device on behalf of an approved Virtual Desktop Infrastructure (VDI) provider. This action wraps the Zero Touch Deployment (ZTD) protocol to create a device in a pending state in the customer's directory. The device can't be used for authentication until it completes its registration. The created device is stamped with a system label that identifies the approved VDI provider. Only VDI applications on Microsoft's approved list of VDI providers can successfully call this action. Calls from other applications are blocked even when the application is granted the required permission. |
| 37 | + param body: The request body |
| 38 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 39 | + Returns: Optional[ProvisionResponse] |
| 40 | + Find more info here: https://learn.microsoft.com/graph/api/device-provision?view=graph-rest-1.0 |
| 41 | + """ |
| 42 | + if body is None: |
| 43 | + raise TypeError("body cannot be null.") |
| 44 | + request_info = self.to_post_request_information( |
| 45 | + body, request_configuration |
| 46 | + ) |
| 47 | + from ...models.o_data_errors.o_data_error import ODataError |
| 48 | + |
| 49 | + error_mapping: dict[str, type[ParsableFactory]] = { |
| 50 | + "XXX": ODataError, |
| 51 | + } |
| 52 | + if not self.request_adapter: |
| 53 | + raise Exception("Http core is null") |
| 54 | + from ...models.provision_response import ProvisionResponse |
| 55 | + |
| 56 | + return await self.request_adapter.send_async(request_info, ProvisionResponse, error_mapping) |
| 57 | + |
| 58 | + def to_post_request_information(self,body: ProvisionPostRequestBody, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation: |
| 59 | + """ |
| 60 | + Provision a device on behalf of an approved Virtual Desktop Infrastructure (VDI) provider. This action wraps the Zero Touch Deployment (ZTD) protocol to create a device in a pending state in the customer's directory. The device can't be used for authentication until it completes its registration. The created device is stamped with a system label that identifies the approved VDI provider. Only VDI applications on Microsoft's approved list of VDI providers can successfully call this action. Calls from other applications are blocked even when the application is granted the required permission. |
| 61 | + param body: The request body |
| 62 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 63 | + Returns: RequestInformation |
| 64 | + """ |
| 65 | + if body is None: |
| 66 | + raise TypeError("body cannot be null.") |
| 67 | + request_info = RequestInformation(Method.POST, self.url_template, self.path_parameters) |
| 68 | + request_info.configure(request_configuration) |
| 69 | + request_info.headers.try_add("Accept", "application/json") |
| 70 | + request_info.set_content_from_parsable(self.request_adapter, "application/json", body) |
| 71 | + return request_info |
| 72 | + |
| 73 | + def with_url(self,raw_url: str) -> ProvisionRequestBuilder: |
| 74 | + """ |
| 75 | + Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. |
| 76 | + param raw_url: The raw URL to use for the request builder. |
| 77 | + Returns: ProvisionRequestBuilder |
| 78 | + """ |
| 79 | + if raw_url is None: |
| 80 | + raise TypeError("raw_url cannot be null.") |
| 81 | + return ProvisionRequestBuilder(self.request_adapter, raw_url) |
| 82 | + |
| 83 | + @dataclass |
| 84 | + class ProvisionRequestBuilderPostRequestConfiguration(RequestConfiguration[QueryParameters]): |
| 85 | + """ |
| 86 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 87 | + """ |
| 88 | + warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning) |
| 89 | + |
| 90 | + |
0 commit comments