Skip to content

Commit 9fe3a42

Browse files
author
SDKAuto
committed
CodeGen from PR 34006 in Azure/azure-rest-api-specs
Merge 6cc659de67576bdedf53855ec4dcad2ed42a03ed into 877f166d9819e61625338a9ebb9922e1fc646636
1 parent 90ca562 commit 9fe3a42

File tree

96 files changed

+6949
-4293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+6949
-4293
lines changed

sdk/agrifood/azure-mgmt-agrifood/CHANGELOG.md

Lines changed: 137 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,61 @@
11
# Microsoft Azure SDK for Python
22

33
This is the Microsoft Azure Agrifood Management Client Library.
4-
This package has been tested with Python 3.7+.
4+
This package has been tested with Python 3.9+.
55
For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all).
66

77
## _Disclaimer_
88

99
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
1010

11-
# Usage
11+
## Getting started
1212

13+
### Prerequisites
1314

14-
To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt)
15-
16-
For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/)
17-
Code samples for this package can be found at [Agrifood Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com.
18-
Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
15+
- Python 3.9+ is required to use this package.
16+
- [Azure subscription](https://azure.microsoft.com/free/)
1917

18+
### Install the package
2019

21-
# Provide Feedback
20+
```bash
21+
pip install azure-mgmt-agrifood
22+
pip install azure-identity
23+
```
2224

23-
If you encounter any bugs or have suggestions, please file an issue in the
24-
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
25-
section of the project.
25+
### Authentication
26+
27+
By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configuration of the following environment variables.
28+
29+
- `AZURE_CLIENT_ID` for Azure client ID.
30+
- `AZURE_TENANT_ID` for Azure tenant ID.
31+
- `AZURE_CLIENT_SECRET` for Azure client secret.
32+
33+
In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`.
34+
35+
With above configuration, client can be authenticated by following code:
36+
37+
```python
38+
from azure.identity import DefaultAzureCredential
39+
from azure.mgmt.agrifood import AgriFoodMgmtClient
40+
import os
2641

42+
sub_id = os.getenv("AZURE_SUBSCRIPTION_ID")
43+
client = AgriFoodMgmtClient(credential=DefaultAzureCredential(), subscription_id=sub_id)
44+
```
2745

46+
## Examples
2847

48+
Code samples for this package can be found at:
49+
- [Search Agrifood Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com
50+
- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples)
51+
52+
53+
## Troubleshooting
54+
55+
## Next steps
56+
57+
## Provide Feedback
58+
59+
If you encounter any bugs or have suggestions, please file an issue in the
60+
[Issues](https://github.com/Azure/azure-sdk-for-python/issues)
61+
section of the project.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "e37a57df67daaa82f9c3758fc450bc8655812a08",
2+
"commit": "2e99511bfd9ef9cf31ecd616bc9c0af63dfc6808",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"autorest": "3.9.2",
4+
"autorest": "3.10.2",
55
"use": [
6-
"@autorest/python@6.2.7",
7-
"@autorest/modelerfour@4.24.3"
6+
"@autorest/python@6.33.0",
7+
"@autorest/modelerfour@4.27.0"
88
],
9-
"autorest_command": "autorest specification/agrifood/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.7 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/agrifood/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.33.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False",
1010
"readme": "specification/agrifood/resource-manager/readme.md"
1111
}

sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@
55
# Code generated by Microsoft (R) AutoRest Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._agri_food_mgmt_client import AgriFoodMgmtClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._agri_food_mgmt_client import AgriFoodMgmtClient # type: ignore
1016
from ._version import VERSION
1117

1218
__version__ = VERSION
1319

1420
try:
1521
from ._patch import __all__ as _patch_all
16-
from ._patch import * # pylint: disable=unused-wildcard-import
22+
from ._patch import *
1723
except ImportError:
1824
_patch_all = []
1925
from ._patch import patch_sdk as _patch_sdk
2026

2127
__all__ = [
2228
"AgriFoodMgmtClient",
2329
]
24-
__all__.extend([p for p in _patch_all if p not in __all__])
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2531

2632
_patch_sdk()

sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_agri_food_mgmt_client.py

Lines changed: 72 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,26 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import Any, TYPE_CHECKING
10+
from typing import Any, Optional, TYPE_CHECKING, cast
11+
from typing_extensions import Self
1112

13+
from azure.core.pipeline import policies
1214
from azure.core.rest import HttpRequest, HttpResponse
15+
from azure.core.settings import settings
1316
from azure.mgmt.core import ARMPipelineClient
17+
from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy
18+
from azure.mgmt.core.tools import get_arm_endpoints
1419

1520
from . import models as _models
1621
from ._configuration import AgriFoodMgmtClientConfiguration
1722
from ._serialization import Deserializer, Serializer
1823
from .operations import (
24+
CheckNameAvailabilityOperations,
25+
DataConnectorsOperations,
26+
DataManagerForAgricultureExtensionsOperations,
27+
DataManagerForAgricultureResourcesOperations,
1928
ExtensionsOperations,
20-
FarmBeatsExtensionsOperations,
21-
FarmBeatsModelsOperations,
22-
LocationsOperations,
29+
OperationResultsOperations,
2330
Operations,
2431
PrivateEndpointConnectionsOperations,
2532
PrivateLinkResourcesOperations,
@@ -28,21 +35,29 @@
2835
)
2936

3037
if TYPE_CHECKING:
31-
# pylint: disable=unused-import,ungrouped-imports
3238
from azure.core.credentials import TokenCredential
3339

3440

35-
class AgriFoodMgmtClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes
36-
"""APIs documentation for Azure AgFoodPlatform Resource Provider Service.
37-
41+
class AgriFoodMgmtClient: # pylint: disable=too-many-instance-attributes
42+
"""APIs documentation for Microsoft Azure Data Manager for Agriculture Service.
43+
44+
:ivar check_name_availability: CheckNameAvailabilityOperations operations
45+
:vartype check_name_availability:
46+
azure.mgmt.agrifood.operations.CheckNameAvailabilityOperations
47+
:ivar data_connectors: DataConnectorsOperations operations
48+
:vartype data_connectors: azure.mgmt.agrifood.operations.DataConnectorsOperations
49+
:ivar data_manager_for_agriculture_extensions: DataManagerForAgricultureExtensionsOperations
50+
operations
51+
:vartype data_manager_for_agriculture_extensions:
52+
azure.mgmt.agrifood.operations.DataManagerForAgricultureExtensionsOperations
53+
:ivar data_manager_for_agriculture_resources: DataManagerForAgricultureResourcesOperations
54+
operations
55+
:vartype data_manager_for_agriculture_resources:
56+
azure.mgmt.agrifood.operations.DataManagerForAgricultureResourcesOperations
57+
:ivar operation_results: OperationResultsOperations operations
58+
:vartype operation_results: azure.mgmt.agrifood.operations.OperationResultsOperations
3859
:ivar extensions: ExtensionsOperations operations
3960
:vartype extensions: azure.mgmt.agrifood.operations.ExtensionsOperations
40-
:ivar farm_beats_extensions: FarmBeatsExtensionsOperations operations
41-
:vartype farm_beats_extensions: azure.mgmt.agrifood.operations.FarmBeatsExtensionsOperations
42-
:ivar farm_beats_models: FarmBeatsModelsOperations operations
43-
:vartype farm_beats_models: azure.mgmt.agrifood.operations.FarmBeatsModelsOperations
44-
:ivar locations: LocationsOperations operations
45-
:vartype locations: azure.mgmt.agrifood.operations.LocationsOperations
4661
:ivar operations: Operations operations
4762
:vartype operations: azure.mgmt.agrifood.operations.Operations
4863
:ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations
@@ -57,44 +72,67 @@ class AgriFoodMgmtClient: # pylint: disable=client-accepts-api-version-keyword,
5772
azure.mgmt.agrifood.operations.SolutionsDiscoverabilityOperations
5873
:param credential: Credential needed for the client to connect to Azure. Required.
5974
:type credential: ~azure.core.credentials.TokenCredential
60-
:param solution_id: Solution Id of the solution. Required.
61-
:type solution_id: str
6275
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
6376
:type subscription_id: str
64-
:param base_url: Service URL. Default value is "https://management.azure.com".
77+
:param base_url: Service URL. Default value is None.
6578
:type base_url: str
66-
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
79+
:keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding
6780
this default value may result in unsupported behavior.
6881
:paramtype api_version: str
6982
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
7083
Retry-After header is present.
7184
"""
7285

7386
def __init__(
74-
self,
75-
credential: "TokenCredential",
76-
solution_id: str,
77-
subscription_id: str,
78-
base_url: str = "https://management.azure.com",
79-
**kwargs: Any
87+
self, credential: "TokenCredential", subscription_id: str, base_url: Optional[str] = None, **kwargs: Any
8088
) -> None:
89+
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
90+
_endpoints = get_arm_endpoints(_cloud)
91+
if not base_url:
92+
base_url = _endpoints["resource_manager"]
93+
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
8194
self._config = AgriFoodMgmtClientConfiguration(
82-
credential=credential, solution_id=solution_id, subscription_id=subscription_id, **kwargs
95+
credential=credential, subscription_id=subscription_id, credential_scopes=credential_scopes, **kwargs
8396
)
84-
self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs)
97+
98+
_policies = kwargs.pop("policies", None)
99+
if _policies is None:
100+
_policies = [
101+
policies.RequestIdPolicy(**kwargs),
102+
self._config.headers_policy,
103+
self._config.user_agent_policy,
104+
self._config.proxy_policy,
105+
policies.ContentDecodePolicy(**kwargs),
106+
ARMAutoResourceProviderRegistrationPolicy(),
107+
self._config.redirect_policy,
108+
self._config.retry_policy,
109+
self._config.authentication_policy,
110+
self._config.custom_hook_policy,
111+
self._config.logging_policy,
112+
policies.DistributedTracingPolicy(**kwargs),
113+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
114+
self._config.http_logging_policy,
115+
]
116+
self._client: ARMPipelineClient = ARMPipelineClient(base_url=cast(str, base_url), policies=_policies, **kwargs)
85117

86118
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
87119
self._serialize = Serializer(client_models)
88120
self._deserialize = Deserializer(client_models)
89121
self._serialize.client_side_validation = False
90-
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
91-
self.farm_beats_extensions = FarmBeatsExtensionsOperations(
122+
self.check_name_availability = CheckNameAvailabilityOperations(
123+
self._client, self._config, self._serialize, self._deserialize
124+
)
125+
self.data_connectors = DataConnectorsOperations(self._client, self._config, self._serialize, self._deserialize)
126+
self.data_manager_for_agriculture_extensions = DataManagerForAgricultureExtensionsOperations(
127+
self._client, self._config, self._serialize, self._deserialize
128+
)
129+
self.data_manager_for_agriculture_resources = DataManagerForAgricultureResourcesOperations(
92130
self._client, self._config, self._serialize, self._deserialize
93131
)
94-
self.farm_beats_models = FarmBeatsModelsOperations(
132+
self.operation_results = OperationResultsOperations(
95133
self._client, self._config, self._serialize, self._deserialize
96134
)
97-
self.locations = LocationsOperations(self._client, self._config, self._serialize, self._deserialize)
135+
self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize)
98136
self.operations = Operations(self._client, self._config, self._serialize, self._deserialize)
99137
self.private_endpoint_connections = PrivateEndpointConnectionsOperations(
100138
self._client, self._config, self._serialize, self._deserialize
@@ -107,7 +145,7 @@ def __init__(
107145
self._client, self._config, self._serialize, self._deserialize
108146
)
109147

110-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
148+
def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
111149
"""Runs the network request through the client's chained policies.
112150
113151
>>> from azure.core.rest import HttpRequest
@@ -127,14 +165,14 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
127165

128166
request_copy = deepcopy(request)
129167
request_copy.url = self._client.format_url(request_copy.url)
130-
return self._client.send_request(request_copy, **kwargs)
168+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
131169

132170
def close(self) -> None:
133171
self._client.close()
134172

135-
def __enter__(self) -> "AgriFoodMgmtClient":
173+
def __enter__(self) -> Self:
136174
self._client.__enter__()
137175
return self
138176

139-
def __exit__(self, *exc_details) -> None:
177+
def __exit__(self, *exc_details: Any) -> None:
140178
self._client.__exit__(*exc_details)

sdk/agrifood/azure-mgmt-agrifood/azure/mgmt/agrifood/_configuration.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,46 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
import sys
109
from typing import Any, TYPE_CHECKING
1110

12-
from azure.core.configuration import Configuration
1311
from azure.core.pipeline import policies
1412
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy
1513

1614
from ._version import VERSION
1715

18-
if sys.version_info >= (3, 8):
19-
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
20-
else:
21-
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
22-
2316
if TYPE_CHECKING:
24-
# pylint: disable=unused-import,ungrouped-imports
2517
from azure.core.credentials import TokenCredential
2618

2719

28-
class AgriFoodMgmtClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
20+
class AgriFoodMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes
2921
"""Configuration for AgriFoodMgmtClient.
3022
3123
Note that all parameters used to create this instance are saved as instance
3224
attributes.
3325
3426
:param credential: Credential needed for the client to connect to Azure. Required.
3527
:type credential: ~azure.core.credentials.TokenCredential
36-
:param solution_id: Solution Id of the solution. Required.
37-
:type solution_id: str
3828
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
3929
:type subscription_id: str
40-
:keyword api_version: Api Version. Default value is "2021-09-01-preview". Note that overriding
30+
:keyword api_version: Api Version. Default value is "2023-06-01-preview". Note that overriding
4131
this default value may result in unsupported behavior.
4232
:paramtype api_version: str
4333
"""
4434

45-
def __init__(self, credential: "TokenCredential", solution_id: str, subscription_id: str, **kwargs: Any) -> None:
46-
super(AgriFoodMgmtClientConfiguration, self).__init__(**kwargs)
47-
api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview")
35+
def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
36+
api_version: str = kwargs.pop("api_version", "2023-06-01-preview")
4837

4938
if credential is None:
5039
raise ValueError("Parameter 'credential' must not be None.")
51-
if solution_id is None:
52-
raise ValueError("Parameter 'solution_id' must not be None.")
5340
if subscription_id is None:
5441
raise ValueError("Parameter 'subscription_id' must not be None.")
5542

5643
self.credential = credential
57-
self.solution_id = solution_id
5844
self.subscription_id = subscription_id
5945
self.api_version = api_version
6046
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
6147
kwargs.setdefault("sdk_moniker", "mgmt-agrifood/{}".format(VERSION))
48+
self.polling_interval = kwargs.get("polling_interval", 30)
6249
self._configure(**kwargs)
6350

6451
def _configure(self, **kwargs: Any) -> None:
@@ -67,9 +54,9 @@ def _configure(self, **kwargs: Any) -> None:
6754
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
6855
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
6956
self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs)
70-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
7157
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
7258
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
59+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
7360
self.authentication_policy = kwargs.get("authentication_policy")
7461
if self.credential and not self.authentication_policy:
7562
self.authentication_policy = ARMChallengeAuthenticationPolicy(

0 commit comments

Comments
 (0)