|
| 1 | +from __future__ import annotations |
| 2 | +from dataclasses import dataclass, field |
| 3 | +from kiota_abstractions.base_request_builder import BaseRequestBuilder |
| 4 | +from kiota_abstractions.get_path_parameters import get_path_parameters |
| 5 | +from kiota_abstractions.method import Method |
| 6 | +from kiota_abstractions.request_adapter import RequestAdapter |
| 7 | +from kiota_abstractions.request_information import RequestInformation |
| 8 | +from kiota_abstractions.request_option import RequestOption |
| 9 | +from kiota_abstractions.response_handler import ResponseHandler |
| 10 | +from kiota_abstractions.serialization import Parsable, ParsableFactory |
| 11 | +from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union |
| 12 | + |
| 13 | +if TYPE_CHECKING: |
| 14 | + from ..models.application import Application |
| 15 | + from ..models.o_data_errors.o_data_error import ODataError |
| 16 | + |
| 17 | +class ApplicationsWithAppIdRequestBuilder(BaseRequestBuilder): |
| 18 | + """ |
| 19 | + Provides operations to manage the collection of application entities. |
| 20 | + """ |
| 21 | + def __init__(self,request_adapter: RequestAdapter, path_parameters: Optional[Union[Dict[str, Any], str]] = None, app_id: Optional[str] = None) -> None: |
| 22 | + """ |
| 23 | + Instantiates a new ApplicationsWithAppIdRequestBuilder and sets the default values. |
| 24 | + Args: |
| 25 | + app_id: Alternate key of application |
| 26 | + path_parameters: The raw url or the Url template parameters for the request. |
| 27 | + request_adapter: The request adapter to use to execute the requests. |
| 28 | + """ |
| 29 | + super().__init__(request_adapter, "{+baseurl}/applications(appId='{appId}'){?%24select,%24expand}", path_parameters) |
| 30 | + |
| 31 | + async def delete(self,request_configuration: Optional[ApplicationsWithAppIdRequestBuilderDeleteRequestConfiguration] = None) -> None: |
| 32 | + """ |
| 33 | + Delete an application object. When deleted, apps are moved to a temporary container and can be restored within 30 days. After that time, they are permanently deleted. |
| 34 | + Args: |
| 35 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 36 | + """ |
| 37 | + request_info = self.to_delete_request_information( |
| 38 | + request_configuration |
| 39 | + ) |
| 40 | + from ..models.o_data_errors.o_data_error import ODataError |
| 41 | + |
| 42 | + error_mapping: Dict[str, ParsableFactory] = { |
| 43 | + "4XX": ODataError, |
| 44 | + "5XX": ODataError, |
| 45 | + } |
| 46 | + if not self.request_adapter: |
| 47 | + raise Exception("Http core is null") |
| 48 | + return await self.request_adapter.send_no_response_content_async(request_info, error_mapping) |
| 49 | + |
| 50 | + async def get(self,request_configuration: Optional[ApplicationsWithAppIdRequestBuilderGetRequestConfiguration] = None) -> Optional[Application]: |
| 51 | + """ |
| 52 | + Get the properties and relationships of an application object. |
| 53 | + Args: |
| 54 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 55 | + Returns: Optional[Application] |
| 56 | + """ |
| 57 | + request_info = self.to_get_request_information( |
| 58 | + request_configuration |
| 59 | + ) |
| 60 | + from ..models.o_data_errors.o_data_error import ODataError |
| 61 | + |
| 62 | + error_mapping: Dict[str, ParsableFactory] = { |
| 63 | + "4XX": ODataError, |
| 64 | + "5XX": ODataError, |
| 65 | + } |
| 66 | + if not self.request_adapter: |
| 67 | + raise Exception("Http core is null") |
| 68 | + from ..models.application import Application |
| 69 | + |
| 70 | + return await self.request_adapter.send_async(request_info, Application, error_mapping) |
| 71 | + |
| 72 | + async def patch(self,body: Optional[Application] = None, request_configuration: Optional[ApplicationsWithAppIdRequestBuilderPatchRequestConfiguration] = None) -> Optional[Application]: |
| 73 | + """ |
| 74 | + Update the properties of an application object. |
| 75 | + Args: |
| 76 | + body: The request body |
| 77 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 78 | + Returns: Optional[Application] |
| 79 | + """ |
| 80 | + if not body: |
| 81 | + raise TypeError("body cannot be null.") |
| 82 | + request_info = self.to_patch_request_information( |
| 83 | + body, request_configuration |
| 84 | + ) |
| 85 | + from ..models.o_data_errors.o_data_error import ODataError |
| 86 | + |
| 87 | + error_mapping: Dict[str, ParsableFactory] = { |
| 88 | + "4XX": ODataError, |
| 89 | + "5XX": ODataError, |
| 90 | + } |
| 91 | + if not self.request_adapter: |
| 92 | + raise Exception("Http core is null") |
| 93 | + from ..models.application import Application |
| 94 | + |
| 95 | + return await self.request_adapter.send_async(request_info, Application, error_mapping) |
| 96 | + |
| 97 | + def to_delete_request_information(self,request_configuration: Optional[ApplicationsWithAppIdRequestBuilderDeleteRequestConfiguration] = None) -> RequestInformation: |
| 98 | + """ |
| 99 | + Delete an application object. When deleted, apps are moved to a temporary container and can be restored within 30 days. After that time, they are permanently deleted. |
| 100 | + Args: |
| 101 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 102 | + Returns: RequestInformation |
| 103 | + """ |
| 104 | + request_info = RequestInformation() |
| 105 | + request_info.url_template = self.url_template |
| 106 | + request_info.path_parameters = self.path_parameters |
| 107 | + request_info.http_method = Method.DELETE |
| 108 | + if request_configuration: |
| 109 | + request_info.add_request_headers(request_configuration.headers) |
| 110 | + request_info.add_request_options(request_configuration.options) |
| 111 | + return request_info |
| 112 | + |
| 113 | + def to_get_request_information(self,request_configuration: Optional[ApplicationsWithAppIdRequestBuilderGetRequestConfiguration] = None) -> RequestInformation: |
| 114 | + """ |
| 115 | + Get the properties and relationships of an application object. |
| 116 | + Args: |
| 117 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 118 | + Returns: RequestInformation |
| 119 | + """ |
| 120 | + request_info = RequestInformation() |
| 121 | + request_info.url_template = self.url_template |
| 122 | + request_info.path_parameters = self.path_parameters |
| 123 | + request_info.http_method = Method.GET |
| 124 | + request_info.headers["Accept"] = ["application/json"] |
| 125 | + if request_configuration: |
| 126 | + request_info.add_request_headers(request_configuration.headers) |
| 127 | + request_info.set_query_string_parameters_from_raw_object(request_configuration.query_parameters) |
| 128 | + request_info.add_request_options(request_configuration.options) |
| 129 | + return request_info |
| 130 | + |
| 131 | + def to_patch_request_information(self,body: Optional[Application] = None, request_configuration: Optional[ApplicationsWithAppIdRequestBuilderPatchRequestConfiguration] = None) -> RequestInformation: |
| 132 | + """ |
| 133 | + Update the properties of an application object. |
| 134 | + Args: |
| 135 | + body: The request body |
| 136 | + request_configuration: Configuration for the request such as headers, query parameters, and middleware options. |
| 137 | + Returns: RequestInformation |
| 138 | + """ |
| 139 | + if not body: |
| 140 | + raise TypeError("body cannot be null.") |
| 141 | + request_info = RequestInformation() |
| 142 | + request_info.url_template = self.url_template |
| 143 | + request_info.path_parameters = self.path_parameters |
| 144 | + request_info.http_method = Method.PATCH |
| 145 | + request_info.headers["Accept"] = ["application/json"] |
| 146 | + if request_configuration: |
| 147 | + request_info.add_request_headers(request_configuration.headers) |
| 148 | + request_info.add_request_options(request_configuration.options) |
| 149 | + request_info.set_content_from_parsable(self.request_adapter, "application/json", body) |
| 150 | + return request_info |
| 151 | + |
| 152 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 153 | + |
| 154 | + @dataclass |
| 155 | + class ApplicationsWithAppIdRequestBuilderDeleteRequestConfiguration(BaseRequestConfiguration): |
| 156 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 157 | + |
| 158 | + """ |
| 159 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 160 | + """ |
| 161 | + |
| 162 | + @dataclass |
| 163 | + class ApplicationsWithAppIdRequestBuilderGetQueryParameters(): |
| 164 | + """ |
| 165 | + Get the properties and relationships of an application object. |
| 166 | + """ |
| 167 | + def get_query_parameter(self,original_name: Optional[str] = None) -> str: |
| 168 | + """ |
| 169 | + Maps the query parameters names to their encoded names for the URI template parsing. |
| 170 | + Args: |
| 171 | + original_name: The original query parameter name in the class. |
| 172 | + Returns: str |
| 173 | + """ |
| 174 | + if not original_name: |
| 175 | + raise TypeError("original_name cannot be null.") |
| 176 | + if original_name == "expand": |
| 177 | + return "%24expand" |
| 178 | + if original_name == "select": |
| 179 | + return "%24select" |
| 180 | + return original_name |
| 181 | + |
| 182 | + # Expand related entities |
| 183 | + expand: Optional[List[str]] = None |
| 184 | + |
| 185 | + # Select properties to be returned |
| 186 | + select: Optional[List[str]] = None |
| 187 | + |
| 188 | + |
| 189 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 190 | + |
| 191 | + @dataclass |
| 192 | + class ApplicationsWithAppIdRequestBuilderGetRequestConfiguration(BaseRequestConfiguration): |
| 193 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 194 | + |
| 195 | + """ |
| 196 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 197 | + """ |
| 198 | + # Request query parameters |
| 199 | + query_parameters: Optional[ApplicationsWithAppIdRequestBuilder.ApplicationsWithAppIdRequestBuilderGetQueryParameters] = None |
| 200 | + |
| 201 | + |
| 202 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 203 | + |
| 204 | + @dataclass |
| 205 | + class ApplicationsWithAppIdRequestBuilderPatchRequestConfiguration(BaseRequestConfiguration): |
| 206 | + from kiota_abstractions.base_request_configuration import BaseRequestConfiguration |
| 207 | + |
| 208 | + """ |
| 209 | + Configuration for the request such as headers, query parameters, and middleware options. |
| 210 | + """ |
| 211 | + |
| 212 | + |
0 commit comments