azure-mgmt-agricultureplatform 1.0.0b1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. azure/mgmt/agricultureplatform/__init__.py +32 -0
  2. azure/mgmt/agricultureplatform/_client.py +137 -0
  3. azure/mgmt/agricultureplatform/_configuration.py +80 -0
  4. azure/mgmt/agricultureplatform/_patch.py +21 -0
  5. azure/mgmt/agricultureplatform/_utils/__init__.py +6 -0
  6. azure/mgmt/agricultureplatform/_utils/model_base.py +1337 -0
  7. azure/mgmt/agricultureplatform/_utils/serialization.py +2041 -0
  8. azure/mgmt/agricultureplatform/_version.py +9 -0
  9. azure/mgmt/agricultureplatform/aio/__init__.py +29 -0
  10. azure/mgmt/agricultureplatform/aio/_client.py +141 -0
  11. azure/mgmt/agricultureplatform/aio/_configuration.py +80 -0
  12. azure/mgmt/agricultureplatform/aio/_patch.py +21 -0
  13. azure/mgmt/agricultureplatform/aio/operations/__init__.py +27 -0
  14. azure/mgmt/agricultureplatform/aio/operations/_operations.py +1102 -0
  15. azure/mgmt/agricultureplatform/aio/operations/_patch.py +21 -0
  16. azure/mgmt/agricultureplatform/models/__init__.py +92 -0
  17. azure/mgmt/agricultureplatform/models/_enums.py +103 -0
  18. azure/mgmt/agricultureplatform/models/_models.py +1037 -0
  19. azure/mgmt/agricultureplatform/models/_patch.py +21 -0
  20. azure/mgmt/agricultureplatform/operations/__init__.py +27 -0
  21. azure/mgmt/agricultureplatform/operations/_operations.py +1303 -0
  22. azure/mgmt/agricultureplatform/operations/_patch.py +21 -0
  23. azure/mgmt/agricultureplatform/py.typed +1 -0
  24. azure_mgmt_agricultureplatform-1.0.0b1.dist-info/METADATA +94 -0
  25. azure_mgmt_agricultureplatform-1.0.0b1.dist-info/RECORD +28 -0
  26. azure_mgmt_agricultureplatform-1.0.0b1.dist-info/WHEEL +5 -0
  27. azure_mgmt_agricultureplatform-1.0.0b1.dist-info/licenses/LICENSE +21 -0
  28. azure_mgmt_agricultureplatform-1.0.0b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1303 @@
1
+ # pylint: disable=line-too-long,useless-suppression,too-many-lines
2
+ # coding=utf-8
3
+ # --------------------------------------------------------------------------
4
+ # Copyright (c) Microsoft Corporation. All rights reserved.
5
+ # Licensed under the MIT License. See License.txt in the project root for license information.
6
+ # Code generated by Microsoft (R) Python Code Generator.
7
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
+ # --------------------------------------------------------------------------
9
+ from collections.abc import MutableMapping
10
+ from io import IOBase
11
+ import json
12
+ from typing import Any, Callable, IO, Iterator, Optional, TypeVar, Union, cast, overload
13
+ import urllib.parse
14
+
15
+ from azure.core import PipelineClient
16
+ from azure.core.exceptions import (
17
+ ClientAuthenticationError,
18
+ HttpResponseError,
19
+ ResourceExistsError,
20
+ ResourceNotFoundError,
21
+ ResourceNotModifiedError,
22
+ StreamClosedError,
23
+ StreamConsumedError,
24
+ map_error,
25
+ )
26
+ from azure.core.paging import ItemPaged
27
+ from azure.core.pipeline import PipelineResponse
28
+ from azure.core.polling import LROPoller, NoPolling, PollingMethod
29
+ from azure.core.rest import HttpRequest, HttpResponse
30
+ from azure.core.tracing.decorator import distributed_trace
31
+ from azure.core.utils import case_insensitive_dict
32
+ from azure.mgmt.core.exceptions import ARMErrorFormat
33
+ from azure.mgmt.core.polling.arm_polling import ARMPolling
34
+
35
+ from .. import models as _models
36
+ from .._configuration import AgriculturePlatformMgmtClientConfiguration
37
+ from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize
38
+ from .._utils.serialization import Deserializer, Serializer
39
+
40
+ T = TypeVar("T")
41
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]]
42
+ JSON = MutableMapping[str, Any]
43
+ List = list
44
+
45
+ _SERIALIZER = Serializer()
46
+ _SERIALIZER.client_side_validation = False
47
+
48
+
49
+ def build_operations_list_request(**kwargs: Any) -> HttpRequest:
50
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
51
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
52
+
53
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
54
+ accept = _headers.pop("Accept", "application/json")
55
+
56
+ # Construct URL
57
+ _url = "/providers/Microsoft.AgriculturePlatform/operations"
58
+
59
+ # Construct parameters
60
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
61
+
62
+ # Construct headers
63
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
64
+
65
+ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
66
+
67
+
68
+ def build_agri_service_get_request(
69
+ resource_group_name: str, agri_service_resource_name: str, subscription_id: str, **kwargs: Any
70
+ ) -> HttpRequest:
71
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
72
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
73
+
74
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
75
+ accept = _headers.pop("Accept", "application/json")
76
+
77
+ # Construct URL
78
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices/{agriServiceResourceName}"
79
+ path_format_arguments = {
80
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
81
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
82
+ "agriServiceResourceName": _SERIALIZER.url("agri_service_resource_name", agri_service_resource_name, "str"),
83
+ }
84
+
85
+ _url: str = _url.format(**path_format_arguments) # type: ignore
86
+
87
+ # Construct parameters
88
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
89
+
90
+ # Construct headers
91
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
92
+
93
+ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
94
+
95
+
96
+ def build_agri_service_create_or_update_request( # pylint: disable=name-too-long
97
+ resource_group_name: str, agri_service_resource_name: str, subscription_id: str, **kwargs: Any
98
+ ) -> HttpRequest:
99
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
100
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
101
+
102
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
103
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
104
+ accept = _headers.pop("Accept", "application/json")
105
+
106
+ # Construct URL
107
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices/{agriServiceResourceName}"
108
+ path_format_arguments = {
109
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
110
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
111
+ "agriServiceResourceName": _SERIALIZER.url("agri_service_resource_name", agri_service_resource_name, "str"),
112
+ }
113
+
114
+ _url: str = _url.format(**path_format_arguments) # type: ignore
115
+
116
+ # Construct parameters
117
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
118
+
119
+ # Construct headers
120
+ if content_type is not None:
121
+ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
122
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
123
+
124
+ return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs)
125
+
126
+
127
+ def build_agri_service_update_request(
128
+ resource_group_name: str, agri_service_resource_name: str, subscription_id: str, **kwargs: Any
129
+ ) -> HttpRequest:
130
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
131
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
132
+
133
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
134
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
135
+ accept = _headers.pop("Accept", "application/json")
136
+
137
+ # Construct URL
138
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices/{agriServiceResourceName}"
139
+ path_format_arguments = {
140
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
141
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
142
+ "agriServiceResourceName": _SERIALIZER.url("agri_service_resource_name", agri_service_resource_name, "str"),
143
+ }
144
+
145
+ _url: str = _url.format(**path_format_arguments) # type: ignore
146
+
147
+ # Construct parameters
148
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
149
+
150
+ # Construct headers
151
+ if content_type is not None:
152
+ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str")
153
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
154
+
155
+ return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs)
156
+
157
+
158
+ def build_agri_service_delete_request(
159
+ resource_group_name: str, agri_service_resource_name: str, subscription_id: str, **kwargs: Any
160
+ ) -> HttpRequest:
161
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
162
+
163
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
164
+ # Construct URL
165
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices/{agriServiceResourceName}"
166
+ path_format_arguments = {
167
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
168
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
169
+ "agriServiceResourceName": _SERIALIZER.url("agri_service_resource_name", agri_service_resource_name, "str"),
170
+ }
171
+
172
+ _url: str = _url.format(**path_format_arguments) # type: ignore
173
+
174
+ # Construct parameters
175
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
176
+
177
+ return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs)
178
+
179
+
180
+ def build_agri_service_list_by_resource_group_request( # pylint: disable=name-too-long
181
+ resource_group_name: str, subscription_id: str, **kwargs: Any
182
+ ) -> HttpRequest:
183
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
184
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
185
+
186
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
187
+ accept = _headers.pop("Accept", "application/json")
188
+
189
+ # Construct URL
190
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices"
191
+ path_format_arguments = {
192
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
193
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
194
+ }
195
+
196
+ _url: str = _url.format(**path_format_arguments) # type: ignore
197
+
198
+ # Construct parameters
199
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
200
+
201
+ # Construct headers
202
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
203
+
204
+ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
205
+
206
+
207
+ def build_agri_service_list_by_subscription_request( # pylint: disable=name-too-long
208
+ subscription_id: str, **kwargs: Any
209
+ ) -> HttpRequest:
210
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
211
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
212
+
213
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
214
+ accept = _headers.pop("Accept", "application/json")
215
+
216
+ # Construct URL
217
+ _url = "/subscriptions/{subscriptionId}/providers/Microsoft.AgriculturePlatform/agriServices"
218
+ path_format_arguments = {
219
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
220
+ }
221
+
222
+ _url: str = _url.format(**path_format_arguments) # type: ignore
223
+
224
+ # Construct parameters
225
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
226
+
227
+ # Construct headers
228
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
229
+
230
+ return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs)
231
+
232
+
233
+ def build_agri_service_list_available_solutions_request( # pylint: disable=name-too-long
234
+ resource_group_name: str, agri_service_resource_name: str, subscription_id: str, **kwargs: Any
235
+ ) -> HttpRequest:
236
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
237
+ _params = case_insensitive_dict(kwargs.pop("params", {}) or {})
238
+
239
+ api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-06-01-preview"))
240
+ accept = _headers.pop("Accept", "application/json")
241
+
242
+ # Construct URL
243
+ _url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgriculturePlatform/agriServices/{agriServiceResourceName}/listAvailableSolutions"
244
+ path_format_arguments = {
245
+ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"),
246
+ "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"),
247
+ "agriServiceResourceName": _SERIALIZER.url("agri_service_resource_name", agri_service_resource_name, "str"),
248
+ }
249
+
250
+ _url: str = _url.format(**path_format_arguments) # type: ignore
251
+
252
+ # Construct parameters
253
+ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str")
254
+
255
+ # Construct headers
256
+ _headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
257
+
258
+ return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
259
+
260
+
261
+ class Operations:
262
+ """
263
+ .. warning::
264
+ **DO NOT** instantiate this class directly.
265
+
266
+ Instead, you should access the following operations through
267
+ :class:`~azure.mgmt.agricultureplatform.AgriculturePlatformMgmtClient`'s
268
+ :attr:`operations` attribute.
269
+ """
270
+
271
+ def __init__(self, *args, **kwargs) -> None:
272
+ input_args = list(args)
273
+ self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
274
+ self._config: AgriculturePlatformMgmtClientConfiguration = (
275
+ input_args.pop(0) if input_args else kwargs.pop("config")
276
+ )
277
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
278
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
279
+
280
+ @distributed_trace
281
+ def list(self, **kwargs: Any) -> ItemPaged["_models.Operation"]:
282
+ """List the operations for the provider.
283
+
284
+ :return: An iterator like instance of Operation
285
+ :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.agricultureplatform.models.Operation]
286
+ :raises ~azure.core.exceptions.HttpResponseError:
287
+ """
288
+ _headers = kwargs.pop("headers", {}) or {}
289
+ _params = kwargs.pop("params", {}) or {}
290
+
291
+ cls: ClsType[List[_models.Operation]] = kwargs.pop("cls", None)
292
+
293
+ error_map: MutableMapping = {
294
+ 401: ClientAuthenticationError,
295
+ 404: ResourceNotFoundError,
296
+ 409: ResourceExistsError,
297
+ 304: ResourceNotModifiedError,
298
+ }
299
+ error_map.update(kwargs.pop("error_map", {}) or {})
300
+
301
+ def prepare_request(next_link=None):
302
+ if not next_link:
303
+
304
+ _request = build_operations_list_request(
305
+ api_version=self._config.api_version,
306
+ headers=_headers,
307
+ params=_params,
308
+ )
309
+ path_format_arguments = {
310
+ "endpoint": self._serialize.url(
311
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
312
+ ),
313
+ }
314
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
315
+
316
+ else:
317
+ # make call to next link with the client's api-version
318
+ _parsed_next_link = urllib.parse.urlparse(next_link)
319
+ _next_request_params = case_insensitive_dict(
320
+ {
321
+ key: [urllib.parse.quote(v) for v in value]
322
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
323
+ }
324
+ )
325
+ _next_request_params["api-version"] = self._config.api_version
326
+ _request = HttpRequest(
327
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
328
+ )
329
+ path_format_arguments = {
330
+ "endpoint": self._serialize.url(
331
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
332
+ ),
333
+ }
334
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
335
+
336
+ return _request
337
+
338
+ def extract_data(pipeline_response):
339
+ deserialized = pipeline_response.http_response.json()
340
+ list_of_elem = _deserialize(List[_models.Operation], deserialized.get("value", []))
341
+ if cls:
342
+ list_of_elem = cls(list_of_elem) # type: ignore
343
+ return deserialized.get("nextLink") or None, iter(list_of_elem)
344
+
345
+ def get_next(next_link=None):
346
+ _request = prepare_request(next_link)
347
+
348
+ _stream = False
349
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
350
+ _request, stream=_stream, **kwargs
351
+ )
352
+ response = pipeline_response.http_response
353
+
354
+ if response.status_code not in [200]:
355
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
356
+ error = _failsafe_deserialize(
357
+ _models.ErrorResponse,
358
+ response,
359
+ )
360
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
361
+
362
+ return pipeline_response
363
+
364
+ return ItemPaged(get_next, extract_data)
365
+
366
+
367
+ class AgriServiceOperations:
368
+ """
369
+ .. warning::
370
+ **DO NOT** instantiate this class directly.
371
+
372
+ Instead, you should access the following operations through
373
+ :class:`~azure.mgmt.agricultureplatform.AgriculturePlatformMgmtClient`'s
374
+ :attr:`agri_service` attribute.
375
+ """
376
+
377
+ def __init__(self, *args, **kwargs) -> None:
378
+ input_args = list(args)
379
+ self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
380
+ self._config: AgriculturePlatformMgmtClientConfiguration = (
381
+ input_args.pop(0) if input_args else kwargs.pop("config")
382
+ )
383
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
384
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
385
+
386
+ @distributed_trace
387
+ def get(
388
+ self, resource_group_name: str, agri_service_resource_name: str, **kwargs: Any
389
+ ) -> _models.AgriServiceResource:
390
+ """Get a AgriServiceResource.
391
+
392
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
393
+ Required.
394
+ :type resource_group_name: str
395
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
396
+ :type agri_service_resource_name: str
397
+ :return: AgriServiceResource. The AgriServiceResource is compatible with MutableMapping
398
+ :rtype: ~azure.mgmt.agricultureplatform.models.AgriServiceResource
399
+ :raises ~azure.core.exceptions.HttpResponseError:
400
+ """
401
+ error_map: MutableMapping = {
402
+ 401: ClientAuthenticationError,
403
+ 404: ResourceNotFoundError,
404
+ 409: ResourceExistsError,
405
+ 304: ResourceNotModifiedError,
406
+ }
407
+ error_map.update(kwargs.pop("error_map", {}) or {})
408
+
409
+ _headers = kwargs.pop("headers", {}) or {}
410
+ _params = kwargs.pop("params", {}) or {}
411
+
412
+ cls: ClsType[_models.AgriServiceResource] = kwargs.pop("cls", None)
413
+
414
+ _request = build_agri_service_get_request(
415
+ resource_group_name=resource_group_name,
416
+ agri_service_resource_name=agri_service_resource_name,
417
+ subscription_id=self._config.subscription_id,
418
+ api_version=self._config.api_version,
419
+ headers=_headers,
420
+ params=_params,
421
+ )
422
+ path_format_arguments = {
423
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
424
+ }
425
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
426
+
427
+ _stream = kwargs.pop("stream", False)
428
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
429
+ _request, stream=_stream, **kwargs
430
+ )
431
+
432
+ response = pipeline_response.http_response
433
+
434
+ if response.status_code not in [200]:
435
+ if _stream:
436
+ try:
437
+ response.read() # Load the body in memory and close the socket
438
+ except (StreamConsumedError, StreamClosedError):
439
+ pass
440
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
441
+ error = _failsafe_deserialize(
442
+ _models.ErrorResponse,
443
+ response,
444
+ )
445
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
446
+
447
+ if _stream:
448
+ deserialized = response.iter_bytes()
449
+ else:
450
+ deserialized = _deserialize(_models.AgriServiceResource, response.json())
451
+
452
+ if cls:
453
+ return cls(pipeline_response, deserialized, {}) # type: ignore
454
+
455
+ return deserialized # type: ignore
456
+
457
+ def _create_or_update_initial(
458
+ self,
459
+ resource_group_name: str,
460
+ agri_service_resource_name: str,
461
+ resource: Union[_models.AgriServiceResource, JSON, IO[bytes]],
462
+ **kwargs: Any
463
+ ) -> Iterator[bytes]:
464
+ error_map: MutableMapping = {
465
+ 401: ClientAuthenticationError,
466
+ 404: ResourceNotFoundError,
467
+ 409: ResourceExistsError,
468
+ 304: ResourceNotModifiedError,
469
+ }
470
+ error_map.update(kwargs.pop("error_map", {}) or {})
471
+
472
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
473
+ _params = kwargs.pop("params", {}) or {}
474
+
475
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
476
+ cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)
477
+
478
+ content_type = content_type or "application/json"
479
+ _content = None
480
+ if isinstance(resource, (IOBase, bytes)):
481
+ _content = resource
482
+ else:
483
+ _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
484
+
485
+ _request = build_agri_service_create_or_update_request(
486
+ resource_group_name=resource_group_name,
487
+ agri_service_resource_name=agri_service_resource_name,
488
+ subscription_id=self._config.subscription_id,
489
+ content_type=content_type,
490
+ api_version=self._config.api_version,
491
+ content=_content,
492
+ headers=_headers,
493
+ params=_params,
494
+ )
495
+ path_format_arguments = {
496
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
497
+ }
498
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
499
+
500
+ _stream = True
501
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
502
+ _request, stream=_stream, **kwargs
503
+ )
504
+
505
+ response = pipeline_response.http_response
506
+
507
+ if response.status_code not in [200, 201]:
508
+ try:
509
+ response.read() # Load the body in memory and close the socket
510
+ except (StreamConsumedError, StreamClosedError):
511
+ pass
512
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
513
+ error = _failsafe_deserialize(
514
+ _models.ErrorResponse,
515
+ response,
516
+ )
517
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
518
+
519
+ response_headers = {}
520
+ if response.status_code == 201:
521
+ response_headers["Azure-AsyncOperation"] = self._deserialize(
522
+ "str", response.headers.get("Azure-AsyncOperation")
523
+ )
524
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
525
+
526
+ deserialized = response.iter_bytes()
527
+
528
+ if cls:
529
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
530
+
531
+ return deserialized # type: ignore
532
+
533
+ @overload
534
+ def begin_create_or_update(
535
+ self,
536
+ resource_group_name: str,
537
+ agri_service_resource_name: str,
538
+ resource: _models.AgriServiceResource,
539
+ *,
540
+ content_type: str = "application/json",
541
+ **kwargs: Any
542
+ ) -> LROPoller[_models.AgriServiceResource]:
543
+ """Create a AgriServiceResource.
544
+
545
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
546
+ Required.
547
+ :type resource_group_name: str
548
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
549
+ :type agri_service_resource_name: str
550
+ :param resource: Resource create parameters. Required.
551
+ :type resource: ~azure.mgmt.agricultureplatform.models.AgriServiceResource
552
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
553
+ Default value is "application/json".
554
+ :paramtype content_type: str
555
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
556
+ compatible with MutableMapping
557
+ :rtype:
558
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
559
+ :raises ~azure.core.exceptions.HttpResponseError:
560
+ """
561
+
562
+ @overload
563
+ def begin_create_or_update(
564
+ self,
565
+ resource_group_name: str,
566
+ agri_service_resource_name: str,
567
+ resource: JSON,
568
+ *,
569
+ content_type: str = "application/json",
570
+ **kwargs: Any
571
+ ) -> LROPoller[_models.AgriServiceResource]:
572
+ """Create a AgriServiceResource.
573
+
574
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
575
+ Required.
576
+ :type resource_group_name: str
577
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
578
+ :type agri_service_resource_name: str
579
+ :param resource: Resource create parameters. Required.
580
+ :type resource: JSON
581
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
582
+ Default value is "application/json".
583
+ :paramtype content_type: str
584
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
585
+ compatible with MutableMapping
586
+ :rtype:
587
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
588
+ :raises ~azure.core.exceptions.HttpResponseError:
589
+ """
590
+
591
+ @overload
592
+ def begin_create_or_update(
593
+ self,
594
+ resource_group_name: str,
595
+ agri_service_resource_name: str,
596
+ resource: IO[bytes],
597
+ *,
598
+ content_type: str = "application/json",
599
+ **kwargs: Any
600
+ ) -> LROPoller[_models.AgriServiceResource]:
601
+ """Create a AgriServiceResource.
602
+
603
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
604
+ Required.
605
+ :type resource_group_name: str
606
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
607
+ :type agri_service_resource_name: str
608
+ :param resource: Resource create parameters. Required.
609
+ :type resource: IO[bytes]
610
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
611
+ Default value is "application/json".
612
+ :paramtype content_type: str
613
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
614
+ compatible with MutableMapping
615
+ :rtype:
616
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
617
+ :raises ~azure.core.exceptions.HttpResponseError:
618
+ """
619
+
620
+ @distributed_trace
621
+ def begin_create_or_update(
622
+ self,
623
+ resource_group_name: str,
624
+ agri_service_resource_name: str,
625
+ resource: Union[_models.AgriServiceResource, JSON, IO[bytes]],
626
+ **kwargs: Any
627
+ ) -> LROPoller[_models.AgriServiceResource]:
628
+ """Create a AgriServiceResource.
629
+
630
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
631
+ Required.
632
+ :type resource_group_name: str
633
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
634
+ :type agri_service_resource_name: str
635
+ :param resource: Resource create parameters. Is one of the following types:
636
+ AgriServiceResource, JSON, IO[bytes] Required.
637
+ :type resource: ~azure.mgmt.agricultureplatform.models.AgriServiceResource or JSON or IO[bytes]
638
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
639
+ compatible with MutableMapping
640
+ :rtype:
641
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
642
+ :raises ~azure.core.exceptions.HttpResponseError:
643
+ """
644
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
645
+ _params = kwargs.pop("params", {}) or {}
646
+
647
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
648
+ cls: ClsType[_models.AgriServiceResource] = kwargs.pop("cls", None)
649
+ polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
650
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
651
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
652
+ if cont_token is None:
653
+ raw_result = self._create_or_update_initial(
654
+ resource_group_name=resource_group_name,
655
+ agri_service_resource_name=agri_service_resource_name,
656
+ resource=resource,
657
+ content_type=content_type,
658
+ cls=lambda x, y, z: x,
659
+ headers=_headers,
660
+ params=_params,
661
+ **kwargs
662
+ )
663
+ raw_result.http_response.read() # type: ignore
664
+ kwargs.pop("error_map", None)
665
+
666
+ def get_long_running_output(pipeline_response):
667
+ response = pipeline_response.http_response
668
+ deserialized = _deserialize(_models.AgriServiceResource, response.json())
669
+ if cls:
670
+ return cls(pipeline_response, deserialized, {}) # type: ignore
671
+ return deserialized
672
+
673
+ path_format_arguments = {
674
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
675
+ }
676
+
677
+ if polling is True:
678
+ polling_method: PollingMethod = cast(
679
+ PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
680
+ )
681
+ elif polling is False:
682
+ polling_method = cast(PollingMethod, NoPolling())
683
+ else:
684
+ polling_method = polling
685
+ if cont_token:
686
+ return LROPoller[_models.AgriServiceResource].from_continuation_token(
687
+ polling_method=polling_method,
688
+ continuation_token=cont_token,
689
+ client=self._client,
690
+ deserialization_callback=get_long_running_output,
691
+ )
692
+ return LROPoller[_models.AgriServiceResource](
693
+ self._client, raw_result, get_long_running_output, polling_method # type: ignore
694
+ )
695
+
696
+ def _update_initial(
697
+ self,
698
+ resource_group_name: str,
699
+ agri_service_resource_name: str,
700
+ properties: Union[_models.AgriServiceResourceUpdate, JSON, IO[bytes]],
701
+ **kwargs: Any
702
+ ) -> Iterator[bytes]:
703
+ error_map: MutableMapping = {
704
+ 401: ClientAuthenticationError,
705
+ 404: ResourceNotFoundError,
706
+ 409: ResourceExistsError,
707
+ 304: ResourceNotModifiedError,
708
+ }
709
+ error_map.update(kwargs.pop("error_map", {}) or {})
710
+
711
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
712
+ _params = kwargs.pop("params", {}) or {}
713
+
714
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
715
+ cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)
716
+
717
+ content_type = content_type or "application/json"
718
+ _content = None
719
+ if isinstance(properties, (IOBase, bytes)):
720
+ _content = properties
721
+ else:
722
+ _content = json.dumps(properties, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
723
+
724
+ _request = build_agri_service_update_request(
725
+ resource_group_name=resource_group_name,
726
+ agri_service_resource_name=agri_service_resource_name,
727
+ subscription_id=self._config.subscription_id,
728
+ content_type=content_type,
729
+ api_version=self._config.api_version,
730
+ content=_content,
731
+ headers=_headers,
732
+ params=_params,
733
+ )
734
+ path_format_arguments = {
735
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
736
+ }
737
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
738
+
739
+ _stream = True
740
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
741
+ _request, stream=_stream, **kwargs
742
+ )
743
+
744
+ response = pipeline_response.http_response
745
+
746
+ if response.status_code not in [200, 202]:
747
+ try:
748
+ response.read() # Load the body in memory and close the socket
749
+ except (StreamConsumedError, StreamClosedError):
750
+ pass
751
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
752
+ error = _failsafe_deserialize(
753
+ _models.ErrorResponse,
754
+ response,
755
+ )
756
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
757
+
758
+ response_headers = {}
759
+ if response.status_code == 202:
760
+ response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
761
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
762
+
763
+ deserialized = response.iter_bytes()
764
+
765
+ if cls:
766
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
767
+
768
+ return deserialized # type: ignore
769
+
770
+ @overload
771
+ def begin_update(
772
+ self,
773
+ resource_group_name: str,
774
+ agri_service_resource_name: str,
775
+ properties: _models.AgriServiceResourceUpdate,
776
+ *,
777
+ content_type: str = "application/json",
778
+ **kwargs: Any
779
+ ) -> LROPoller[_models.AgriServiceResource]:
780
+ """Update a AgriServiceResource.
781
+
782
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
783
+ Required.
784
+ :type resource_group_name: str
785
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
786
+ :type agri_service_resource_name: str
787
+ :param properties: The resource properties to be updated. Required.
788
+ :type properties: ~azure.mgmt.agricultureplatform.models.AgriServiceResourceUpdate
789
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
790
+ Default value is "application/json".
791
+ :paramtype content_type: str
792
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
793
+ compatible with MutableMapping
794
+ :rtype:
795
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
796
+ :raises ~azure.core.exceptions.HttpResponseError:
797
+ """
798
+
799
+ @overload
800
+ def begin_update(
801
+ self,
802
+ resource_group_name: str,
803
+ agri_service_resource_name: str,
804
+ properties: JSON,
805
+ *,
806
+ content_type: str = "application/json",
807
+ **kwargs: Any
808
+ ) -> LROPoller[_models.AgriServiceResource]:
809
+ """Update a AgriServiceResource.
810
+
811
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
812
+ Required.
813
+ :type resource_group_name: str
814
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
815
+ :type agri_service_resource_name: str
816
+ :param properties: The resource properties to be updated. Required.
817
+ :type properties: JSON
818
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
819
+ Default value is "application/json".
820
+ :paramtype content_type: str
821
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
822
+ compatible with MutableMapping
823
+ :rtype:
824
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
825
+ :raises ~azure.core.exceptions.HttpResponseError:
826
+ """
827
+
828
+ @overload
829
+ def begin_update(
830
+ self,
831
+ resource_group_name: str,
832
+ agri_service_resource_name: str,
833
+ properties: IO[bytes],
834
+ *,
835
+ content_type: str = "application/json",
836
+ **kwargs: Any
837
+ ) -> LROPoller[_models.AgriServiceResource]:
838
+ """Update a AgriServiceResource.
839
+
840
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
841
+ Required.
842
+ :type resource_group_name: str
843
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
844
+ :type agri_service_resource_name: str
845
+ :param properties: The resource properties to be updated. Required.
846
+ :type properties: IO[bytes]
847
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
848
+ Default value is "application/json".
849
+ :paramtype content_type: str
850
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
851
+ compatible with MutableMapping
852
+ :rtype:
853
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
854
+ :raises ~azure.core.exceptions.HttpResponseError:
855
+ """
856
+
857
+ @distributed_trace
858
+ def begin_update(
859
+ self,
860
+ resource_group_name: str,
861
+ agri_service_resource_name: str,
862
+ properties: Union[_models.AgriServiceResourceUpdate, JSON, IO[bytes]],
863
+ **kwargs: Any
864
+ ) -> LROPoller[_models.AgriServiceResource]:
865
+ """Update a AgriServiceResource.
866
+
867
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
868
+ Required.
869
+ :type resource_group_name: str
870
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
871
+ :type agri_service_resource_name: str
872
+ :param properties: The resource properties to be updated. Is one of the following types:
873
+ AgriServiceResourceUpdate, JSON, IO[bytes] Required.
874
+ :type properties: ~azure.mgmt.agricultureplatform.models.AgriServiceResourceUpdate or JSON or
875
+ IO[bytes]
876
+ :return: An instance of LROPoller that returns AgriServiceResource. The AgriServiceResource is
877
+ compatible with MutableMapping
878
+ :rtype:
879
+ ~azure.core.polling.LROPoller[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
880
+ :raises ~azure.core.exceptions.HttpResponseError:
881
+ """
882
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
883
+ _params = kwargs.pop("params", {}) or {}
884
+
885
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
886
+ cls: ClsType[_models.AgriServiceResource] = kwargs.pop("cls", None)
887
+ polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
888
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
889
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
890
+ if cont_token is None:
891
+ raw_result = self._update_initial(
892
+ resource_group_name=resource_group_name,
893
+ agri_service_resource_name=agri_service_resource_name,
894
+ properties=properties,
895
+ content_type=content_type,
896
+ cls=lambda x, y, z: x,
897
+ headers=_headers,
898
+ params=_params,
899
+ **kwargs
900
+ )
901
+ raw_result.http_response.read() # type: ignore
902
+ kwargs.pop("error_map", None)
903
+
904
+ def get_long_running_output(pipeline_response):
905
+ response = pipeline_response.http_response
906
+ deserialized = _deserialize(_models.AgriServiceResource, response.json())
907
+ if cls:
908
+ return cls(pipeline_response, deserialized, {}) # type: ignore
909
+ return deserialized
910
+
911
+ path_format_arguments = {
912
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
913
+ }
914
+
915
+ if polling is True:
916
+ polling_method: PollingMethod = cast(
917
+ PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
918
+ )
919
+ elif polling is False:
920
+ polling_method = cast(PollingMethod, NoPolling())
921
+ else:
922
+ polling_method = polling
923
+ if cont_token:
924
+ return LROPoller[_models.AgriServiceResource].from_continuation_token(
925
+ polling_method=polling_method,
926
+ continuation_token=cont_token,
927
+ client=self._client,
928
+ deserialization_callback=get_long_running_output,
929
+ )
930
+ return LROPoller[_models.AgriServiceResource](
931
+ self._client, raw_result, get_long_running_output, polling_method # type: ignore
932
+ )
933
+
934
+ def _delete_initial(
935
+ self, resource_group_name: str, agri_service_resource_name: str, **kwargs: Any
936
+ ) -> Iterator[bytes]:
937
+ error_map: MutableMapping = {
938
+ 401: ClientAuthenticationError,
939
+ 404: ResourceNotFoundError,
940
+ 409: ResourceExistsError,
941
+ 304: ResourceNotModifiedError,
942
+ }
943
+ error_map.update(kwargs.pop("error_map", {}) or {})
944
+
945
+ _headers = kwargs.pop("headers", {}) or {}
946
+ _params = kwargs.pop("params", {}) or {}
947
+
948
+ cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None)
949
+
950
+ _request = build_agri_service_delete_request(
951
+ resource_group_name=resource_group_name,
952
+ agri_service_resource_name=agri_service_resource_name,
953
+ subscription_id=self._config.subscription_id,
954
+ api_version=self._config.api_version,
955
+ headers=_headers,
956
+ params=_params,
957
+ )
958
+ path_format_arguments = {
959
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
960
+ }
961
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
962
+
963
+ _stream = True
964
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
965
+ _request, stream=_stream, **kwargs
966
+ )
967
+
968
+ response = pipeline_response.http_response
969
+
970
+ if response.status_code not in [202, 204]:
971
+ try:
972
+ response.read() # Load the body in memory and close the socket
973
+ except (StreamConsumedError, StreamClosedError):
974
+ pass
975
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
976
+ error = _failsafe_deserialize(
977
+ _models.ErrorResponse,
978
+ response,
979
+ )
980
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
981
+
982
+ response_headers = {}
983
+ if response.status_code == 202:
984
+ response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
985
+ response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))
986
+
987
+ deserialized = response.iter_bytes()
988
+
989
+ if cls:
990
+ return cls(pipeline_response, deserialized, response_headers) # type: ignore
991
+
992
+ return deserialized # type: ignore
993
+
994
+ @distributed_trace
995
+ def begin_delete(self, resource_group_name: str, agri_service_resource_name: str, **kwargs: Any) -> LROPoller[None]:
996
+ """Delete a AgriServiceResource.
997
+
998
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
999
+ Required.
1000
+ :type resource_group_name: str
1001
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
1002
+ :type agri_service_resource_name: str
1003
+ :return: An instance of LROPoller that returns None
1004
+ :rtype: ~azure.core.polling.LROPoller[None]
1005
+ :raises ~azure.core.exceptions.HttpResponseError:
1006
+ """
1007
+ _headers = kwargs.pop("headers", {}) or {}
1008
+ _params = kwargs.pop("params", {}) or {}
1009
+
1010
+ cls: ClsType[None] = kwargs.pop("cls", None)
1011
+ polling: Union[bool, PollingMethod] = kwargs.pop("polling", True)
1012
+ lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
1013
+ cont_token: Optional[str] = kwargs.pop("continuation_token", None)
1014
+ if cont_token is None:
1015
+ raw_result = self._delete_initial(
1016
+ resource_group_name=resource_group_name,
1017
+ agri_service_resource_name=agri_service_resource_name,
1018
+ cls=lambda x, y, z: x,
1019
+ headers=_headers,
1020
+ params=_params,
1021
+ **kwargs
1022
+ )
1023
+ raw_result.http_response.read() # type: ignore
1024
+ kwargs.pop("error_map", None)
1025
+
1026
+ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements
1027
+ if cls:
1028
+ return cls(pipeline_response, None, {}) # type: ignore
1029
+
1030
+ path_format_arguments = {
1031
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1032
+ }
1033
+
1034
+ if polling is True:
1035
+ polling_method: PollingMethod = cast(
1036
+ PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
1037
+ )
1038
+ elif polling is False:
1039
+ polling_method = cast(PollingMethod, NoPolling())
1040
+ else:
1041
+ polling_method = polling
1042
+ if cont_token:
1043
+ return LROPoller[None].from_continuation_token(
1044
+ polling_method=polling_method,
1045
+ continuation_token=cont_token,
1046
+ client=self._client,
1047
+ deserialization_callback=get_long_running_output,
1048
+ )
1049
+ return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
1050
+
1051
+ @distributed_trace
1052
+ def list_by_resource_group(
1053
+ self, resource_group_name: str, **kwargs: Any
1054
+ ) -> ItemPaged["_models.AgriServiceResource"]:
1055
+ """List AgriServiceResource resources by resource group.
1056
+
1057
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1058
+ Required.
1059
+ :type resource_group_name: str
1060
+ :return: An iterator like instance of AgriServiceResource
1061
+ :rtype:
1062
+ ~azure.core.paging.ItemPaged[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
1063
+ :raises ~azure.core.exceptions.HttpResponseError:
1064
+ """
1065
+ _headers = kwargs.pop("headers", {}) or {}
1066
+ _params = kwargs.pop("params", {}) or {}
1067
+
1068
+ cls: ClsType[List[_models.AgriServiceResource]] = kwargs.pop("cls", None)
1069
+
1070
+ error_map: MutableMapping = {
1071
+ 401: ClientAuthenticationError,
1072
+ 404: ResourceNotFoundError,
1073
+ 409: ResourceExistsError,
1074
+ 304: ResourceNotModifiedError,
1075
+ }
1076
+ error_map.update(kwargs.pop("error_map", {}) or {})
1077
+
1078
+ def prepare_request(next_link=None):
1079
+ if not next_link:
1080
+
1081
+ _request = build_agri_service_list_by_resource_group_request(
1082
+ resource_group_name=resource_group_name,
1083
+ subscription_id=self._config.subscription_id,
1084
+ api_version=self._config.api_version,
1085
+ headers=_headers,
1086
+ params=_params,
1087
+ )
1088
+ path_format_arguments = {
1089
+ "endpoint": self._serialize.url(
1090
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1091
+ ),
1092
+ }
1093
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1094
+
1095
+ else:
1096
+ # make call to next link with the client's api-version
1097
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1098
+ _next_request_params = case_insensitive_dict(
1099
+ {
1100
+ key: [urllib.parse.quote(v) for v in value]
1101
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1102
+ }
1103
+ )
1104
+ _next_request_params["api-version"] = self._config.api_version
1105
+ _request = HttpRequest(
1106
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1107
+ )
1108
+ path_format_arguments = {
1109
+ "endpoint": self._serialize.url(
1110
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1111
+ ),
1112
+ }
1113
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1114
+
1115
+ return _request
1116
+
1117
+ def extract_data(pipeline_response):
1118
+ deserialized = pipeline_response.http_response.json()
1119
+ list_of_elem = _deserialize(List[_models.AgriServiceResource], deserialized.get("value", []))
1120
+ if cls:
1121
+ list_of_elem = cls(list_of_elem) # type: ignore
1122
+ return deserialized.get("nextLink") or None, iter(list_of_elem)
1123
+
1124
+ def get_next(next_link=None):
1125
+ _request = prepare_request(next_link)
1126
+
1127
+ _stream = False
1128
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
1129
+ _request, stream=_stream, **kwargs
1130
+ )
1131
+ response = pipeline_response.http_response
1132
+
1133
+ if response.status_code not in [200]:
1134
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1135
+ error = _failsafe_deserialize(
1136
+ _models.ErrorResponse,
1137
+ response,
1138
+ )
1139
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1140
+
1141
+ return pipeline_response
1142
+
1143
+ return ItemPaged(get_next, extract_data)
1144
+
1145
+ @distributed_trace
1146
+ def list_by_subscription(self, **kwargs: Any) -> ItemPaged["_models.AgriServiceResource"]:
1147
+ """List AgriServiceResource resources by subscription ID.
1148
+
1149
+ :return: An iterator like instance of AgriServiceResource
1150
+ :rtype:
1151
+ ~azure.core.paging.ItemPaged[~azure.mgmt.agricultureplatform.models.AgriServiceResource]
1152
+ :raises ~azure.core.exceptions.HttpResponseError:
1153
+ """
1154
+ _headers = kwargs.pop("headers", {}) or {}
1155
+ _params = kwargs.pop("params", {}) or {}
1156
+
1157
+ cls: ClsType[List[_models.AgriServiceResource]] = kwargs.pop("cls", None)
1158
+
1159
+ error_map: MutableMapping = {
1160
+ 401: ClientAuthenticationError,
1161
+ 404: ResourceNotFoundError,
1162
+ 409: ResourceExistsError,
1163
+ 304: ResourceNotModifiedError,
1164
+ }
1165
+ error_map.update(kwargs.pop("error_map", {}) or {})
1166
+
1167
+ def prepare_request(next_link=None):
1168
+ if not next_link:
1169
+
1170
+ _request = build_agri_service_list_by_subscription_request(
1171
+ subscription_id=self._config.subscription_id,
1172
+ api_version=self._config.api_version,
1173
+ headers=_headers,
1174
+ params=_params,
1175
+ )
1176
+ path_format_arguments = {
1177
+ "endpoint": self._serialize.url(
1178
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1179
+ ),
1180
+ }
1181
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1182
+
1183
+ else:
1184
+ # make call to next link with the client's api-version
1185
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1186
+ _next_request_params = case_insensitive_dict(
1187
+ {
1188
+ key: [urllib.parse.quote(v) for v in value]
1189
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1190
+ }
1191
+ )
1192
+ _next_request_params["api-version"] = self._config.api_version
1193
+ _request = HttpRequest(
1194
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1195
+ )
1196
+ path_format_arguments = {
1197
+ "endpoint": self._serialize.url(
1198
+ "self._config.base_url", self._config.base_url, "str", skip_quote=True
1199
+ ),
1200
+ }
1201
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1202
+
1203
+ return _request
1204
+
1205
+ def extract_data(pipeline_response):
1206
+ deserialized = pipeline_response.http_response.json()
1207
+ list_of_elem = _deserialize(List[_models.AgriServiceResource], deserialized.get("value", []))
1208
+ if cls:
1209
+ list_of_elem = cls(list_of_elem) # type: ignore
1210
+ return deserialized.get("nextLink") or None, iter(list_of_elem)
1211
+
1212
+ def get_next(next_link=None):
1213
+ _request = prepare_request(next_link)
1214
+
1215
+ _stream = False
1216
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
1217
+ _request, stream=_stream, **kwargs
1218
+ )
1219
+ response = pipeline_response.http_response
1220
+
1221
+ if response.status_code not in [200]:
1222
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1223
+ error = _failsafe_deserialize(
1224
+ _models.ErrorResponse,
1225
+ response,
1226
+ )
1227
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1228
+
1229
+ return pipeline_response
1230
+
1231
+ return ItemPaged(get_next, extract_data)
1232
+
1233
+ @distributed_trace
1234
+ def list_available_solutions(
1235
+ self, resource_group_name: str, agri_service_resource_name: str, **kwargs: Any
1236
+ ) -> _models.AvailableAgriSolutionListResult:
1237
+ """Returns the list of available agri solutions.
1238
+
1239
+ :param resource_group_name: The name of the resource group. The name is case insensitive.
1240
+ Required.
1241
+ :type resource_group_name: str
1242
+ :param agri_service_resource_name: The name of the AgriService resource. Required.
1243
+ :type agri_service_resource_name: str
1244
+ :return: AvailableAgriSolutionListResult. The AvailableAgriSolutionListResult is compatible
1245
+ with MutableMapping
1246
+ :rtype: ~azure.mgmt.agricultureplatform.models.AvailableAgriSolutionListResult
1247
+ :raises ~azure.core.exceptions.HttpResponseError:
1248
+ """
1249
+ error_map: MutableMapping = {
1250
+ 401: ClientAuthenticationError,
1251
+ 404: ResourceNotFoundError,
1252
+ 409: ResourceExistsError,
1253
+ 304: ResourceNotModifiedError,
1254
+ }
1255
+ error_map.update(kwargs.pop("error_map", {}) or {})
1256
+
1257
+ _headers = kwargs.pop("headers", {}) or {}
1258
+ _params = kwargs.pop("params", {}) or {}
1259
+
1260
+ cls: ClsType[_models.AvailableAgriSolutionListResult] = kwargs.pop("cls", None)
1261
+
1262
+ _request = build_agri_service_list_available_solutions_request(
1263
+ resource_group_name=resource_group_name,
1264
+ agri_service_resource_name=agri_service_resource_name,
1265
+ subscription_id=self._config.subscription_id,
1266
+ api_version=self._config.api_version,
1267
+ headers=_headers,
1268
+ params=_params,
1269
+ )
1270
+ path_format_arguments = {
1271
+ "endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
1272
+ }
1273
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1274
+
1275
+ _stream = kwargs.pop("stream", False)
1276
+ pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
1277
+ _request, stream=_stream, **kwargs
1278
+ )
1279
+
1280
+ response = pipeline_response.http_response
1281
+
1282
+ if response.status_code not in [200]:
1283
+ if _stream:
1284
+ try:
1285
+ response.read() # Load the body in memory and close the socket
1286
+ except (StreamConsumedError, StreamClosedError):
1287
+ pass
1288
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1289
+ error = _failsafe_deserialize(
1290
+ _models.ErrorResponse,
1291
+ response,
1292
+ )
1293
+ raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
1294
+
1295
+ if _stream:
1296
+ deserialized = response.iter_bytes()
1297
+ else:
1298
+ deserialized = _deserialize(_models.AvailableAgriSolutionListResult, response.json())
1299
+
1300
+ if cls:
1301
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1302
+
1303
+ return deserialized # type: ignore