-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Purview administration] first release #20874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1b1f4aa
part1 test
msyyc 4ed58d5
test and readme
msyyc e74f6da
CI fix
msyyc 378317a
fix dependency
msyyc 5483ad0
fix CI
msyyc 8a592fd
regenerate
msyyc e76c078
review
msyyc fa1d543
regenerate with new api version 2021-07-01-preview
msyyc 5ae0c78
update readme.md for python2.7 claim and setup.py for python 3.10
msyyc 1ad0c30
Merge branch 'main' into purview-adminastration-2021-09-23
msyyc 4acaf6b
Fix py.typed packaging
lmazuel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Release History | ||
|
|
||
| ## 1.0.0b1 (2021-09-29) | ||
|
|
||
| - This is the initial release of the Azure Purview Administration library. | ||
| - This package includes the operations of `azure-purview-account` that was previously released | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| recursive-include tests *.py | ||
| recursive-include samples *.py *.md | ||
| include *.md | ||
| include azure/__init__.py | ||
| include azure/purview/__init__.py | ||
| include azure/purview/administration/account/py.typed | ||
| include azure/purview/administration/metadatapolicies/py.typed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| # Azure Purview Administration client library for Python | ||
|
|
||
| Azure Purview is a fully managed cloud service. | ||
|
|
||
| **Please rely heavily on the [service's documentation][account_product_documentation] to use this library** | ||
|
|
||
| [Source code][source_code] | [Package (PyPI)][account_pypi] | [API reference documentation][account_ref_docs]| [Product documentation][account_product_documentation] | ||
|
|
||
| ## _Disclaimer_ | ||
|
|
||
| _Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ | ||
|
|
||
| ## 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 a [Purview][purview_resource] to use this package. | ||
|
|
||
| #### Create a Purview Resource | ||
|
|
||
| Follow [these][purview_resource] instructions to create your Purview resource | ||
|
|
||
| ### Install the package | ||
|
|
||
| Install the Azure Purview Account client library for Python with [pip][pip]: | ||
|
|
||
| ```bash | ||
| pip install azure-purview-administration | ||
| ``` | ||
|
|
||
| ### 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 Purview resource][enable_aad] | ||
|
|
||
| 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.purview.administration.account import PurviewAccountClient | ||
| from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient | ||
| from azure.identity import DefaultAzureCredential | ||
|
|
||
| credential = DefaultAzureCredential() | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| endpoint = "https://<my-account-name>.purview.azure.com" | ||
| account_client = PurviewAccountClient(endpoint=endpoint, credential=credential) | ||
| metadatapolicy_client = PurviewMetadataPoliciesClient(endpoint=endpoint, credential=credential) | ||
| ``` | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Key concepts | ||
|
|
||
| ### Client | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The package contains two kinds of client: `PurviewAccountClient` and `PurviewMetadataPoliciesClient`. You could use them | ||
| with one package according to your requirements. | ||
|
|
||
| ## Examples | ||
|
|
||
| The following section shows you how to initialize and authenticate your client, then list all of your keys. | ||
|
|
||
| - [Get Keys](#get-keys "Get All Keys") | ||
|
|
||
| ### Get Keys | ||
|
|
||
| ```python | ||
| from azure.purview.administration.account import PurviewAccountClient | ||
| from azure.identity import DefaultAzureCredential | ||
|
|
||
| credential = DefaultAzureCredential() | ||
| client = PurviewAccountClient(endpoint="https://<my-account-name>.purview.azure.com", credential=credential) | ||
| response = client.accounts.get_access_keys() | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print(response) | ||
| ``` | ||
|
|
||
| The following section shows you how to initialize and authenticate your client, then list all of your roles. | ||
|
|
||
| - [List_Roles](#list-roles "List Roles") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be further up under the |
||
|
|
||
| ### List Roles | ||
|
|
||
| ```python | ||
| from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient | ||
| from azure.identity import DefaultAzureCredential | ||
|
|
||
| credential = DefaultAzureCredential() | ||
| client = PurviewMetadataPoliciesClient(endpoint="https://<my-account-name>.purview.azure.com", credential=credential) | ||
| response = client.metadata_roles.list() | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| result = [item for item in response] | ||
| print(result) | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### General | ||
|
|
||
| The Purview client will raise exceptions if status code of your responses is not defined. | ||
|
|
||
| ### 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.purview.administration.account import PurviewAccountClient | ||
|
|
||
| # 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>.purview.azure.com" | ||
| credential = DefaultAzureCredential() | ||
|
|
||
| # This client will log detailed information about its HTTP sessions, at DEBUG level | ||
| client = PurviewAccountClient(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 | ||
| result = client.accounts.get_access_keys(logging_enable=True) | ||
| ``` | ||
|
|
||
| ## Next steps | ||
|
|
||
| For more generic samples, see our [client docs][request_builders_and_client]. | ||
|
|
||
| ## 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 [[email protected]][coc_contact] with any additional questions or comments. | ||
|
|
||
| <!-- LINKS --> | ||
|
|
||
| [source_code]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/purview/ | ||
| [account_pypi]: https://pypi.org/project/azure-purview-catalog/#history | ||
| [account_ref_docs]: https://azure.github.io/azure-sdk-for-python/ | ||
| [account_product_documentation]: https://azure.microsoft.com/services/purview/ | ||
| [azure_subscription]: https://azure.microsoft.com/free/ | ||
| [purview_resource]: https://docs.microsoft.com/azure/purview/create-catalog-portal | ||
| [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/main/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/main/sdk/identity/azure-identity#defaultazurecredential | ||
| [enable_aad]: https://docs.microsoft.com/azure/purview/create-catalog-portal#add-a-security-principal-to-a-data-plane-role | ||
| [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:[email protected] | ||
| [request_builders_and_client]: https://aka.ms/azsdk/python/protocol/quickstart | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
1 change: 1 addition & 0 deletions
1
sdk/purview/azure-purview-administration/azure/purview/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
1 change: 1 addition & 0 deletions
1
sdk/purview/azure-purview-administration/azure/purview/administration/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore |
8 changes: 8 additions & 0 deletions
8
sdk/purview/azure-purview-administration/azure/purview/administration/_version.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # 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. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| VERSION = "1.0.0b1" |
19 changes: 19 additions & 0 deletions
19
sdk/purview/azure-purview-administration/azure/purview/administration/account/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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. | ||
| # Code generated by Microsoft (R) AutoRest Code Generator. | ||
| # Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| from ._purview_account_client import PurviewAccountClient | ||
| from ._version import VERSION | ||
|
|
||
| __version__ = VERSION | ||
| __all__ = ['PurviewAccountClient'] | ||
|
|
||
| try: | ||
| from ._patch import patch_sdk # type: ignore | ||
| patch_sdk() | ||
| except ImportError: | ||
| pass |
70 changes: 70 additions & 0 deletions
70
...rview/azure-purview-administration/azure/purview/administration/account/_configuration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 PurviewAccountClientConfiguration(Configuration): | ||
| """Configuration for PurviewAccountClient. | ||
|
|
||
| Note that all parameters used to create this instance are saved as instance | ||
| attributes. | ||
|
|
||
| :param endpoint: The account endpoint of your Purview account. Example: https://{accountName}.purview.azure.com/account/. | ||
| :type endpoint: str | ||
| :param credential: Credential needed for the client to connect to Azure. | ||
| :type credential: ~azure.core.credentials.TokenCredential | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| endpoint, # type: str | ||
| credential, # type: "TokenCredential" | ||
| **kwargs # type: Any | ||
| ): | ||
| # type: (...) -> None | ||
| if endpoint is None: | ||
| raise ValueError("Parameter 'endpoint' must not be None.") | ||
| if credential is None: | ||
| raise ValueError("Parameter 'credential' must not be None.") | ||
| super(PurviewAccountClientConfiguration, self).__init__(**kwargs) | ||
|
|
||
| self.endpoint = endpoint | ||
| self.credential = credential | ||
| self.api_version = "2019-11-01-preview" | ||
| self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default']) | ||
| kwargs.setdefault('sdk_moniker', 'purview-administration/{}'.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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.