Skip to content

Commit f8198fe

Browse files
committed
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-python into add_logging_param
* 'master' of https://github.com/Azure/azure-sdk-for-python: (33 commits) [text analytics] rerecord (Azure#18731) [agrifood] generation for azure-agrifood-farming (Azure#18713) [SB/EH] temporarily remove mgmt from ci pipeline (Azure#18724) bump core version (Azure#18723) Added policy Reset APIs; Cleaned up several model types. (Azure#18679) update release date (Azure#18704) Fixed PathProperties class init issue (Azure#18559) [agrifood] ignore swagger readme (Azure#18714) update for aiohttp 3.6 (Azure#18715) Renamed remaining connection string EV references (Azure#18682) Increment package version after release of azure-containerregistry (Azure#18683) skip live recording (Azure#18712) Increment package version after release of azure-identity (Azure#18710) Sample demonstrating authentication with a Key Vault certificate (Azure#18109) [AutoRelease] t2-storage-2021-05-13-13723 (Azure#18691) [AutoRelease] t2-loganalytics-2021-05-13-47912 (Azure#18694) useless sdk folder del (Azure#18688) [AutoRelease] t2-resource-2021-05-13-95786 (Azure#18686) update release date (Azure#18689) bump autorest version from '3.3.0' to '3.4.2' (Azure#18662) ...
2 parents 479769a + fe1f0b5 commit f8198fe

File tree

1,704 files changed

+181568
-185276
lines changed

Some content is hidden

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

1,704 files changed

+181568
-185276
lines changed

eng/.docsettings.yml

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ known_content_issues:
8686
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']
8787
- ['sdk/purview/azure-purview-catalog/swagger/README.md',  '#4554']
8888
- ['sdk/purview/azure-purview-scanning/swagger/README.md',  '#4554']
89+
- ['sdk/agrifood/azure-agrifood-farming/swagger/README.md',  '#4554']
8990
- ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554']
9091
- ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554']
9192
- ['sdk/attestation/azure-security-attestation/swagger/README.md', '#4554']

eng/common/pipelines/templates/steps/create-pull-request.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ parameters:
1313
PRTitle: not-specified
1414
PRBody: ''
1515
ScriptDirectory: eng/common/scripts
16-
GHReviewersVariable: ''
16+
GHReviewersVariable: ''
1717
GHTeamReviewersVariable: ''
1818
GHAssignessVariable: ''
1919
# Multiple labels seperated by comma, e.g. "bug, APIView"
@@ -33,7 +33,7 @@ steps:
3333
PushArgs: ${{ parameters.PushArgs }}
3434
WorkingDirectory: ${{ parameters.WorkingDirectory }}
3535
ScriptDirectory: ${{ parameters.ScriptDirectory }}
36-
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
36+
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
3737

3838
- task: PowerShell@2
3939
displayName: Create pull request

eng/common/pipelines/templates/steps/sparse-checkout.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ steps:
2020
- pwsh: |
2121
$dir = "${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}"
2222
New-Item $dir -ItemType Directory -Force
23+
displayName: Create ${{ repo.Name }} directories
2324
2425
- pwsh: |
2526
git clone --no-checkout --filter=tree:0 git://github.com/${{ repo.Name }} .

eng/tox/allowed_pylint_failures.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
"azure-purview-nspkg",
5555
"azure-purview-scanning",
5656
"azure-purview-catalog",
57-
"azure-messaging-nspkg"
57+
"azure-messaging-nspkg",
58+
"azure-agrifood-farming",
5859
]

scripts/devops_tasks/test_run_samples.py

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
"purchase_phone_number_sample.py",
113113
"release_phone_number_sample_async.py",
114114
"release_phone_number_sample.py"
115+
],
116+
"azure-ai-formrecognizer": [
117+
"sample_authentication.py",
118+
"sample_authentication_async.py"
115119
]
116120
}
117121

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
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# coding=utf-8
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for
5-
# license information.
6-
#
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
75
# Code generated by Microsoft (R) AutoRest Code Generator.
8-
# Changes may cause incorrect behavior and will be lost if the code is
9-
# regenerated.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
107
# --------------------------------------------------------------------------
118

12-
from .machine_learning_compute_management_client import MachineLearningComputeManagementClient
13-
from .version import VERSION
14-
15-
__all__ = ['MachineLearningComputeManagementClient']
9+
from ._farm_beats_client import FarmBeatsClient
10+
from ._version import VERSION
1611

1712
__version__ = VERSION
13+
__all__ = ['FarmBeatsClient']
1814

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)