Skip to content

Commit ffea1ef

Browse files
authored
[agrifood] generation for azure-agrifood-farming (#18713)
1 parent 99aa3bc commit ffea1ef

File tree

78 files changed

+29807
-0
lines changed

Some content is hidden

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

78 files changed

+29807
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (Unreleased)
4+
5+
- This is the initial release of the Azure AgriFood Farming library.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
recursive-include tests *.py
2+
recursive-include samples *.py *.md
3+
include *.md
4+
include azure/__init__.py
5+
include azure/agrifood/__init__.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Azure AgriFood Farming client library for Python
2+
3+
## Getting started
4+
5+
### Prerequisites
6+
7+
- Python 2.7, or 3.6 or later is required to use this package.
8+
- You must have an [Azure subscription][azure_subscription] and an AgriFood resource to use this package.
9+
10+
#### Create an AgriFood Resource
11+
12+
### Install the package
13+
14+
Install the Azure AgriFood Farming client library for Python with [pip][pip]:
15+
16+
```bash
17+
pip install azure-agrifood-farming
18+
```
19+
20+
### Authenticate the client
21+
22+
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
23+
provide an instance of the desired credential type obtained from the
24+
[azure-identity][azure_identity_credentials] library.
25+
26+
To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] and
27+
enable AAD authentication on your AgriFood resource (ADD LINK).
28+
29+
After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
30+
As an example, [DefaultAzureCredential][default_azure_credential]
31+
can be used to authenticate the client:
32+
33+
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
34+
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
35+
36+
Use the returned token credential to authenticate the client:
37+
38+
```python
39+
from azure.agrifood.farming import FarmBeatsClient
40+
from azure.identity import DefaultAzureCredential
41+
42+
credential = DefaultAzureCredential()
43+
client = FarmBeatsClient(endpoint="https://<my-account-name>.farmbeats.azure.net", credential=credential)
44+
```
45+
46+
## Key concepts
47+
48+
## Examples
49+
50+
The following section shows you how to initialize and authenticate your client, then get all of your type-defs.
51+
52+
## Troubleshooting
53+
54+
### General
55+
56+
The AgriFood Farming client will raise exceptions defined in [Azure Core][azure_core] if you call `.raise_for_status()` on your responses.
57+
58+
### Logging
59+
60+
This library uses the standard
61+
[logging][python_logging] library for logging.
62+
Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO
63+
level.
64+
65+
Detailed DEBUG level logging, including request/response bodies and unredacted
66+
headers, can be enabled on a client with the `logging_enable` keyword argument:
67+
68+
```python
69+
import sys
70+
import logging
71+
from azure.identity import DefaultAzureCredential
72+
from azure.agrifood.farming import FarmBeatsClient
73+
74+
# Create a logger for the 'azure' SDK
75+
logger = logging.getLogger('azure')
76+
logger.setLevel(logging.DEBUG)
77+
78+
# Configure a console output
79+
handler = logging.StreamHandler(stream=sys.stdout)
80+
logger.addHandler(handler)
81+
82+
endpoint = "https://<my-account-name>.farmbeats.azure.net"
83+
credential = DefaultAzureCredential()
84+
85+
# This client will log detailed information about its HTTP sessions, at DEBUG level
86+
client = FarmBeatsClient(endpoint=endpoint, credential=credential, logging_enable=True)
87+
```
88+
89+
Similarly, `logging_enable` can enable detailed logging for a single call,
90+
even when it isn't enabled for the client:
91+
92+
```python
93+
client.crops.get(crop_id="crop_id", logging_enable=True)
94+
```
95+
96+
## Next steps
97+
98+
## Contributing
99+
100+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].
101+
102+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
103+
104+
This project has adopted the [Microsoft Open Source Code of Conduct][code_of_conduct]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or comments.
105+
106+
<!-- LINKS -->
107+
108+
[azure_subscription]: https://azure.microsoft.com/free/
109+
[pip]: https://pypi.org/project/pip/
110+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
111+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#credentials
112+
[azure_identity_pip]: https://pypi.org/project/azure-identity/
113+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#defaultazurecredential
114+
[python_logging]: https://docs.python.org/3.5/library/logging.html
115+
[cla]: https://cla.microsoft.com
116+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
117+
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
118+
[coc_contact]: mailto:[email protected]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from ._farm_beats_client import FarmBeatsClient
10+
from ._version import VERSION
11+
12+
__version__ = VERSION
13+
__all__ = ['FarmBeatsClient']
14+
15+
try:
16+
from ._patch import patch_sdk # type: ignore
17+
patch_sdk()
18+
except ImportError:
19+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import TYPE_CHECKING
10+
11+
from azure.core.configuration import Configuration
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
# pylint: disable=unused-import,ungrouped-imports
18+
from typing import Any
19+
20+
from azure.core.credentials import TokenCredential
21+
22+
23+
class FarmBeatsClientConfiguration(Configuration):
24+
"""Configuration for FarmBeatsClient.
25+
26+
Note that all parameters used to create this instance are saved as instance
27+
attributes.
28+
29+
:param credential: Credential needed for the client to connect to Azure.
30+
:type credential: ~azure.core.credentials.TokenCredential
31+
:param endpoint: The endpoint of your FarmBeats resource (protocol and hostname, for example: https://{resourceName}.farmbeats.azure.net).
32+
:type endpoint: str
33+
"""
34+
35+
def __init__(
36+
self,
37+
credential, # type: "TokenCredential"
38+
endpoint, # type: str
39+
**kwargs # type: Any
40+
):
41+
# type: (...) -> None
42+
if credential is None:
43+
raise ValueError("Parameter 'credential' must not be None.")
44+
if endpoint is None:
45+
raise ValueError("Parameter 'endpoint' must not be None.")
46+
super(FarmBeatsClientConfiguration, self).__init__(**kwargs)
47+
48+
self.credential = credential
49+
self.endpoint = endpoint
50+
self.api_version = "2021-03-31-preview"
51+
self.credential_scopes = kwargs.pop('credential_scopes', ['https://farmbeats.azure.net/.default'])
52+
kwargs.setdefault('sdk_moniker', 'agrifood-farming/{}'.format(VERSION))
53+
self._configure(**kwargs)
54+
55+
def _configure(
56+
self,
57+
**kwargs # type: Any
58+
):
59+
# type: (...) -> None
60+
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
61+
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
62+
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
63+
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
64+
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
65+
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
66+
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
67+
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
68+
self.authentication_policy = kwargs.get('authentication_policy')
69+
if self.credential and not self.authentication_policy:
70+
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)

0 commit comments

Comments
 (0)