6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
# --------------------------------------------------------------------------
8
8
9
- from typing import TYPE_CHECKING
9
+ from copy import deepcopy
10
+ from typing import Any , TYPE_CHECKING
10
11
12
+ from azure .core .rest import HttpRequest , HttpResponse
11
13
from azure .mgmt .core import ARMPipelineClient
12
- from msrest import Deserializer , Serializer
14
+
15
+ from . import models as _models
16
+ from ._configuration import AzureAgriFoodRPServiceConfiguration
17
+ from ._serialization import Deserializer , Serializer
18
+ from .operations import (
19
+ ExtensionsOperations ,
20
+ FarmBeatsExtensionsOperations ,
21
+ FarmBeatsModelsOperations ,
22
+ LocationsOperations ,
23
+ Operations ,
24
+ )
13
25
14
26
if TYPE_CHECKING :
15
27
# pylint: disable=unused-import,ungrouped-imports
16
- from typing import Any , Optional
17
-
18
28
from azure .core .credentials import TokenCredential
19
- from azure .core .pipeline .transport import HttpRequest , HttpResponse
20
29
21
- from ._configuration import AzureAgriFoodRPServiceConfiguration
22
- from .operations import ExtensionsOperations
23
- from .operations import FarmBeatsExtensionsOperations
24
- from .operations import FarmBeatsModelsOperations
25
- from .operations import LocationsOperations
26
- from .operations import Operations
27
- from . import models
28
30
29
-
30
- class AzureAgriFoodRPService (object ):
31
+ class AzureAgriFoodRPService : # pylint: disable=client-accepts-api-version-keyword
31
32
"""APIs documentation for Azure AgriFood Resource Provider Service.
32
33
33
34
:ivar extensions: ExtensionsOperations operations
@@ -40,31 +41,33 @@ class AzureAgriFoodRPService(object):
40
41
:vartype locations: azure.mgmt.agrifood.operations.LocationsOperations
41
42
:ivar operations: Operations operations
42
43
:vartype operations: azure.mgmt.agrifood.operations.Operations
43
- :param credential: Credential needed for the client to connect to Azure.
44
+ :param credential: Credential needed for the client to connect to Azure. Required.
44
45
:type credential: ~azure.core.credentials.TokenCredential
45
- :param subscription_id: The ID of the target subscription.
46
+ :param subscription_id: The ID of the target subscription. Required.
46
47
:type subscription_id: str
47
- :param str base_url: Service URL
48
+ :param base_url: Service URL. Default value is "https://management.azure.com".
49
+ :type base_url: str
50
+ :keyword api_version: Api Version. Default value is "2020-05-12-preview". Note that overriding
51
+ this default value may result in unsupported behavior.
52
+ :paramtype api_version: str
48
53
"""
49
54
50
55
def __init__ (
51
56
self ,
52
- credential , # type: "TokenCredential"
53
- subscription_id , # type: str
54
- base_url = None , # type: Optional[str]
55
- ** kwargs # type: Any
56
- ):
57
- # type: (...) -> None
58
- if not base_url :
59
- base_url = "https://management.azure.com"
60
- self ._config = AzureAgriFoodRPServiceConfiguration (credential , subscription_id , ** kwargs )
57
+ credential : "TokenCredential" ,
58
+ subscription_id : str ,
59
+ base_url : str = "https://management.azure.com" ,
60
+ ** kwargs : Any
61
+ ) -> None :
62
+ self ._config = AzureAgriFoodRPServiceConfiguration (
63
+ credential = credential , subscription_id = subscription_id , ** kwargs
64
+ )
61
65
self ._client = ARMPipelineClient (base_url = base_url , config = self ._config , ** kwargs )
62
66
63
- client_models = {k : v for k , v in models .__dict__ .items () if isinstance (v , type )}
67
+ client_models = {k : v for k , v in _models .__dict__ .items () if isinstance (v , type )}
64
68
self ._serialize = Serializer (client_models )
65
- self ._serialize .client_side_validation = False
66
69
self ._deserialize = Deserializer (client_models )
67
-
70
+ self . _serialize . client_side_validation = False
68
71
self .extensions = ExtensionsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
69
72
self .farm_beats_extensions = FarmBeatsExtensionsOperations (
70
73
self ._client , self ._config , self ._serialize , self ._deserialize
@@ -75,35 +78,34 @@ def __init__(
75
78
self .locations = LocationsOperations (self ._client , self ._config , self ._serialize , self ._deserialize )
76
79
self .operations = Operations (self ._client , self ._config , self ._serialize , self ._deserialize )
77
80
78
- def _send_request (self , http_request , ** kwargs ):
79
- # type: (HttpRequest, Any) -> HttpResponse
81
+ def _send_request (self , request : HttpRequest , ** kwargs : Any ) -> HttpResponse :
80
82
"""Runs the network request through the client's chained policies.
81
83
82
- :param http_request: The network request you want to make. Required.
83
- :type http_request: ~azure.core.pipeline.transport.HttpRequest
84
- :keyword bool stream: Whether the response payload will be streamed. Defaults to True.
84
+ >>> from azure.core.rest import HttpRequest
85
+ >>> request = HttpRequest("GET", "https://www.example.org/")
86
+ <HttpRequest [GET], url: 'https://www.example.org/'>
87
+ >>> response = client._send_request(request)
88
+ <HttpResponse: 200 OK>
89
+
90
+ For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
91
+
92
+ :param request: The network request you want to make. Required.
93
+ :type request: ~azure.core.rest.HttpRequest
94
+ :keyword bool stream: Whether the response payload will be streamed. Defaults to False.
85
95
:return: The response of your network call. Does not do error handling on your response.
86
- :rtype: ~azure.core.pipeline.transport .HttpResponse
96
+ :rtype: ~azure.core.rest .HttpResponse
87
97
"""
88
- path_format_arguments = {
89
- "subscriptionId" : self ._serialize .url (
90
- "self._config.subscription_id" , self ._config .subscription_id , "str" , min_length = 1
91
- ),
92
- }
93
- http_request .url = self ._client .format_url (http_request .url , ** path_format_arguments )
94
- stream = kwargs .pop ("stream" , True )
95
- pipeline_response = self ._client ._pipeline .run (http_request , stream = stream , ** kwargs )
96
- return pipeline_response .http_response
97
-
98
- def close (self ):
99
- # type: () -> None
98
+
99
+ request_copy = deepcopy (request )
100
+ request_copy .url = self ._client .format_url (request_copy .url )
101
+ return self ._client .send_request (request_copy , ** kwargs )
102
+
103
+ def close (self ) -> None :
100
104
self ._client .close ()
101
105
102
- def __enter__ (self ):
103
- # type: () -> AzureAgriFoodRPService
106
+ def __enter__ (self ) -> "AzureAgriFoodRPService" :
104
107
self ._client .__enter__ ()
105
108
return self
106
109
107
- def __exit__ (self , * exc_details ):
108
- # type: (Any) -> None
110
+ def __exit__ (self , * exc_details ) -> None :
109
111
self ._client .__exit__ (* exc_details )
0 commit comments