Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…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)
  ...
  • Loading branch information
iscai-msft committed May 13, 2021
2 parents 479769a + fe1f0b5 commit f8198fe
Show file tree
Hide file tree
Showing 1,704 changed files with 181,568 additions and 185,276 deletions.
1 change: 1 addition & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ known_content_issues:
- ['sdk/textanalytics/azure-ai-textanalytics/swagger/README.md', '#4554']
- ['sdk/purview/azure-purview-catalog/swagger/README.md',  '#4554']
- ['sdk/purview/azure-purview-scanning/swagger/README.md',  '#4554']
- ['sdk/agrifood/azure-agrifood-farming/swagger/README.md',  '#4554']
- ['sdk/containerregistry/azure-containerregistry/swagger/README.md', '#4554']
- ['sdk/appconfiguration/azure-appconfiguration/swagger/README.md', '#4554']
- ['sdk/attestation/azure-security-attestation/swagger/README.md', '#4554']
Expand Down
4 changes: 2 additions & 2 deletions eng/common/pipelines/templates/steps/create-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ parameters:
PRTitle: not-specified
PRBody: ''
ScriptDirectory: eng/common/scripts
GHReviewersVariable: ''
GHReviewersVariable: ''
GHTeamReviewersVariable: ''
GHAssignessVariable: ''
# Multiple labels seperated by comma, e.g. "bug, APIView"
Expand All @@ -33,7 +33,7 @@ steps:
PushArgs: ${{ parameters.PushArgs }}
WorkingDirectory: ${{ parameters.WorkingDirectory }}
ScriptDirectory: ${{ parameters.ScriptDirectory }}
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}
SkipCheckingForChanges: ${{ parameters.SkipCheckingForChanges }}

- task: PowerShell@2
displayName: Create pull request
Expand Down
1 change: 1 addition & 0 deletions eng/common/pipelines/templates/steps/sparse-checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ steps:
- pwsh: |
$dir = "${{ coalesce(repo.WorkingDirectory, format('{0}/{1}', '$(System.DefaultWorkingDirectory)', repo.Name)) }}"
New-Item $dir -ItemType Directory -Force
displayName: Create ${{ repo.Name }} directories
- pwsh: |
git clone --no-checkout --filter=tree:0 git://github.com/${{ repo.Name }} .
Expand Down
3 changes: 2 additions & 1 deletion eng/tox/allowed_pylint_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@
"azure-purview-nspkg",
"azure-purview-scanning",
"azure-purview-catalog",
"azure-messaging-nspkg"
"azure-messaging-nspkg",
"azure-agrifood-farming",
]
4 changes: 4 additions & 0 deletions scripts/devops_tasks/test_run_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
"purchase_phone_number_sample.py",
"release_phone_number_sample_async.py",
"release_phone_number_sample.py"
],
"azure-ai-formrecognizer": [
"sample_authentication.py",
"sample_authentication_async.py"
]
}

Expand Down
5 changes: 5 additions & 0 deletions sdk/agrifood/azure-agrifood-farming/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0b1 (Unreleased)

- This is the initial release of the Azure AgriFood Farming library.
5 changes: 5 additions & 0 deletions sdk/agrifood/azure-agrifood-farming/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
recursive-include tests *.py
recursive-include samples *.py *.md
include *.md
include azure/__init__.py
include azure/agrifood/__init__.py
118 changes: 118 additions & 0 deletions sdk/agrifood/azure-agrifood-farming/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Azure AgriFood Farming client library for Python

## Getting started

### Prerequisites

- Python 2.7, or 3.6 or later is required to use this package.
- You must have an [Azure subscription][azure_subscription] and an AgriFood resource to use this package.

#### Create an AgriFood Resource

### Install the package

Install the Azure AgriFood Farming client library for Python with [pip][pip]:

```bash
pip install azure-agrifood-farming
```

### Authenticate the client

To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
provide an instance of the desired credential type obtained from the
[azure-identity][azure_identity_credentials] library.

To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] and
enable AAD authentication on your AgriFood resource (ADD LINK).

After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use.
As an example, [DefaultAzureCredential][default_azure_credential]
can be used to authenticate the client:

Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables:
AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

Use the returned token credential to authenticate the client:

```python
from azure.agrifood.farming import FarmBeatsClient
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
client = FarmBeatsClient(endpoint="https://<my-account-name>.farmbeats.azure.net", credential=credential)
```

## Key concepts

## Examples

The following section shows you how to initialize and authenticate your client, then get all of your type-defs.

## Troubleshooting

### General

The AgriFood Farming client will raise exceptions defined in [Azure Core][azure_core] if you call `.raise_for_status()` on your responses.

### Logging

This library uses the standard
[logging][python_logging] library for logging.
Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO
level.

Detailed DEBUG level logging, including request/response bodies and unredacted
headers, can be enabled on a client with the `logging_enable` keyword argument:

```python
import sys
import logging
from azure.identity import DefaultAzureCredential
from azure.agrifood.farming import FarmBeatsClient

# Create a logger for the 'azure' SDK
logger = logging.getLogger('azure')
logger.setLevel(logging.DEBUG)

# Configure a console output
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)

endpoint = "https://<my-account-name>.farmbeats.azure.net"
credential = DefaultAzureCredential()

# This client will log detailed information about its HTTP sessions, at DEBUG level
client = FarmBeatsClient(endpoint=endpoint, credential=credential, logging_enable=True)
```

Similarly, `logging_enable` can enable detailed logging for a single call,
even when it isn't enabled for the client:

```python
client.crops.get(crop_id="crop_id", logging_enable=True)
```

## Next steps

## Contributing

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].

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.

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 [opencode@microsoft.com][coc_contact] with any additional questions or comments.

<!-- LINKS -->

[azure_subscription]: https://azure.microsoft.com/free/
[pip]: https://pypi.org/project/pip/
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#credentials
[azure_identity_pip]: https://pypi.org/project/azure-identity/
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/identity/azure-identity#defaultazurecredential
[python_logging]: https://docs.python.org/3.5/library/logging.html
[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:opencode@microsoft.com
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from .machine_learning_compute_management_client import MachineLearningComputeManagementClient
from .version import VERSION

__all__ = ['MachineLearningComputeManagementClient']
from ._farm_beats_client import FarmBeatsClient
from ._version import VERSION

__version__ = VERSION
__all__ = ['FarmBeatsClient']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.credentials import TokenCredential


class FarmBeatsClientConfiguration(Configuration):
"""Configuration for FarmBeatsClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: The endpoint of your FarmBeats resource (protocol and hostname, for example: https://{resourceName}.farmbeats.azure.net).
:type endpoint: str
"""

def __init__(
self,
credential, # type: "TokenCredential"
endpoint, # type: str
**kwargs # type: Any
):
# type: (...) -> None
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
super(FarmBeatsClientConfiguration, self).__init__(**kwargs)

self.credential = credential
self.endpoint = endpoint
self.api_version = "2021-03-31-preview"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://farmbeats.azure.net/.default'])
kwargs.setdefault('sdk_moniker', 'agrifood-farming/{}'.format(VERSION))
self._configure(**kwargs)

def _configure(
self,
**kwargs # type: Any
):
# type: (...) -> None
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get('authentication_policy')
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
Loading

0 comments on commit f8198fe

Please sign in to comment.