|
| 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.cloud_p_c import CloudPC |
| 18 | + from ....models.cloud_p_c_collection_response import CloudPCCollectionResponse |
| 19 | + from ....models.o_data_errors.o_data_error import ODataError |
| 20 | + from .count.count_request_builder import CountRequestBuilder |
| 21 | + from .item.cloud_p_c_item_request_builder import CloudPCItemRequestBuilder |
| 22 | + |
| 23 | +class CloudPCsRequestBuilder(BaseRequestBuilder): |
| 24 | + """ |
| 25 | + Provides operations to manage the cloudPCs property of the microsoft.graph.user entity. |
| 26 | + """ |
| 27 | + def __init__(self,request_adapter: RequestAdapter, path_parameters: Union[str, dict[str, Any]]) -> None: |
| 28 | + """ |
| 29 | + Instantiates a new CloudPCsRequestBuilder and sets the default values. |
| 30 | + param path_parameters: The raw url or the url-template parameters for the request. |
| 31 | + param request_adapter: The request adapter to use to execute the requests. |
| 32 | + Returns: None |
| 33 | + """ |
| 34 | + super().__init__(request_adapter, "{+baseurl}/users/{user%2Did}/cloudPCs{?%24count,%24expand,%24filter,%24orderby,%24search,%24select,%24skip,%24top}", path_parameters) |
| 35 | + |
| 36 | + def by_cloud_p_c_id(self,cloud_p_c_id: str) -> CloudPCItemRequestBuilder: |
| 37 | + """ |
| 38 | + Provides operations to manage the cloudPCs property of the microsoft.graph.user entity. |
| 39 | + param cloud_p_c_id: The unique identifier of cloudPC |
| 40 | + Returns: CloudPCItemRequestBuilder |
| 41 | + """ |
| 42 | + if cloud_p_c_id is None: |
| 43 | + raise TypeError("cloud_p_c_id cannot be null.") |
| 44 | + from .item.cloud_p_c_item_request_builder import CloudPCItemRequestBuilder |
| 45 | + |
| 46 | + url_tpl_params = get_path_parameters(self.path_parameters) |
| 47 | + url_tpl_params["cloudPC%2Did"] = cloud_p_c_id |
| 48 | + return CloudPCItemRequestBuilder(self.request_adapter, url_tpl_params) |
| 49 | + |
| 50 | + async def get(self,request_configuration: Optional[RequestConfiguration[CloudPCsRequestBuilderGetQueryParameters]] = None) -> Optional[CloudPCCollectionResponse]: |
| 51 | + """ |
| 52 | + The user's Cloud PCs. Read-only. Nullable. |
| 53 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 54 | + Returns: Optional[CloudPCCollectionResponse] |
| 55 | + """ |
| 56 | + request_info = self.to_get_request_information( |
| 57 | + request_configuration |
| 58 | + ) |
| 59 | + from ....models.o_data_errors.o_data_error import ODataError |
| 60 | + |
| 61 | + error_mapping: dict[str, type[ParsableFactory]] = { |
| 62 | + "XXX": ODataError, |
| 63 | + } |
| 64 | + if not self.request_adapter: |
| 65 | + raise Exception("Http core is null") |
| 66 | + from ....models.cloud_p_c_collection_response import CloudPCCollectionResponse |
| 67 | + |
| 68 | + return await self.request_adapter.send_async(request_info, CloudPCCollectionResponse, error_mapping) |
| 69 | + |
| 70 | + async def post(self,body: CloudPC, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> Optional[CloudPC]: |
| 71 | + """ |
| 72 | + Create new navigation property to cloudPCs for users |
| 73 | + param body: The request body |
| 74 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 75 | + Returns: Optional[CloudPC] |
| 76 | + """ |
| 77 | + if body is None: |
| 78 | + raise TypeError("body cannot be null.") |
| 79 | + request_info = self.to_post_request_information( |
| 80 | + body, request_configuration |
| 81 | + ) |
| 82 | + from ....models.o_data_errors.o_data_error import ODataError |
| 83 | + |
| 84 | + error_mapping: dict[str, type[ParsableFactory]] = { |
| 85 | + "XXX": ODataError, |
| 86 | + } |
| 87 | + if not self.request_adapter: |
| 88 | + raise Exception("Http core is null") |
| 89 | + from ....models.cloud_p_c import CloudPC |
| 90 | + |
| 91 | + return await self.request_adapter.send_async(request_info, CloudPC, error_mapping) |
| 92 | + |
| 93 | + def to_get_request_information(self,request_configuration: Optional[RequestConfiguration[CloudPCsRequestBuilderGetQueryParameters]] = None) -> RequestInformation: |
| 94 | + """ |
| 95 | + The user's Cloud PCs. Read-only. Nullable. |
| 96 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 97 | + Returns: RequestInformation |
| 98 | + """ |
| 99 | + request_info = RequestInformation(Method.GET, self.url_template, self.path_parameters) |
| 100 | + request_info.configure(request_configuration) |
| 101 | + request_info.headers.try_add("Accept", "application/json") |
| 102 | + return request_info |
| 103 | + |
| 104 | + def to_post_request_information(self,body: CloudPC, request_configuration: Optional[RequestConfiguration[QueryParameters]] = None) -> RequestInformation: |
| 105 | + """ |
| 106 | + Create new navigation property to cloudPCs for users |
| 107 | + param body: The request body |
| 108 | + param request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 109 | + Returns: RequestInformation |
| 110 | + """ |
| 111 | + if body is None: |
| 112 | + raise TypeError("body cannot be null.") |
| 113 | + request_info = RequestInformation(Method.POST, self.url_template, self.path_parameters) |
| 114 | + request_info.configure(request_configuration) |
| 115 | + request_info.headers.try_add("Accept", "application/json") |
| 116 | + request_info.set_content_from_parsable(self.request_adapter, "application/json", body) |
| 117 | + return request_info |
| 118 | + |
| 119 | + def with_url(self,raw_url: str) -> CloudPCsRequestBuilder: |
| 120 | + """ |
| 121 | + Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. |
| 122 | + param raw_url: The raw URL to use for the request builder. |
| 123 | + Returns: CloudPCsRequestBuilder |
| 124 | + """ |
| 125 | + if raw_url is None: |
| 126 | + raise TypeError("raw_url cannot be null.") |
| 127 | + return CloudPCsRequestBuilder(self.request_adapter, raw_url) |
| 128 | + |
| 129 | + @property |
| 130 | + def count(self) -> CountRequestBuilder: |
| 131 | + """ |
| 132 | + Provides operations to count the resources in the collection. |
| 133 | + """ |
| 134 | + from .count.count_request_builder import CountRequestBuilder |
| 135 | + |
| 136 | + return CountRequestBuilder(self.request_adapter, self.path_parameters) |
| 137 | + |
| 138 | + @dataclass |
| 139 | + class CloudPCsRequestBuilderGetQueryParameters(): |
| 140 | + """ |
| 141 | + The user's Cloud PCs. Read-only. Nullable. |
| 142 | + """ |
| 143 | + def get_query_parameter(self,original_name: str) -> str: |
| 144 | + """ |
| 145 | + Maps the query parameters names to their encoded names for the URI template parsing. |
| 146 | + param original_name: The original query parameter name in the class. |
| 147 | + Returns: str |
| 148 | + """ |
| 149 | + if original_name is None: |
| 150 | + raise TypeError("original_name cannot be null.") |
| 151 | + if original_name == "count": |
| 152 | + return "%24count" |
| 153 | + if original_name == "expand": |
| 154 | + return "%24expand" |
| 155 | + if original_name == "filter": |
| 156 | + return "%24filter" |
| 157 | + if original_name == "orderby": |
| 158 | + return "%24orderby" |
| 159 | + if original_name == "search": |
| 160 | + return "%24search" |
| 161 | + if original_name == "select": |
| 162 | + return "%24select" |
| 163 | + if original_name == "skip": |
| 164 | + return "%24skip" |
| 165 | + if original_name == "top": |
| 166 | + return "%24top" |
| 167 | + return original_name |
| 168 | + |
| 169 | + # Include count of items |
| 170 | + count: Optional[bool] = None |
| 171 | + |
| 172 | + # Expand related entities |
| 173 | + expand: Optional[list[str]] = None |
| 174 | + |
| 175 | + # Filter items by property values |
| 176 | + filter: Optional[str] = None |
| 177 | + |
| 178 | + # Order items by property values |
| 179 | + orderby: Optional[list[str]] = None |
| 180 | + |
| 181 | + # Search items by search phrases |
| 182 | + search: Optional[str] = None |
| 183 | + |
| 184 | + # Select properties to be returned |
| 185 | + select: Optional[list[str]] = None |
| 186 | + |
| 187 | + # Skip the first n items |
| 188 | + skip: Optional[int] = None |
| 189 | + |
| 190 | + # Show only the first n items |
| 191 | + top: Optional[int] = None |
| 192 | + |
| 193 | + |
| 194 | + @dataclass |
| 195 | + class CloudPCsRequestBuilderGetRequestConfiguration(RequestConfiguration[CloudPCsRequestBuilderGetQueryParameters]): |
| 196 | + """ |
| 197 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 198 | + """ |
| 199 | + warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning) |
| 200 | + |
| 201 | + @dataclass |
| 202 | + class CloudPCsRequestBuilderPostRequestConfiguration(RequestConfiguration[QueryParameters]): |
| 203 | + """ |
| 204 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 205 | + """ |
| 206 | + warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning) |
| 207 | + |
| 208 | + |
0 commit comments