diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml index 2e5778981834..af881869d621 100644 --- a/eng/.docsettings.yml +++ b/eng/.docsettings.yml @@ -91,6 +91,7 @@ known_content_issues: - ['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/purview/azure-purview-account/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'] diff --git a/eng/tox/allowed_pylint_failures.py b/eng/tox/allowed_pylint_failures.py index b7a9fe1a1762..c929b50632ab 100644 --- a/eng/tox/allowed_pylint_failures.py +++ b/eng/tox/allowed_pylint_failures.py @@ -54,6 +54,7 @@ "azure-purview-nspkg", "azure-purview-scanning", "azure-purview-catalog", + "azure-purview-account", "azure-messaging-nspkg", "azure-agrifood-farming", "azure-eventhub", diff --git a/sdk/purview/azure-purview-account/CHANGELOG.md b/sdk/purview/azure-purview-account/CHANGELOG.md new file mode 100644 index 000000000000..4e25394e1429 --- /dev/null +++ b/sdk/purview/azure-purview-account/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (2021-08-23) + +- This is the initial release of the Azure Purview Account library. diff --git a/sdk/purview/azure-purview-account/MANIFEST.in b/sdk/purview/azure-purview-account/MANIFEST.in new file mode 100644 index 000000000000..f15ff0ee5293 --- /dev/null +++ b/sdk/purview/azure-purview-account/MANIFEST.in @@ -0,0 +1,5 @@ +recursive-include tests *.py +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/purview/__init__.py \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/README.md b/sdk/purview/azure-purview-account/README.md new file mode 100644 index 000000000000..9e768852a853 --- /dev/null +++ b/sdk/purview/azure-purview-account/README.md @@ -0,0 +1,151 @@ +# Azure Purview Account client library for Python + +Azure Purview Account is a fully managed cloud service. + +**Please rely heavily on the [service's documentation][account_product_documentation] and our [client docs][request_builders_and_client] to use this library** + +[Source code][source_code] | [Package (PyPI)][account_pypi] | [API reference documentation][account_ref_docs]| [Product documentation][account_product_documentation] + +## 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-account +``` + +### 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.account import PurviewAccountClient +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +client = PurviewAccountClient(endpoint="https://.purview.azure.com", credential=credential) +``` + +## Key concepts + +### Client + +## 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.account import PurviewAccountClient +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +client = PurviewAccountClient(endpoint="https://.purview.azure.com", credential=credential) +response = client.accounts.get_access_keys() +print(response) +``` + +## Troubleshooting + +### General + +The Purview Account 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.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://.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 [opencode@microsoft.com][coc_contact] with any additional questions or comments. + + + +[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 +[request_builders_and_client]: https://aka.ms/azsdk/python/protocol/quickstart +[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:opencode@microsoft.com diff --git a/sdk/purview/azure-purview-account/azure/__init__.py b/sdk/purview/azure-purview-account/azure/__init__.py new file mode 100644 index 000000000000..5960c353a898 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/azure/purview/__init__.py b/sdk/purview/azure-purview-account/azure/purview/__init__.py new file mode 100644 index 000000000000..5960c353a898 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) # type: ignore \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/azure/purview/account/__init__.py b/sdk/purview/azure-purview-account/azure/purview/account/__init__.py new file mode 100644 index 000000000000..d5c53ba7d43e --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/__init__.py @@ -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 diff --git a/sdk/purview/azure-purview-account/azure/purview/account/_configuration.py b/sdk/purview/azure-purview-account/azure/purview/account/_configuration.py new file mode 100644 index 000000000000..74582061d3e2 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/_configuration.py @@ -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-account/{}'.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) diff --git a/sdk/purview/azure-purview-account/azure/purview/account/_purview_account_client.py b/sdk/purview/azure-purview-account/azure/purview/account/_purview_account_client.py new file mode 100644 index 000000000000..62c1ff6f00c0 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/_purview_account_client.py @@ -0,0 +1,103 @@ +# 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 copy import deepcopy +from typing import TYPE_CHECKING + +from azure.core import PipelineClient +from msrest import Deserializer, Serializer + +from ._configuration import PurviewAccountClientConfiguration +from .operations import AccountsOperations, CollectionsOperations, ResourceSetRulesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Dict, Optional + + from azure.core.credentials import TokenCredential + from azure.core.rest import HttpRequest, HttpResponse + +class PurviewAccountClient(object): + """Creates a Microsoft.Purview data plane account client. + + :ivar accounts: AccountsOperations operations + :vartype accounts: azure.purview.account.operations.AccountsOperations + :ivar collections: CollectionsOperations operations + :vartype collections: azure.purview.account.operations.CollectionsOperations + :ivar resource_set_rules: ResourceSetRulesOperations operations + :vartype resource_set_rules: azure.purview.account.operations.ResourceSetRulesOperations + :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 + _endpoint = '{endpoint}' + self._config = PurviewAccountClientConfiguration(endpoint, credential, **kwargs) + self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.collections = CollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_set_rules = ResourceSetRulesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse + """Runs the network request through the client's chained policies. + + We have helper methods to create requests specific to this service in `azure.purview.account.rest`. + Use these helper methods to create the request you pass to this method. + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> PurviewAccountClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/purview/azure-purview-account/azure/purview/account/_version.py b/sdk/purview/azure-purview-account/azure/purview/account/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/__init__.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/__init__.py new file mode 100644 index 000000000000..1e668f62d8c2 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/__init__.py @@ -0,0 +1,10 @@ +# 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 +__all__ = ['PurviewAccountClient'] diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/_configuration.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/_configuration.py new file mode 100644 index 000000000000..655f01975acb --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 Any, 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 azure.core.credentials_async import AsyncTokenCredential + + +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_async.AsyncTokenCredential + """ + + def __init__( + self, + endpoint: str, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> 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-account/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> 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.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/_purview_account_client.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/_purview_account_client.py new file mode 100644 index 000000000000..80968f3291bd --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/_purview_account_client.py @@ -0,0 +1,98 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + +from ._configuration import PurviewAccountClientConfiguration +from .operations import AccountsOperations, CollectionsOperations, ResourceSetRulesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + +class PurviewAccountClient: + """Creates a Microsoft.Purview data plane account client. + + :ivar accounts: AccountsOperations operations + :vartype accounts: azure.purview.account.aio.operations.AccountsOperations + :ivar collections: CollectionsOperations operations + :vartype collections: azure.purview.account.aio.operations.CollectionsOperations + :ivar resource_set_rules: ResourceSetRulesOperations operations + :vartype resource_set_rules: azure.purview.account.aio.operations.ResourceSetRulesOperations + :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_async.AsyncTokenCredential + """ + + def __init__( + self, + endpoint: str, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + _endpoint = '{endpoint}' + self._config = PurviewAccountClientConfiguration(endpoint, credential, **kwargs) + self._client = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) + + self._serialize = Serializer() + self._deserialize = Deserializer() + self._serialize.client_side_validation = False + self.accounts = AccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.collections = CollectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.resource_set_rules = ResourceSetRulesOperations(self._client, self._config, self._serialize, self._deserialize) + + + def send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + We have helper methods to create requests specific to this service in `azure.purview.account.rest`. + Use these helper methods to create the request you pass to this method. + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + For advanced cases, you can also create your own :class:`~azure.core.rest.HttpRequest` + and pass it in. + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "PurviewAccountClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/__init__.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/__init__.py new file mode 100644 index 000000000000..9b3934fb09cb --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._accounts_operations import AccountsOperations +from ._collections_operations import CollectionsOperations +from ._resource_set_rules_operations import ResourceSetRulesOperations + +__all__ = [ + 'AccountsOperations', + 'CollectionsOperations', + 'ResourceSetRulesOperations', +] diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_accounts_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_accounts_operations.py new file mode 100644 index 000000000000..259b91c66b10 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_accounts_operations.py @@ -0,0 +1,409 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async + +from ...operations._accounts_operations import build_get_access_keys_request, build_get_account_properties_request, build_regenerate_access_key_request, build_update_account_properties_request + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccountsOperations: + """AccountsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get_account_properties( + self, + **kwargs: Any + ) -> Any: + """Get an account. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "identity": { + "principalId": "str (optional)", + "tenantId": "str (optional)", + "type": "str (optional)" + }, + "location": "str (optional)", + "name": "str (optional)", + "properties": { + "cloudConnectors": { + "awsExternalId": "str (optional)" + }, + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByObjectId": "str (optional)", + "endpoints": { + "catalog": "str (optional)", + "guardian": "str (optional)", + "scan": "str (optional)" + }, + "friendlyName": "str (optional)", + "managedResourceGroupName": "str (optional)", + "managedResources": { + "eventHubNamespace": "str (optional)", + "resourceGroup": "str (optional)", + "storageAccount": "str (optional)" + }, + "privateEndpointConnections": [ + { + "id": "str (optional)", + "name": "str (optional)", + "properties": { + "privateEndpoint": { + "id": "str (optional)" + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str (optional)", + "description": "str (optional)", + "status": "str (optional)" + }, + "provisioningState": "str (optional)" + }, + "type": "str (optional)" + } + ], + "provisioningState": "str (optional)", + "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" + }, + "sku": { + "capacity": "int (optional)", + "name": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + }, + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_account_properties_request( + template_url=self.get_account_properties.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_account_properties.metadata = {'url': '/'} # type: ignore + + + @distributed_trace_async + async def update_account_properties( + self, + account_update_parameters: Any, + **kwargs: Any + ) -> Any: + """Updates an account. + + :param account_update_parameters: + :type account_update_parameters: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + account_update_parameters = { + "friendlyName": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "identity": { + "principalId": "str (optional)", + "tenantId": "str (optional)", + "type": "str (optional)" + }, + "location": "str (optional)", + "name": "str (optional)", + "properties": { + "cloudConnectors": { + "awsExternalId": "str (optional)" + }, + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByObjectId": "str (optional)", + "endpoints": { + "catalog": "str (optional)", + "guardian": "str (optional)", + "scan": "str (optional)" + }, + "friendlyName": "str (optional)", + "managedResourceGroupName": "str (optional)", + "managedResources": { + "eventHubNamespace": "str (optional)", + "resourceGroup": "str (optional)", + "storageAccount": "str (optional)" + }, + "privateEndpointConnections": [ + { + "id": "str (optional)", + "name": "str (optional)", + "properties": { + "privateEndpoint": { + "id": "str (optional)" + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str (optional)", + "description": "str (optional)", + "status": "str (optional)" + }, + "provisioningState": "str (optional)" + }, + "type": "str (optional)" + } + ], + "provisioningState": "str (optional)", + "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" + }, + "sku": { + "capacity": "int (optional)", + "name": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + }, + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = account_update_parameters + + request = build_update_account_properties_request( + content_type=content_type, + json=json, + template_url=self.update_account_properties.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_account_properties.metadata = {'url': '/'} # type: ignore + + + @distributed_trace_async + async def get_access_keys( + self, + **kwargs: Any + ) -> Any: + """List the authorization keys associated with this account. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str (optional)", + "atlasKafkaSecondaryEndpoint": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_access_keys_request( + template_url=self.get_access_keys.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_access_keys.metadata = {'url': '/listkeys'} # type: ignore + + + @distributed_trace_async + async def regenerate_access_key( + self, + key_options: Any, + **kwargs: Any + ) -> Any: + """Regenerate the authorization keys associated with this data catalog. + + :param key_options: + :type key_options: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + key_options = { + "keyType": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str (optional)", + "atlasKafkaSecondaryEndpoint": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = key_options + + request = build_regenerate_access_key_request( + content_type=content_type, + json=json, + template_url=self.regenerate_access_key.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_access_key.metadata = {'url': '/regeneratekeys'} # type: ignore + diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_collections_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_collections_operations.py new file mode 100644 index 000000000000..d2bd035f7fe4 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_collections_operations.py @@ -0,0 +1,519 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from json import loads as _loads +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async + +from ...operations._collections_operations import build_create_or_update_collection_request, build_delete_collection_request, build_get_collection_path_request, build_get_collection_request, build_list_child_collection_names_request, build_list_collections_request + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class CollectionsOperations: + """CollectionsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get_collection( + self, + collection_name: str, + **kwargs: Any + ) -> Any: + """Get a collection. + + :param collection_name: + :type collection_name: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_collection_request( + collection_name=collection_name, + template_url=self.get_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update_collection( + self, + collection_name: str, + collection: Any, + **kwargs: Any + ) -> Any: + """Creates or updates a collection entity. + + :param collection_name: + :type collection_name: str + :param collection: + :type collection: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + collection = { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = collection + + request = build_create_or_update_collection_request( + collection_name=collection_name, + content_type=content_type, + json=json, + template_url=self.create_or_update_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace_async + async def delete_collection( + self, + collection_name: str, + **kwargs: Any + ) -> None: + """Deletes a Collection entity. + + :param collection_name: + :type collection_name: str + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_collection_request( + collection_name=collection_name, + template_url=self.delete_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace + def list_collections( + self, + *, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List the collections in the account. + + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_collections_request( + skip_token=skip_token, + template_url=self.list_collections.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_collections_request( + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_collections.metadata = {'url': '/collections'} # type: ignore + + @distributed_trace + def list_child_collection_names( + self, + collection_name: str, + *, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[Any]: + """Lists the child collections names in the collection. + + :param collection_name: + :type collection_name: str + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "friendlyName": "str (optional)", + "name": "str (optional)" + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=self.list_child_collection_names.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_child_collection_names.metadata = {'url': '/collections/{collectionName}/getChildCollectionNames'} # type: ignore + + @distributed_trace_async + async def get_collection_path( + self, + collection_name: str, + **kwargs: Any + ) -> Any: + """Gets the parent name and parent friendly name chains that represent the collection path. + + :param collection_name: + :type collection_name: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "parentFriendlyNameChain": [ + "str (optional)" + ], + "parentNameChain": [ + "str (optional)" + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_collection_path_request( + collection_name=collection_name, + template_url=self.get_collection_path.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_collection_path.metadata = {'url': '/collections/{collectionName}/getCollectionPath'} # type: ignore + diff --git a/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_resource_set_rules_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_resource_set_rules_operations.py new file mode 100644 index 000000000000..5a2156c7e9e6 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/aio/operations/_resource_set_rules_operations.py @@ -0,0 +1,786 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from json import loads as _loads +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async + +from ...operations._resource_set_rules_operations import build_create_or_update_resource_set_rule_request, build_delete_resource_set_rule_request, build_get_resource_set_rule_request, build_list_resource_set_rules_request + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourceSetRulesOperations: + """ResourceSetRulesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def get_resource_set_rule( + self, + **kwargs: Any + ) -> Any: + """Get a resource set config service model. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_resource_set_rule_request( + template_url=self.get_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace_async + async def create_or_update_resource_set_rule( + self, + resource_set_rule_config: Any, + **kwargs: Any + ) -> Any: + """Creates or updates an resource set config. + + :param resource_set_rule_config: + :type resource_set_rule_config: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource_set_rule_config = { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = resource_set_rule_config + + request = build_create_or_update_resource_set_rule_request( + content_type=content_type, + json=json, + template_url=self.create_or_update_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace_async + async def delete_resource_set_rule( + self, + **kwargs: Any + ) -> None: + """Deletes a ResourceSetRuleConfig resource. + + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_resource_set_rule_request( + template_url=self.delete_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace + def list_resource_set_rules( + self, + *, + skip_token: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[Any]: + """Get a resource set config service model. + + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.async_paging.AsyncItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_resource_set_rules_request( + skip_token=skip_token, + template_url=self.list_resource_set_rules.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_resource_set_rules_request( + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_resource_set_rules.metadata = {'url': '/resourceSetRuleConfigs'} # type: ignore diff --git a/sdk/purview/azure-purview-account/azure/purview/account/operations/__init__.py b/sdk/purview/azure-purview-account/azure/purview/account/operations/__init__.py new file mode 100644 index 000000000000..9b3934fb09cb --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/operations/__init__.py @@ -0,0 +1,17 @@ +# 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 ._accounts_operations import AccountsOperations +from ._collections_operations import CollectionsOperations +from ._resource_set_rules_operations import ResourceSetRulesOperations + +__all__ = [ + 'AccountsOperations', + 'CollectionsOperations', + 'ResourceSetRulesOperations', +] diff --git a/sdk/purview/azure-purview-account/azure/purview/account/operations/_accounts_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/operations/_accounts_operations.py new file mode 100644 index 000000000000..4694fce07df3 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/operations/_accounts_operations.py @@ -0,0 +1,531 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_get_account_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_account_properties_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_access_keys_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/listkeys') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_regenerate_access_key_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/regeneratekeys') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class AccountsOperations(object): + """AccountsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get_account_properties( + self, + **kwargs # type: Any + ): + # type: (...) -> Any + """Get an account. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "identity": { + "principalId": "str (optional)", + "tenantId": "str (optional)", + "type": "str (optional)" + }, + "location": "str (optional)", + "name": "str (optional)", + "properties": { + "cloudConnectors": { + "awsExternalId": "str (optional)" + }, + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByObjectId": "str (optional)", + "endpoints": { + "catalog": "str (optional)", + "guardian": "str (optional)", + "scan": "str (optional)" + }, + "friendlyName": "str (optional)", + "managedResourceGroupName": "str (optional)", + "managedResources": { + "eventHubNamespace": "str (optional)", + "resourceGroup": "str (optional)", + "storageAccount": "str (optional)" + }, + "privateEndpointConnections": [ + { + "id": "str (optional)", + "name": "str (optional)", + "properties": { + "privateEndpoint": { + "id": "str (optional)" + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str (optional)", + "description": "str (optional)", + "status": "str (optional)" + }, + "provisioningState": "str (optional)" + }, + "type": "str (optional)" + } + ], + "provisioningState": "str (optional)", + "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" + }, + "sku": { + "capacity": "int (optional)", + "name": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + }, + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_account_properties_request( + template_url=self.get_account_properties.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_account_properties.metadata = {'url': '/'} # type: ignore + + + @distributed_trace + def update_account_properties( + self, + account_update_parameters, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Updates an account. + + :param account_update_parameters: + :type account_update_parameters: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + account_update_parameters = { + "friendlyName": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "id": "str (optional)", + "identity": { + "principalId": "str (optional)", + "tenantId": "str (optional)", + "type": "str (optional)" + }, + "location": "str (optional)", + "name": "str (optional)", + "properties": { + "cloudConnectors": { + "awsExternalId": "str (optional)" + }, + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByObjectId": "str (optional)", + "endpoints": { + "catalog": "str (optional)", + "guardian": "str (optional)", + "scan": "str (optional)" + }, + "friendlyName": "str (optional)", + "managedResourceGroupName": "str (optional)", + "managedResources": { + "eventHubNamespace": "str (optional)", + "resourceGroup": "str (optional)", + "storageAccount": "str (optional)" + }, + "privateEndpointConnections": [ + { + "id": "str (optional)", + "name": "str (optional)", + "properties": { + "privateEndpoint": { + "id": "str (optional)" + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str (optional)", + "description": "str (optional)", + "status": "str (optional)" + }, + "provisioningState": "str (optional)" + }, + "type": "str (optional)" + } + ], + "provisioningState": "str (optional)", + "publicNetworkAccess": "str (optional). Default value is \"Enabled\"" + }, + "sku": { + "capacity": "int (optional)", + "name": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + }, + "tags": { + "str": "str (optional)" + }, + "type": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = account_update_parameters + + request = build_update_account_properties_request( + content_type=content_type, + json=json, + template_url=self.update_account_properties.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update_account_properties.metadata = {'url': '/'} # type: ignore + + + @distributed_trace + def get_access_keys( + self, + **kwargs # type: Any + ): + # type: (...) -> Any + """List the authorization keys associated with this account. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str (optional)", + "atlasKafkaSecondaryEndpoint": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_access_keys_request( + template_url=self.get_access_keys.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_access_keys.metadata = {'url': '/listkeys'} # type: ignore + + + @distributed_trace + def regenerate_access_key( + self, + key_options, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Regenerate the authorization keys associated with this data catalog. + + :param key_options: + :type key_options: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + key_options = { + "keyType": "str (optional)" + } + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str (optional)", + "atlasKafkaSecondaryEndpoint": "str (optional)" + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = key_options + + request = build_regenerate_access_key_request( + content_type=content_type, + json=json, + template_url=self.regenerate_access_key.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_access_key.metadata = {'url': '/regeneratekeys'} # type: ignore + diff --git a/sdk/purview/azure-purview-account/azure/purview/account/operations/_collections_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/operations/_collections_operations.py new file mode 100644 index 000000000000..73d946a278a0 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/operations/_collections_operations.py @@ -0,0 +1,729 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from json import loads as _loads +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.pipeline.transport._base import _format_url_section +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_get_collection_request( + collection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections/{collectionName}') + path_format_arguments = { + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_collection_request( + collection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections/{collectionName}') + path_format_arguments = { + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_collection_request( + collection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections/{collectionName}') + path_format_arguments = { + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_collections_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_child_collection_names_request( + collection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections/{collectionName}/getChildCollectionNames') + path_format_arguments = { + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_collection_path_request( + collection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/collections/{collectionName}/getCollectionPath') + path_format_arguments = { + "collectionName": _SERIALIZER.url("collection_name", collection_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class CollectionsOperations(object): + """CollectionsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get_collection( + self, + collection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a collection. + + :param collection_name: + :type collection_name: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_collection_request( + collection_name=collection_name, + template_url=self.get_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace + def create_or_update_collection( + self, + collection_name, # type: str + collection, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or updates a collection entity. + + :param collection_name: + :type collection_name: str + :param collection: + :type collection: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + collection = { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = collection + + request = build_create_or_update_collection_request( + collection_name=collection_name, + content_type=content_type, + json=json, + template_url=self.create_or_update_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace + def delete_collection( + self, + collection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a Collection entity. + + :param collection_name: + :type collection_name: str + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_collection_request( + collection_name=collection_name, + template_url=self.delete_collection.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_collection.metadata = {'url': '/collections/{collectionName}'} # type: ignore + + + @distributed_trace + def list_collections( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List the collections in the account. + + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "collectionProvisioningState": "str (optional)", + "description": "str (optional)", + "friendlyName": "str (optional)", + "name": "str (optional)", + "parentCollection": { + "referenceName": "str (optional)", + "type": "str (optional)" + }, + "systemData": { + "createdAt": "datetime (optional)", + "createdBy": "str (optional)", + "createdByType": "str (optional)", + "lastModifiedAt": "datetime (optional)", + "lastModifiedBy": "str (optional)", + "lastModifiedByType": "str (optional)" + } + } + ] + } + """ + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_collections_request( + skip_token=skip_token, + template_url=self.list_collections.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_collections_request( + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_collections.metadata = {'url': '/collections'} # type: ignore + + @distributed_trace + def list_child_collection_names( + self, + collection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """Lists the child collections names in the collection. + + :param collection_name: + :type collection_name: str + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "friendlyName": "str (optional)", + "name": "str (optional)" + } + ] + } + """ + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=self.list_child_collection_names.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_child_collection_names.metadata = {'url': '/collections/{collectionName}/getChildCollectionNames'} # type: ignore + + @distributed_trace + def get_collection_path( + self, + collection_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Gets the parent name and parent friendly name chains that represent the collection path. + + :param collection_name: + :type collection_name: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "parentFriendlyNameChain": [ + "str (optional)" + ], + "parentNameChain": [ + "str (optional)" + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_collection_path_request( + collection_name=collection_name, + template_url=self.get_collection_path.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_collection_path.metadata = {'url': '/collections/{collectionName}/getCollectionPath'} # type: ignore + diff --git a/sdk/purview/azure-purview-account/azure/purview/account/operations/_resource_set_rules_operations.py b/sdk/purview/azure-purview-account/azure/purview/account/operations/_resource_set_rules_operations.py new file mode 100644 index 000000000000..4e65e11cab96 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/operations/_resource_set_rules_operations.py @@ -0,0 +1,907 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from json import loads as _loads +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_get_resource_set_rule_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/resourceSetRuleConfigs/defaultResourceSetRuleConfig') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_resource_set_rule_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/resourceSetRuleConfigs/defaultResourceSetRuleConfig') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_resource_set_rule_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/resourceSetRuleConfigs/defaultResourceSetRuleConfig') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_resource_set_rules_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/resourceSetRuleConfigs') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if skip_token is not None: + query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on +class ResourceSetRulesOperations(object): + """ResourceSetRulesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get_resource_set_rule( + self, + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a resource set config service model. + + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_resource_set_rule_request( + template_url=self.get_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace + def create_or_update_resource_set_rule( + self, + resource_set_rule_config, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or updates an resource set config. + + :param resource_set_rule_config: + :type resource_set_rule_config: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # JSON input template you can fill out and use as your body input. + resource_set_rule_config = { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = resource_set_rule_config + + request = build_create_or_update_resource_set_rule_request( + content_type=content_type, + json=json, + template_url=self.create_or_update_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace + def delete_resource_set_rule( + self, + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a ResourceSetRuleConfig resource. + + :return: None + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_resource_set_rule_request( + template_url=self.delete_resource_set_rule.metadata['url'], + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) + + delete_resource_set_rule.metadata = {'url': '/resourceSetRuleConfigs/defaultResourceSetRuleConfig'} # type: ignore + + + @distributed_trace + def list_resource_set_rules( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """Get a resource set config service model. + + :keyword skip_token: + :paramtype skip_token: str + :return: An iterator like instance of JSON object + :rtype: ~azure.core.paging.ItemPaged[Any] + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "count": "long (optional)", + "nextLink": "str (optional)", + "value": [ + { + "advancedResourceSet": { + "modifiedAt": "datetime (optional)", + "resourceSetProcessing": "str (optional)" + }, + "name": "str (optional)", + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "complexReplacers": [ + { + "createdBy": "str (optional)", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool (optional)", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional)", + "name": "str (optional)", + "typeName": "str (optional)" + } + ], + "createdBy": "str", + "enableDefaultPatterns": "bool", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "normalizationRules": [ + { + "description": "str (optional)", + "disabled": "bool (optional)", + "dynamicReplacement": "bool (optional)", + "entityTypes": [ + "str (optional)" + ], + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)", + "version": "float (optional)" + } + ], + "regexReplacers": [ + { + "condition": "str (optional)", + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "description": "str (optional)", + "disableRecursiveReplacerApplication": "bool (optional)", + "disabled": "bool", + "doNotReplaceRegex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "regex": { + "maxDigits": "int (optional)", + "maxLetters": "int (optional)", + "minDashes": "int (optional)", + "minDigits": "int (optional)", + "minDigitsOrLetters": "int (optional)", + "minDots": "int (optional)", + "minHex": "int (optional)", + "minLetters": "int (optional)", + "minUnderscores": "int (optional)", + "options": "int (optional)", + "regexStr": "str (optional)" + }, + "replaceWith": "str (optional)" + } + ], + "rejectedPatterns": [ + { + "createdBy": "str (optional). Default value is \"AzureDataCatalog\"", + "filterType": "str (optional). Default value is \"Pattern\"", + "lastUpdatedTimestamp": "long (optional)", + "modifiedBy": "str (optional). Default value is \"AzureDataCatalog\"", + "name": "str", + "path": "str" + } + ], + "scopedRules": [ + { + "bindingUrl": "str", + "rules": [ + { + "displayName": "str (optional)", + "isResourceSet": "bool (optional). Default value is True", + "lastUpdatedTimestamp": "long (optional)", + "name": "str (optional)", + "qualifiedName": "str" + } + ], + "storeType": "str" + } + ], + "version": "int (optional). Default value is 0" + } + } + ] + } + """ + skip_token = kwargs.pop('skip_token', None) # type: Optional[str] + + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_resource_set_rules_request( + skip_token=skip_token, + template_url=self.list_resource_set_rules.metadata['url'], + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + else: + + request = build_list_resource_set_rules_request( + skip_token=skip_token, + template_url=next_link, + )._to_pipeline_transport_request() + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.url = self._client.format_url(request.url, **path_format_arguments) + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + } + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = _loads(pipeline_response.http_response.body()) + list_of_elem = deserialized["value"] + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.get("nextLink", None), iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_resource_set_rules.metadata = {'url': '/resourceSetRuleConfigs'} # type: ignore diff --git a/sdk/purview/azure-purview-account/azure/purview/account/py.typed b/sdk/purview/azure-purview-account/azure/purview/account/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/purview/azure-purview-account/azure/purview/account/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/dev_requirements.txt b/sdk/purview/azure-purview-account/dev_requirements.txt new file mode 100644 index 000000000000..60e6d0eeff43 --- /dev/null +++ b/sdk/purview/azure-purview-account/dev_requirements.txt @@ -0,0 +1,6 @@ +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools +../../core/azure-core +-e ../../identity/azure-identity +../../nspkg/azure-purview-nspkg +aiohttp>=3.0; python_version >= '3.5' \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/sdk_packaging.toml b/sdk/purview/azure-purview-account/sdk_packaging.toml new file mode 100644 index 000000000000..6f823f446798 --- /dev/null +++ b/sdk/purview/azure-purview-account/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +auto_update = false +package_name = "azure-purview-account" +package_pprint_name = "Azure Purview Account" +is_stable = false +is_arm = false + +# Package owners should uncomment and set this doc id. +# package_doc_id = "purview-account" \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/setup.cfg b/sdk/purview/azure-purview-account/setup.cfg new file mode 100644 index 000000000000..3480374bc2f2 --- /dev/null +++ b/sdk/purview/azure-purview-account/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/setup.py b/sdk/purview/azure-purview-account/setup.py new file mode 100644 index 000000000000..43175e611ea0 --- /dev/null +++ b/sdk/purview/azure-purview-account/setup.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-purview-account" +PACKAGE_PPRINT_NAME = "Azure Purview Account" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + "Development Status :: 4 - Beta", + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.purview', + ]), + install_requires=[ + "azure-core<2.0.0,>=1.16.0", + "msrest>=0.6.21", + 'six>=1.11.0', + ], + extras_require={ + ":python_version<'3.0'": ['azure-purview-nspkg'], + ":python_version<'3.5'": ['typing'], + } +) \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/swagger/README.md b/sdk/purview/azure-purview-account/swagger/README.md new file mode 100644 index 000000000000..a863f80392a6 --- /dev/null +++ b/sdk/purview/azure-purview-account/swagger/README.md @@ -0,0 +1,36 @@ +# Azure Purview for Python + +> see https://aka.ms/autorest + +### Setup + +Install Autorest v3 + +```ps +npm install -g autorest +``` + +### Generation + +```ps +cd +autorest +``` + +### Settings + +```yaml +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.Account/preview/2019-11-01-preview/account.json +output-folder: ../azure/purview/account +namespace: azure.purview.account +package-name: azure-purview-account +license-header: MICROSOFT_MIT_NO_VERSION +clear-output-folder: true +no-namespace-folders: true +python: true +title: PurviewAccountClient +version-tolerant: true +package-version: 1.0.0b1 +add-credential: true +credential-scopes: https://purview.azure.net/.default +``` diff --git a/sdk/purview/azure-purview-account/tests/_util.py b/sdk/purview/azure-purview-account/tests/_util.py new file mode 100644 index 000000000000..2f45bd9149a5 --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/_util.py @@ -0,0 +1,25 @@ +# 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. +# -------------------------------------------------------------------------- +from azure_devtools.scenario_tests import RecordingProcessor +import json + + +class PurviewAccountRecordingProcessor(RecordingProcessor): + def process_response(self, response): + response["body"]["string"] = '{"atlasKafkaPrimaryEndpoint":"000","atlasKafkaSecondaryEndpoint":"000"}' + return response + + +class PurviewAccountCollectionsRecordingProcessor(RecordingProcessor): + def process_response(self, response): + try: + body = json.loads(response["body"]["string"]) + for value in body["value"]: + value["systemData"] = "000" + response["body"]["string"] = json.dumps(body) + finally: + return response diff --git a/sdk/purview/azure-purview-account/tests/conftest.py b/sdk/purview/azure-purview-account/tests/conftest.py new file mode 100644 index 000000000000..a6ab83f7f5f0 --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/conftest.py @@ -0,0 +1,15 @@ +# 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. +# -------------------------------------------------------------------------- + +import sys + +# fixture needs to be visible from conftest + +# Ignore async tests for Python < 3.5 +collect_ignore_glob = [] +if sys.version_info < (3, 5): + collect_ignore_glob.append("*_async.py") \ No newline at end of file diff --git a/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_basic_smoke_test.yaml new file mode 100644 index 000000000000..ccfa4efef067 --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_basic_smoke_test.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + User-Agent: + - azsdk-python-purview-account/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://fake_account.account.purview.azure.com/listkeys?api-version=2019-11-01-preview + response: + body: + string: '{"atlasKafkaPrimaryEndpoint":"000","atlasKafkaSecondaryEndpoint":"000"}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Tue, 24 Aug 2021 03:00:07 GMT + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_collections_list.yaml b/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_collections_list.yaml new file mode 100644 index 000000000000..a9c39433f1e5 --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/recordings/test_smoke.test_collections_list.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-purview-account/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/collections?api-version=2019-11-01-preview + response: + body: + string: '{"value": [{"name": "purview-msyyc", "friendlyName": "purview-msyyc", + "description": "The root collection.", "systemData": "000", "collectionProvisioningState": + "Succeeded"}], "count": 1}' + headers: + content-type: + - application/json; charset=utf-8 + date: + - Tue, 24 Aug 2021 03:00:09 GMT + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml new file mode 100644 index 000000000000..480b26a80f6c --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-purview-account/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://fake_account.account.purview.azure.com/listkeys?api-version=2019-11-01-preview + response: + body: + string: '{"atlasKafkaPrimaryEndpoint":"000","atlasKafkaSecondaryEndpoint":"000"}' + headers: + content-type: application/json; charset=utf-8 + date: Tue, 24 Aug 2021 03:00:26 GMT + server: Kestrel + strict-transport-security: max-age=31536000; includeSubDomains + transfer-encoding: chunked + status: + code: 200 + message: OK + url: https://purview-msyyc.purview.azure.com/listkeys?api-version=2019-11-01-preview +version: 1 diff --git a/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_collections_list.yaml b/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_collections_list.yaml new file mode 100644 index 000000000000..c0a4f323f0cc --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/recordings/test_smoke_async.test_collections_list.yaml @@ -0,0 +1,26 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-purview-account/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/collections?api-version=2019-11-01-preview + response: + body: + string: '{"value": [{"name": "purview-msyyc", "friendlyName": "purview-msyyc", + "description": "The root collection.", "systemData": "000", "collectionProvisioningState": + "Succeeded"}], "count": 1}' + headers: + content-type: application/json; charset=utf-8 + date: Tue, 24 Aug 2021 03:00:29 GMT + server: Kestrel + strict-transport-security: max-age=31536000; includeSubDomains + transfer-encoding: chunked + status: + code: 200 + message: OK + url: https://purview-msyyc.purview.azure.com/collections?api-version=2019-11-01-preview +version: 1 diff --git a/sdk/purview/azure-purview-account/tests/test_smoke.py b/sdk/purview/azure-purview-account/tests/test_smoke.py new file mode 100644 index 000000000000..104feb458b65 --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/test_smoke.py @@ -0,0 +1,27 @@ +# 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. +# ------------------------------------------------------------------------- +from testcase import PurviewAccountTest, PurviewAccountPowerShellPreparer +from _util import PurviewAccountRecordingProcessor, PurviewAccountCollectionsRecordingProcessor + + +class PurviewAccountSmokeTest(PurviewAccountTest): + + @PurviewAccountPowerShellPreparer() + def test_basic_smoke_test(self, purviewaccount_endpoint): + self.recording_processors.append(PurviewAccountRecordingProcessor()) + client = self.create_client(endpoint=purviewaccount_endpoint) + response = client.accounts.get_access_keys() + assert set(response.keys()) == set(['atlasKafkaPrimaryEndpoint', 'atlasKafkaSecondaryEndpoint']) + + @PurviewAccountPowerShellPreparer() + def test_collections_list(self, purviewaccount_endpoint): + self.recording_processors.append(PurviewAccountCollectionsRecordingProcessor()) + client = self.create_client(endpoint=purviewaccount_endpoint) + response = client.collections.list_collections() + result = [item for item in response] + for item in result: + assert set(item.keys()) == set(['name', 'friendlyName', 'description', 'systemData', 'collectionProvisioningState']) diff --git a/sdk/purview/azure-purview-account/tests/test_smoke_async.py b/sdk/purview/azure-purview-account/tests/test_smoke_async.py new file mode 100644 index 000000000000..7d98e1042b5d --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/test_smoke_async.py @@ -0,0 +1,28 @@ +# 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. +# ------------------------------------------------------------------------- +from testcase import PurviewAccountPowerShellPreparer +from testcase_async import PurviewAccountTestAsync +from _util import PurviewAccountRecordingProcessor, PurviewAccountCollectionsRecordingProcessor + + +class PurviewAccountSmokeTestAsync(PurviewAccountTestAsync): + + @PurviewAccountPowerShellPreparer() + async def test_basic_smoke_test(self, purviewaccount_endpoint): + self.recording_processors.append(PurviewAccountRecordingProcessor()) + client = self.create_async_client(endpoint=purviewaccount_endpoint) + response = await client.accounts.get_access_keys() + assert set(response.keys()) == set(['atlasKafkaPrimaryEndpoint', 'atlasKafkaSecondaryEndpoint']) + + @PurviewAccountPowerShellPreparer() + async def test_collections_list(self, purviewaccount_endpoint): + self.recording_processors.append(PurviewAccountCollectionsRecordingProcessor()) + client = self.create_async_client(endpoint=purviewaccount_endpoint) + response = client.collections.list_collections() + result = [item async for item in response] + for item in result: + assert set(item.keys()) == set(['name', 'friendlyName', 'description', 'systemData', 'collectionProvisioningState']) diff --git a/sdk/purview/azure-purview-account/tests/testcase.py b/sdk/purview/azure-purview-account/tests/testcase.py new file mode 100644 index 000000000000..1668f540b03c --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/testcase.py @@ -0,0 +1,29 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from devtools_testutils import AzureTestCase, PowerShellPreparer +from azure.purview.account import PurviewAccountClient + + +class PurviewAccountTest(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(PurviewAccountTest, self).__init__(method_name, **kwargs) + + def create_client(self, endpoint): + credential = self.get_credential(PurviewAccountClient) + return self.create_client_from_credential( + PurviewAccountClient, + credential=credential, + endpoint=endpoint, + ) + + +PurviewAccountPowerShellPreparer = functools.partial( + PowerShellPreparer, + "purviewaccount", + purviewaccount_endpoint="https://fake_account.account.purview.azure.com" +) diff --git a/sdk/purview/azure-purview-account/tests/testcase_async.py b/sdk/purview/azure-purview-account/tests/testcase_async.py new file mode 100644 index 000000000000..0b45881ee9cc --- /dev/null +++ b/sdk/purview/azure-purview-account/tests/testcase_async.py @@ -0,0 +1,21 @@ +# 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. +# -------------------------------------------------------------------------- +from devtools_testutils import AzureTestCase +from azure.purview.account.aio import PurviewAccountClient as AsyncPurviewAccountClient + + +class PurviewAccountTestAsync(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(PurviewAccountTestAsync, self).__init__(method_name, **kwargs) + + def create_async_client(self, endpoint): + credential = self.get_credential(AsyncPurviewAccountClient, is_async=True) + return self.create_client_from_credential( + AsyncPurviewAccountClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/sdk/purview/ci.yml b/sdk/purview/ci.yml index ec7853234383..2eac49904741 100644 --- a/sdk/purview/ci.yml +++ b/sdk/purview/ci.yml @@ -35,3 +35,5 @@ extends: safeName: azurepurviewscanning - name: azure-purview-catalog safeName: azurepurviewcatalog + - name: azure-purview-account + safeName: azurepurviewaccount diff --git a/shared_requirements.txt b/shared_requirements.txt index 11da8a8a9fa8..e2ae8089f81a 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -278,6 +278,8 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-mgmt-resourcegraph msrest>=0.6.21 #override azure-purview-scanning azure-core<2.0.0,>=1.8.2 #override azure-purview-scanning msrest>=0.6.21 +#override azure-purview-account msrest>=0.6.21 +#override azure-purview-account azure-core<2.0.0,>=1.16.0 #override azure-mgmt-rdbms msrest>=0.6.21 #override azure-mgmt-peering msrest>=0.6.21 #override azure-mgmt-elastic msrest>=0.6.21