diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml index 3ed0535fbee3..12c0a65b3bcb 100644 --- a/eng/.docsettings.yml +++ b/eng/.docsettings.yml @@ -94,6 +94,7 @@ known_content_issues: - ['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/purview/azure-purview-administration/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 4f2b35c5b718..738f38d8ea59 100644 --- a/eng/tox/allowed_pylint_failures.py +++ b/eng/tox/allowed_pylint_failures.py @@ -55,6 +55,7 @@ "azure-purview-scanning", "azure-purview-catalog", "azure-purview-account", + "azure-purview-administration", "azure-messaging-nspkg", "azure-agrifood-farming", "azure-eventhub", diff --git a/sdk/purview/azure-purview-administration/CHANGELOG.md b/sdk/purview/azure-purview-administration/CHANGELOG.md new file mode 100644 index 000000000000..e6d0ecd00b49 --- /dev/null +++ b/sdk/purview/azure-purview-administration/CHANGELOG.md @@ -0,0 +1,6 @@ +# Release History + +## 1.0.0b1 (2021-09-29) + +- This is the initial release of the Azure Purview Administration library. +- This package includes the operations of `azure-purview-account` that was previously released diff --git a/sdk/purview/azure-purview-administration/MANIFEST.in b/sdk/purview/azure-purview-administration/MANIFEST.in new file mode 100644 index 000000000000..c5a07332e6c6 --- /dev/null +++ b/sdk/purview/azure-purview-administration/MANIFEST.in @@ -0,0 +1,7 @@ +recursive-include tests *.py +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/purview/__init__.py +include azure/purview/administration/account/py.typed +include azure/purview/administration/metadatapolicies/py.typed \ No newline at end of file diff --git a/sdk/purview/azure-purview-administration/README.md b/sdk/purview/azure-purview-administration/README.md new file mode 100644 index 000000000000..d9a5530ee44c --- /dev/null +++ b/sdk/purview/azure-purview-administration/README.md @@ -0,0 +1,178 @@ +# Azure Purview Administration client library for Python + +Azure Purview is a fully managed cloud service. + +**Please rely heavily on the [service's documentation][account_product_documentation] to use this library** + +[Source code][source_code] | [Package (PyPI)][account_pypi] | [API reference documentation][account_ref_docs]| [Product documentation][account_product_documentation] + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +## Getting started + +### Prerequisites + +- Python 2.7, or 3.6 or later is required to use this package. +- You must have an [Azure subscription][azure_subscription] and a [Purview][purview_resource] to use this package. + +#### Create a Purview Resource + +Follow [these][purview_resource] instructions to create your Purview resource + +### Install the package + +Install the Azure Purview Account client library for Python with [pip][pip]: + +```bash +pip install azure-purview-administration +``` + +### Authenticate the client + +To use an [Azure Active Directory (AAD) token credential][authenticate_with_token], +provide an instance of the desired credential type obtained from the +[azure-identity][azure_identity_credentials] library. + +To authenticate with AAD, you must first [pip][pip] install [`azure-identity`][azure_identity_pip] and +[enable AAD authentication on your Purview resource][enable_aad] + +After setup, you can choose which type of [credential][azure_identity_credentials] from azure.identity to use. +As an example, [DefaultAzureCredential][default_azure_credential] +can be used to authenticate the client: + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: +AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET + +Use the returned token credential to authenticate the client: + +```python +from azure.purview.administration.account import PurviewAccountClient +from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +endpoint = "https://.purview.azure.com" +account_client = PurviewAccountClient(endpoint=endpoint, credential=credential) +metadatapolicy_client = PurviewMetadataPoliciesClient(endpoint=endpoint, credential=credential) +``` + +## Key concepts + +### Client + +The package contains two kinds of client: `PurviewAccountClient` and `PurviewMetadataPoliciesClient`. You could use them +with one package according to your requirements. + +## Examples + +The following section shows you how to initialize and authenticate your client, then list all of your keys. + +- [Get Keys](#get-keys "Get All Keys") + +### Get Keys + +```python +from azure.purview.administration.account import PurviewAccountClient +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +client = PurviewAccountClient(endpoint="https://.purview.azure.com", credential=credential) +response = client.accounts.get_access_keys() +print(response) +``` + +The following section shows you how to initialize and authenticate your client, then list all of your roles. + +- [List_Roles](#list-roles "List Roles") + +### List Roles + +```python +from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +client = PurviewMetadataPoliciesClient(endpoint="https://.purview.azure.com", credential=credential) +response = client.metadata_roles.list() +result = [item for item in response] +print(result) +``` + +## Troubleshooting + +### General + +The Purview client will raise exceptions if status code of your responses is not defined. + +### Logging + +This library uses the standard +[logging][python_logging] library for logging. +Basic information about HTTP sessions (URLs, headers, etc.) is logged at INFO +level. + +Detailed DEBUG level logging, including request/response bodies and unredacted +headers, can be enabled on a client with the `logging_enable` keyword argument: + +```python +import sys +import logging +from azure.identity import DefaultAzureCredential +from azure.purview.administration.account import PurviewAccountClient + +# Create a logger for the 'azure' SDK +logger = logging.getLogger('azure') +logger.setLevel(logging.DEBUG) + +# Configure a console output +handler = logging.StreamHandler(stream=sys.stdout) +logger.addHandler(handler) + +endpoint = "https://.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 +[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 +[request_builders_and_client]: https://aka.ms/azsdk/python/protocol/quickstart diff --git a/sdk/purview/azure-purview-administration/azure/__init__.py b/sdk/purview/azure-purview-administration/azure/__init__.py new file mode 100644 index 000000000000..5960c353a898 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/azure/purview/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/__init__.py new file mode 100644 index 000000000000..5960c353a898 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/azure/purview/administration/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/__init__.py new file mode 100644 index 000000000000..5960c353a898 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/__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-administration/azure/purview/administration/_version.py b/sdk/purview/azure-purview-administration/azure/purview/administration/_version.py new file mode 100644 index 000000000000..ab32f7856eb1 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/_version.py @@ -0,0 +1,8 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/account/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/__init__.py new file mode 100644 index 000000000000..d5c53ba7d43e --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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-administration/azure/purview/administration/account/_configuration.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/_configuration.py new file mode 100644 index 000000000000..09e0ba82e54d --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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-administration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/account/_purview_account_client.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/_purview_account_client.py new file mode 100644 index 000000000000..a5520853c3e6 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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.administration.account.operations.AccountsOperations + :ivar collections: CollectionsOperations operations + :vartype collections: azure.purview.administration.account.operations.CollectionsOperations + :ivar resource_set_rules: ResourceSetRulesOperations operations + :vartype resource_set_rules: + azure.purview.administration.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. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :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-administration/azure/purview/administration/account/_vendor.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/account/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/account/_version.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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-administration/azure/purview/administration/account/aio/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/__init__.py new file mode 100644 index 000000000000..1e668f62d8c2 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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-administration/azure/purview/administration/account/aio/_configuration.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/_configuration.py new file mode 100644 index 000000000000..b24a81bfaa07 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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-administration/{}'.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-administration/azure/purview/administration/account/aio/_purview_account_client.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/_purview_account_client.py new file mode 100644 index 000000000000..612425f842a5 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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.administration.account.aio.operations.AccountsOperations + :ivar collections: CollectionsOperations operations + :vartype collections: azure.purview.administration.account.aio.operations.CollectionsOperations + :ivar resource_set_rules: ResourceSetRulesOperations operations + :vartype resource_set_rules: + azure.purview.administration.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. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :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-administration/azure/purview/administration/account/aio/operations/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/operations/__init__.py new file mode 100644 index 000000000000..ae7fd0373d9b --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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 ._operations import AccountsOperations +from ._operations import CollectionsOperations +from ._operations import ResourceSetRulesOperations + +__all__ = [ + 'AccountsOperations', + 'CollectionsOperations', + 'ResourceSetRulesOperations', +] diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/operations/_operations.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/operations/_operations.py new file mode 100644 index 000000000000..0e8eb5c31a36 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/account/aio/operations/_operations.py @@ -0,0 +1,1674 @@ +# 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 ..._vendor import _convert_request +from ...operations._operations import build_accounts_get_access_keys_request, build_accounts_get_account_properties_request, build_accounts_regenerate_access_key_request, build_accounts_update_account_properties_request, build_collections_create_or_update_collection_request, build_collections_delete_collection_request, build_collections_get_collection_path_request, build_collections_get_collection_request, build_collections_list_child_collection_names_request, build_collections_list_collections_request, build_resource_set_rules_create_or_update_resource_set_rule_request, build_resource_set_rules_delete_resource_set_rule_request, build_resource_set_rules_get_resource_set_rule_request, build_resource_set_rules_list_resource_set_rules_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. Gets or sets the identifier. + "identity": { + "principalId": "str", # Optional. Service principal object Id. + "tenantId": "str", # Optional. Tenant Id. + "type": "SystemAssigned" # Optional. Default value is "SystemAssigned". Identity Type. Possible values include: "SystemAssigned". + }, + "location": "str", # Optional. Gets or sets the location. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "cloudConnectors": { + "awsExternalId": "str" # Optional. AWS external identifier."nConfigured in AWS to allow use of the role arn used for scanning. + }, + "createdAt": "2020-02-20 00:00:00", # Optional. Gets the time at which the entity was created. + "createdBy": "str", # Optional. Gets the creator of the entity. + "createdByObjectId": "str", # Optional. Gets the creators of the entity's object id. + "endpoints": { + "catalog": "str", # Optional. Gets the catalog endpoint. + "guardian": "str", # Optional. Gets the guardian endpoint. + "scan": "str" # Optional. Gets the scan endpoint. + }, + "friendlyName": "str", # Optional. Gets or sets the friendly name. + "managedResourceGroupName": "str", # Optional. Gets or sets the managed resource group name. + "managedResources": { + "eventHubNamespace": "str", # Optional. Gets the managed event hub namespace resource identifier. + "resourceGroup": "str", # Optional. Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + "storageAccount": "str" # Optional. Gets the managed storage account resource identifier. + }, + "privateEndpointConnections": [ + { + "id": "str", # Optional. Gets or sets the identifier. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "privateEndpoint": { + "id": "str" # Optional. The private endpoint identifier. + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", # Optional. The required actions. + "description": "str", # Optional. The description. + "status": "str" # Optional. The status. Possible values include: "Unknown", "Pending", "Approved", "Rejected", "Disconnected". + }, + "provisioningState": "str" # Optional. The provisioning state. + }, + "type": "str" # Optional. Gets or sets the type. + } + ], + "provisioningState": "str", # Optional. Gets or sets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", "Succeeded", "Canceled". + "publicNetworkAccess": "Enabled" # Optional. Default value is "Enabled". Gets or sets the public network access. Possible values include: "NotSpecified", "Enabled", "Disabled". Default value: "Enabled". + }, + "sku": { + "capacity": 0, # Optional. Gets or sets the sku capacity. Possible values include: 4, 16. + "name": "Standard" # Optional. Default value is "Standard". Gets or sets the sku name. Possible values include: "Standard". + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + }, + "tags": { + "str": "str" # Optional. A set of tags. Tags on the azure resource. + }, + "type": "str" # Optional. Gets or sets the type. + } + """ + 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_accounts_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. The friendly name for the azure resource. + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. Gets or sets the identifier. + "identity": { + "principalId": "str", # Optional. Service principal object Id. + "tenantId": "str", # Optional. Tenant Id. + "type": "SystemAssigned" # Optional. Default value is "SystemAssigned". Identity Type. Possible values include: "SystemAssigned". + }, + "location": "str", # Optional. Gets or sets the location. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "cloudConnectors": { + "awsExternalId": "str" # Optional. AWS external identifier."nConfigured in AWS to allow use of the role arn used for scanning. + }, + "createdAt": "2020-02-20 00:00:00", # Optional. Gets the time at which the entity was created. + "createdBy": "str", # Optional. Gets the creator of the entity. + "createdByObjectId": "str", # Optional. Gets the creators of the entity's object id. + "endpoints": { + "catalog": "str", # Optional. Gets the catalog endpoint. + "guardian": "str", # Optional. Gets the guardian endpoint. + "scan": "str" # Optional. Gets the scan endpoint. + }, + "friendlyName": "str", # Optional. Gets or sets the friendly name. + "managedResourceGroupName": "str", # Optional. Gets or sets the managed resource group name. + "managedResources": { + "eventHubNamespace": "str", # Optional. Gets the managed event hub namespace resource identifier. + "resourceGroup": "str", # Optional. Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + "storageAccount": "str" # Optional. Gets the managed storage account resource identifier. + }, + "privateEndpointConnections": [ + { + "id": "str", # Optional. Gets or sets the identifier. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "privateEndpoint": { + "id": "str" # Optional. The private endpoint identifier. + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", # Optional. The required actions. + "description": "str", # Optional. The description. + "status": "str" # Optional. The status. Possible values include: "Unknown", "Pending", "Approved", "Rejected", "Disconnected". + }, + "provisioningState": "str" # Optional. The provisioning state. + }, + "type": "str" # Optional. Gets or sets the type. + } + ], + "provisioningState": "str", # Optional. Gets or sets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", "Succeeded", "Canceled". + "publicNetworkAccess": "Enabled" # Optional. Default value is "Enabled". Gets or sets the public network access. Possible values include: "NotSpecified", "Enabled", "Disabled". Default value: "Enabled". + }, + "sku": { + "capacity": 0, # Optional. Gets or sets the sku capacity. Possible values include: 4, 16. + "name": "Standard" # Optional. Default value is "Standard". Gets or sets the sku name. Possible values include: "Standard". + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + }, + "tags": { + "str": "str" # Optional. A set of tags. Tags on the azure resource. + }, + "type": "str" # Optional. Gets or sets the type. + } + """ + 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_accounts_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. Gets or sets the primary connection string. + "atlasKafkaSecondaryEndpoint": "str" # Optional. Gets or sets the secondary connection string. + } + """ + 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_accounts_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. The access key type. Possible values include: "PrimaryAtlasKafkaKey", "SecondaryAtlasKafkaKey". + } + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str", # Optional. Gets or sets the primary connection string. + "atlasKafkaSecondaryEndpoint": "str" # Optional. Gets or sets the secondary connection string. + } + """ + 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_accounts_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 + +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. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + """ + 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_collections_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. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str", # Optional. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + """ + 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_collections_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_collections_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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "collectionProvisioningState": "str", # Optional. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + ] + } + """ + 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_collections_list_collections_request( + skip_token=skip_token, + template_url=self.list_collections.metadata['url'], + ) + request = _convert_request(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_collections_list_collections_request( + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str" # Optional. Gets the name. + } + ] + } + """ + 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_collections_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=self.list_child_collection_names.metadata['url'], + ) + request = _convert_request(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_collections_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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. The friendly names of ancestors starting from the default (root) collection and ending with the immediate parent. + ], + "parentNameChain": [ + "str" # Optional. The names of ancestors starting from the default (root) collection and ending with the immediate parent. + ] + } + """ + 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_collections_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 + +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": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + """ + 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_resource_set_rules_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": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + """ + 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_resource_set_rules_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_resource_set_rules_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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "advancedResourceSet": { + "modifiedAt": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + ] + } + """ + 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_resource_set_rules_list_resource_set_rules_request( + skip_token=skip_token, + template_url=self.list_resource_set_rules.metadata['url'], + ) + request = _convert_request(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_resource_set_rules_list_resource_set_rules_request( + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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-administration/azure/purview/administration/account/operations/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/operations/__init__.py new file mode 100644 index 000000000000..ae7fd0373d9b --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/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 ._operations import AccountsOperations +from ._operations import CollectionsOperations +from ._operations import ResourceSetRulesOperations + +__all__ = [ + 'AccountsOperations', + 'CollectionsOperations', + 'ResourceSetRulesOperations', +] diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/account/operations/_operations.py b/sdk/purview/azure-purview-administration/azure/purview/administration/account/operations/_operations.py new file mode 100644 index 000000000000..9a08329942ea --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/account/operations/_operations.py @@ -0,0 +1,2116 @@ +# 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 + +from .._vendor import _convert_request, _format_url_section + +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_accounts_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_accounts_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_accounts_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_accounts_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 + ) + + +def build_collections_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_collections_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_collections_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_collections_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_collections_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_collections_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 + ) + + +def build_resource_set_rules_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_resource_set_rules_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_resource_set_rules_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_resource_set_rules_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 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. Gets or sets the identifier. + "identity": { + "principalId": "str", # Optional. Service principal object Id. + "tenantId": "str", # Optional. Tenant Id. + "type": "SystemAssigned" # Optional. Default value is "SystemAssigned". Identity Type. Possible values include: "SystemAssigned". + }, + "location": "str", # Optional. Gets or sets the location. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "cloudConnectors": { + "awsExternalId": "str" # Optional. AWS external identifier."nConfigured in AWS to allow use of the role arn used for scanning. + }, + "createdAt": "2020-02-20 00:00:00", # Optional. Gets the time at which the entity was created. + "createdBy": "str", # Optional. Gets the creator of the entity. + "createdByObjectId": "str", # Optional. Gets the creators of the entity's object id. + "endpoints": { + "catalog": "str", # Optional. Gets the catalog endpoint. + "guardian": "str", # Optional. Gets the guardian endpoint. + "scan": "str" # Optional. Gets the scan endpoint. + }, + "friendlyName": "str", # Optional. Gets or sets the friendly name. + "managedResourceGroupName": "str", # Optional. Gets or sets the managed resource group name. + "managedResources": { + "eventHubNamespace": "str", # Optional. Gets the managed event hub namespace resource identifier. + "resourceGroup": "str", # Optional. Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + "storageAccount": "str" # Optional. Gets the managed storage account resource identifier. + }, + "privateEndpointConnections": [ + { + "id": "str", # Optional. Gets or sets the identifier. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "privateEndpoint": { + "id": "str" # Optional. The private endpoint identifier. + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", # Optional. The required actions. + "description": "str", # Optional. The description. + "status": "str" # Optional. The status. Possible values include: "Unknown", "Pending", "Approved", "Rejected", "Disconnected". + }, + "provisioningState": "str" # Optional. The provisioning state. + }, + "type": "str" # Optional. Gets or sets the type. + } + ], + "provisioningState": "str", # Optional. Gets or sets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", "Succeeded", "Canceled". + "publicNetworkAccess": "Enabled" # Optional. Default value is "Enabled". Gets or sets the public network access. Possible values include: "NotSpecified", "Enabled", "Disabled". Default value: "Enabled". + }, + "sku": { + "capacity": 0, # Optional. Gets or sets the sku capacity. Possible values include: 4, 16. + "name": "Standard" # Optional. Default value is "Standard". Gets or sets the sku name. Possible values include: "Standard". + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + }, + "tags": { + "str": "str" # Optional. A set of tags. Tags on the azure resource. + }, + "type": "str" # Optional. Gets or sets the type. + } + """ + 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_accounts_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. The friendly name for the azure resource. + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. Gets or sets the identifier. + "identity": { + "principalId": "str", # Optional. Service principal object Id. + "tenantId": "str", # Optional. Tenant Id. + "type": "SystemAssigned" # Optional. Default value is "SystemAssigned". Identity Type. Possible values include: "SystemAssigned". + }, + "location": "str", # Optional. Gets or sets the location. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "cloudConnectors": { + "awsExternalId": "str" # Optional. AWS external identifier."nConfigured in AWS to allow use of the role arn used for scanning. + }, + "createdAt": "2020-02-20 00:00:00", # Optional. Gets the time at which the entity was created. + "createdBy": "str", # Optional. Gets the creator of the entity. + "createdByObjectId": "str", # Optional. Gets the creators of the entity's object id. + "endpoints": { + "catalog": "str", # Optional. Gets the catalog endpoint. + "guardian": "str", # Optional. Gets the guardian endpoint. + "scan": "str" # Optional. Gets the scan endpoint. + }, + "friendlyName": "str", # Optional. Gets or sets the friendly name. + "managedResourceGroupName": "str", # Optional. Gets or sets the managed resource group name. + "managedResources": { + "eventHubNamespace": "str", # Optional. Gets the managed event hub namespace resource identifier. + "resourceGroup": "str", # Optional. Gets the managed resource group resource identifier. This resource group will host resource dependencies for the account. + "storageAccount": "str" # Optional. Gets the managed storage account resource identifier. + }, + "privateEndpointConnections": [ + { + "id": "str", # Optional. Gets or sets the identifier. + "name": "str", # Optional. Gets or sets the name. + "properties": { + "privateEndpoint": { + "id": "str" # Optional. The private endpoint identifier. + }, + "privateLinkServiceConnectionState": { + "actionsRequired": "str", # Optional. The required actions. + "description": "str", # Optional. The description. + "status": "str" # Optional. The status. Possible values include: "Unknown", "Pending", "Approved", "Rejected", "Disconnected". + }, + "provisioningState": "str" # Optional. The provisioning state. + }, + "type": "str" # Optional. Gets or sets the type. + } + ], + "provisioningState": "str", # Optional. Gets or sets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "SoftDeleting", "SoftDeleted", "Failed", "Succeeded", "Canceled". + "publicNetworkAccess": "Enabled" # Optional. Default value is "Enabled". Gets or sets the public network access. Possible values include: "NotSpecified", "Enabled", "Disabled". Default value: "Enabled". + }, + "sku": { + "capacity": 0, # Optional. Gets or sets the sku capacity. Possible values include: 4, 16. + "name": "Standard" # Optional. Default value is "Standard". Gets or sets the sku name. Possible values include: "Standard". + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + }, + "tags": { + "str": "str" # Optional. A set of tags. Tags on the azure resource. + }, + "type": "str" # Optional. Gets or sets the type. + } + """ + 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_accounts_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. Gets or sets the primary connection string. + "atlasKafkaSecondaryEndpoint": "str" # Optional. Gets or sets the secondary connection string. + } + """ + 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_accounts_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. The access key type. Possible values include: "PrimaryAtlasKafkaKey", "SecondaryAtlasKafkaKey". + } + + # response body for status code(s): 200 + response.json() == { + "atlasKafkaPrimaryEndpoint": "str", # Optional. Gets or sets the primary connection string. + "atlasKafkaSecondaryEndpoint": "str" # Optional. Gets or sets the secondary connection string. + } + """ + 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_accounts_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 + +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. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + """ + 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_collections_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. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + + # response body for status code(s): 200 + response.json() == { + "collectionProvisioningState": "str", # Optional. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + """ + 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_collections_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_collections_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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "collectionProvisioningState": "str", # Optional. Gets the state of the provisioning. Possible values include: "Unknown", "Creating", "Moving", "Deleting", "Failed", "Succeeded". + "description": "str", # Optional. Gets or sets the description. + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str", # Optional. Gets the name. + "parentCollection": { + "referenceName": "str", # Optional. Gets or sets the reference name. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". Gets or sets the reference type property. + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", # Optional. The timestamp of resource creation (UTC). + "createdBy": "str", # Optional. The identity that created the resource. + "createdByType": "str", # Optional. The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. The timestamp of the last modification the resource (UTC). + "lastModifiedBy": "str", # Optional. The identity that last modified the resource. + "lastModifiedByType": "str" # Optional. The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". + } + } + ] + } + """ + 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_collections_list_collections_request( + skip_token=skip_token, + template_url=self.list_collections.metadata['url'], + ) + request = _convert_request(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_collections_list_collections_request( + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "friendlyName": "str", # Optional. Gets or sets the friendly name of the collection. + "name": "str" # Optional. Gets the name. + } + ] + } + """ + 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_collections_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=self.list_child_collection_names.metadata['url'], + ) + request = _convert_request(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_collections_list_child_collection_names_request( + collection_name=collection_name, + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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. The friendly names of ancestors starting from the default (root) collection and ending with the immediate parent. + ], + "parentNameChain": [ + "str" # Optional. The names of ancestors starting from the default (root) collection and ending with the immediate parent. + ] + } + """ + 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_collections_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 + +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": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + """ + 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_resource_set_rules_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": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + + # response body for status code(s): 200 + response.json() == { + "advancedResourceSet": { + "modifiedAt": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + """ + 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_resource_set_rules_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_resource_set_rules_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": 0.0, # Optional. Total item count. + "nextLink": "str", # Optional. The Url of next result page. + "value": [ + { + "advancedResourceSet": { + "modifiedAt": "2020-02-20 00:00:00", # Optional. Date at which ResourceSetProcessing property of the account is updated. + "resourceSetProcessing": "str" # Optional. The advanced resource property of the account. Possible values include: "Default", "Advanced". + }, + "name": "str", # Optional. The name of the rule. + "pathPatternConfig": { + "acceptedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "complexReplacers": [ + { + "createdBy": "str", # Optional. The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "str", # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "typeName": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "createdBy": "str", # Required. + "enableDefaultPatterns": bool, # Required. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "normalizationRules": [ + { + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Optional. The configuration rules for path pattern extraction. + "dynamicReplacement": bool, # Optional. The configuration rules for path pattern extraction. + "entityTypes": [ + "str" # Optional. The configuration rules for path pattern extraction. + ], + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str", # Optional. The configuration rules for path pattern extraction. + "version": 0.0 # Optional. The configuration rules for path pattern extraction. + } + ], + "regexReplacers": [ + { + "condition": "str", # Optional. The configuration rules for path pattern extraction. + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "description": "str", # Optional. The configuration rules for path pattern extraction. + "disableRecursiveReplacerApplication": bool, # Optional. The configuration rules for path pattern extraction. + "disabled": bool, # Required. + "doNotReplaceRegex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "regex": { + "maxDigits": 0, # Optional. The configuration rules for path pattern extraction. + "maxLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDashes": 0, # Optional. The configuration rules for path pattern extraction. + "minDigits": 0, # Optional. The configuration rules for path pattern extraction. + "minDigitsOrLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minDots": 0, # Optional. The configuration rules for path pattern extraction. + "minHex": 0, # Optional. The configuration rules for path pattern extraction. + "minLetters": 0, # Optional. The configuration rules for path pattern extraction. + "minUnderscores": 0, # Optional. The configuration rules for path pattern extraction. + "options": 0, # Optional. The configuration rules for path pattern extraction. + "regexStr": "str" # Optional. The configuration rules for path pattern extraction. + }, + "replaceWith": "str" # Optional. The configuration rules for path pattern extraction. + } + ], + "rejectedPatterns": [ + { + "createdBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "filterType": "Pattern", # Optional. Default value is "Pattern". Possible values include: "Pattern", "Regex". Default value: "Pattern". + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "modifiedBy": "AzureDataCatalog", # Optional. Default value is "AzureDataCatalog". The configuration rules for path pattern extraction. + "name": "str", # Required. + "path": "str" # Required. + } + ], + "scopedRules": [ + { + "bindingUrl": "str", # Required. + "rules": [ + { + "displayName": "str", # Optional. The configuration rules for path pattern extraction. + "isResourceSet": True, # Optional. Default value is True. The configuration rules for path pattern extraction. + "lastUpdatedTimestamp": 0.0, # Optional. The configuration rules for path pattern extraction. + "name": "str", # Optional. The configuration rules for path pattern extraction. + "qualifiedName": "str" # Required. + } + ], + "storeType": "str" # Required. + } + ], + "version": 0 # Optional. The configuration rules for path pattern extraction. + } + } + ] + } + """ + 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_resource_set_rules_list_resource_set_rules_request( + skip_token=skip_token, + template_url=self.list_resource_set_rules.metadata['url'], + ) + request = _convert_request(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_resource_set_rules_list_resource_set_rules_request( + skip_token=skip_token, + template_url=next_link, + ) + request = _convert_request(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-administration/azure/purview/administration/account/py.typed b/sdk/purview/azure-purview-administration/azure/purview/administration/account/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/account/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/__init__.py new file mode 100644 index 000000000000..354f986dae6d --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/__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_metadata_policies_client import PurviewMetadataPoliciesClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['PurviewMetadataPoliciesClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_configuration.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_configuration.py new file mode 100644 index 000000000000..4e9cf8fe48ec --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_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 PurviewMetadataPoliciesClientConfiguration(Configuration): + """Configuration for PurviewMetadataPoliciesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The endpoint of your Purview account. Example: https://{accountName}.purview.azure.com. + :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(PurviewMetadataPoliciesClientConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.credential = credential + self.api_version = "2021-07-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default']) + kwargs.setdefault('sdk_moniker', 'purview-administration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_purview_metadata_policies_client.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_purview_metadata_policies_client.py new file mode 100644 index 000000000000..c6d5dff382dd --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_purview_metadata_policies_client.py @@ -0,0 +1,101 @@ +# 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 PurviewMetadataPoliciesClientConfiguration +from .operations import MetadataPolicyOperations, MetadataRolesOperations + +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 PurviewMetadataPoliciesClient(object): + """PurviewMetadataPoliciesClient. + + :ivar metadata_roles: MetadataRolesOperations operations + :vartype metadata_roles: + azure.purview.administration.metadatapolicies.operations.MetadataRolesOperations + :ivar metadata_policy: MetadataPolicyOperations operations + :vartype metadata_policy: + azure.purview.administration.metadatapolicies.operations.MetadataPolicyOperations + :param endpoint: The endpoint of your Purview account. Example: + https://{accountName}.purview.azure.com. + :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}/policyStore' + self._config = PurviewMetadataPoliciesClientConfiguration(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.metadata_roles = MetadataRolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metadata_policy = MetadataPolicyOperations(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. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :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: () -> PurviewMetadataPoliciesClient + 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-administration/azure/purview/administration/metadatapolicies/_vendor.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_version.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/_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-administration/azure/purview/administration/metadatapolicies/aio/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/__init__.py new file mode 100644 index 000000000000..3afd8b91b730 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/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_metadata_policies_client import PurviewMetadataPoliciesClient +__all__ = ['PurviewMetadataPoliciesClient'] diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/_configuration.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/_configuration.py new file mode 100644 index 000000000000..c1de758cd465 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/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 PurviewMetadataPoliciesClientConfiguration(Configuration): + """Configuration for PurviewMetadataPoliciesClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param endpoint: The endpoint of your Purview account. Example: https://{accountName}.purview.azure.com. + :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(PurviewMetadataPoliciesClientConfiguration, self).__init__(**kwargs) + + self.endpoint = endpoint + self.credential = credential + self.api_version = "2021-07-01-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default']) + kwargs.setdefault('sdk_moniker', 'purview-administration/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: 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-administration/azure/purview/administration/metadatapolicies/aio/_purview_metadata_policies_client.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/_purview_metadata_policies_client.py new file mode 100644 index 000000000000..ff807921b6a8 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/_purview_metadata_policies_client.py @@ -0,0 +1,96 @@ +# 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 PurviewMetadataPoliciesClientConfiguration +from .operations import MetadataPolicyOperations, MetadataRolesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + +class PurviewMetadataPoliciesClient: + """PurviewMetadataPoliciesClient. + + :ivar metadata_roles: MetadataRolesOperations operations + :vartype metadata_roles: + azure.purview.administration.metadatapolicies.aio.operations.MetadataRolesOperations + :ivar metadata_policy: MetadataPolicyOperations operations + :vartype metadata_policy: + azure.purview.administration.metadatapolicies.aio.operations.MetadataPolicyOperations + :param endpoint: The endpoint of your Purview account. Example: + https://{accountName}.purview.azure.com. + :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}/policyStore' + self._config = PurviewMetadataPoliciesClientConfiguration(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.metadata_roles = MetadataRolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metadata_policy = MetadataPolicyOperations(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. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client.send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :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) -> "PurviewMetadataPoliciesClient": + 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-administration/azure/purview/administration/metadatapolicies/aio/operations/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/operations/__init__.py new file mode 100644 index 000000000000..2e16550e3e30 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/operations/__init__.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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import MetadataRolesOperations +from ._operations import MetadataPolicyOperations + +__all__ = [ + 'MetadataRolesOperations', + 'MetadataPolicyOperations', +] diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/operations/_operations.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/operations/_operations.py new file mode 100644 index 000000000000..dbeb3d8bff36 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/aio/operations/_operations.py @@ -0,0 +1,616 @@ +# 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 ..._vendor import _convert_request +from ...operations._operations import build_metadata_policy_get_request, build_metadata_policy_list_all_request, build_metadata_policy_update_request, build_metadata_roles_list_request + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MetadataRolesOperations: + """MetadataRolesOperations 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 + def list( + self, + **kwargs: Any + ) -> AsyncIterable[Any]: + """Lists roles for Purview Account. + + :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() == { + "nextLink": "str", # Optional. + "values": [ + { + "id": "str", # Optional. The Id of role. + "name": "str", # Optional. The name of role. + "properties": { + "cnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "description": "str", # Optional. The description of role. + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "friendlyName": "str", # Optional. The friendly name of role. + "provisioningState": "str", # Optional. The provisioningState of role. + "roleType": "str", # Optional. The type of role. + "version": 0.0 # Optional. The version of role. + }, + "type": "str" # Optional. The type of role. + } + ] + } + """ + 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_metadata_roles_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(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_metadata_roles_list_request( + template_url=next_link, + ) + request = _convert_request(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["values"] + 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.metadata = {'url': '/metadataRoles'} # type: ignore +class MetadataPolicyOperations: + """MetadataPolicyOperations 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 + def list_all( + self, + *, + collection_name: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List or Get metadata policies. + + :keyword collection_name: The name of an existing collection for which one policy needs to be + fetched. + :paramtype collection_name: 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() == { + "nextLink": "str", # Optional. + "values": [ + { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + ] + } + """ + 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_metadata_policy_list_all_request( + collection_name=collection_name, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(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_metadata_policy_list_all_request( + collection_name=collection_name, + template_url=next_link, + ) + request = _convert_request(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["values"] + 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_all.metadata = {'url': '/metadataPolicies'} # type: ignore + + @distributed_trace_async + async def update( + self, + policy_id: str, + body: Any = None, + **kwargs: Any + ) -> Any: + """Updates a metadata policy. + + :param policy_id: Unique policy id. + :type policy_id: str + :param body: Policy to be updated. + :type body: 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. + body = { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + """ + 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] + + if body is not None: + json = body + else: + json = None + + request = build_metadata_policy_update_request( + policy_id=policy_id, + content_type=content_type, + json=json, + template_url=self.update.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.metadata = {'url': '/metadataPolicies/{policyId}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + policy_id: str, + **kwargs: Any + ) -> Any: + """Gets a metadata policy. + + :param policy_id: Id of an existing policy that needs to be fetched. + :type policy_id: str + :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. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + """ + 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_metadata_policy_get_request( + policy_id=policy_id, + template_url=self.get.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.metadata = {'url': '/metadataPolicies/{policyId}'} # type: ignore + diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/__init__.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/__init__.py new file mode 100644 index 000000000000..2e16550e3e30 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/__init__.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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import MetadataRolesOperations +from ._operations import MetadataPolicyOperations + +__all__ = [ + 'MetadataRolesOperations', + 'MetadataPolicyOperations', +] diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/_operations.py b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/_operations.py new file mode 100644 index 000000000000..2b11961f4278 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/operations/_operations.py @@ -0,0 +1,750 @@ +# 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 + +from .._vendor import _convert_request, _format_url_section + +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_metadata_roles_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/metadataRoles') + + # 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_metadata_policy_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + collection_name = kwargs.pop('collection_name', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/metadataPolicies') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if collection_name is not None: + query_parameters['collectionName'] = _SERIALIZER.query("collection_name", collection_name, 'str') + 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_metadata_policy_update_request( + policy_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/metadataPolicies/{policyId}') + path_format_arguments = { + "policyId": _SERIALIZER.url("policy_id", policy_id, '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_metadata_policy_get_request( + policy_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/metadataPolicies/{policyId}') + path_format_arguments = { + "policyId": _SERIALIZER.url("policy_id", policy_id, '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 MetadataRolesOperations(object): + """MetadataRolesOperations 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 list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """Lists roles for Purview Account. + + :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() == { + "nextLink": "str", # Optional. + "values": [ + { + "id": "str", # Optional. The Id of role. + "name": "str", # Optional. The name of role. + "properties": { + "cnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "description": "str", # Optional. The description of role. + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "friendlyName": "str", # Optional. The friendly name of role. + "provisioningState": "str", # Optional. The provisioningState of role. + "roleType": "str", # Optional. The type of role. + "version": 0.0 # Optional. The version of role. + }, + "type": "str" # Optional. The type of role. + } + ] + } + """ + 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_metadata_roles_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(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_metadata_roles_list_request( + template_url=next_link, + ) + request = _convert_request(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["values"] + 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.metadata = {'url': '/metadataRoles'} # type: ignore +class MetadataPolicyOperations(object): + """MetadataPolicyOperations 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 list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List or Get metadata policies. + + :keyword collection_name: The name of an existing collection for which one policy needs to be + fetched. + :paramtype collection_name: 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() == { + "nextLink": "str", # Optional. + "values": [ + { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + ] + } + """ + collection_name = kwargs.pop('collection_name', 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_metadata_policy_list_all_request( + collection_name=collection_name, + template_url=self.list_all.metadata['url'], + ) + request = _convert_request(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_metadata_policy_list_all_request( + collection_name=collection_name, + template_url=next_link, + ) + request = _convert_request(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["values"] + 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_all.metadata = {'url': '/metadataPolicies'} # type: ignore + + @distributed_trace + def update( + self, + policy_id, # type: str + body=None, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Updates a metadata policy. + + :param policy_id: Unique policy id. + :type policy_id: str + :param body: Policy to be updated. + :type body: 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. + body = { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + """ + 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] + + if body is not None: + json = body + else: + json = None + + request = build_metadata_policy_update_request( + policy_id=policy_id, + content_type=content_type, + json=json, + template_url=self.update.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.metadata = {'url': '/metadataPolicies/{policyId}'} # type: ignore + + + @distributed_trace + def get( + self, + policy_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Gets a metadata policy. + + :param policy_id: Id of an existing policy that needs to be fetched. + :type policy_id: str + :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. The id of policy. + "name": "str", # Optional. The name of policy. + "properties": { + "attributeRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "id": "str", # Optional. The id for rule. + "kind": "str", # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + "name": "str" # Optional. The name for rule. + } + ], + "collection": { + "referenceName": "str", # Optional. The name of reference. + "type": "CollectionReference" # Optional. Default value is "CollectionReference". The type of reference. + }, + "decisionRules": [ + { + "dnfCondition": [ + [ + { + "attributeName": "str", # Optional. AttributeName. + "attributeValueExcludedIn": [ + "str" # Optional. List of values excluded for attribute. + ], + "attributeValueExcludes": "str", # Optional. Value excluded for attribute. + "attributeValueIncludedIn": [ + "str" # Optional. List of values for attribute. + ], + "attributeValueIncludes": "str" # Optional. Value for attribute. + } + ] + ], + "effect": "str", # Optional. The effect for rule. Possible values include: "Deny", "Permit". + "kind": "str" # Optional. The kind of rule. Possible values include: "decisionrule", "attributerule". + } + ], + "description": "str", # Optional. The description of policy. + "parentCollectionName": "str" # Optional. The parent collection of the policy. + }, + "version": 0 # Optional. The version of policy. + } + """ + 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_metadata_policy_get_request( + policy_id=policy_id, + template_url=self.get.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.metadata = {'url': '/metadataPolicies/{policyId}'} # type: ignore + diff --git a/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/py.typed b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/purview/azure-purview-administration/azure/purview/administration/metadatapolicies/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/purview/azure-purview-administration/dev_requirements.txt b/sdk/purview/azure-purview-administration/dev_requirements.txt new file mode 100644 index 000000000000..45bdbbd581f4 --- /dev/null +++ b/sdk/purview/azure-purview-administration/dev_requirements.txt @@ -0,0 +1,5 @@ +-e ../../../tools/azure-sdk-tools +-e ../../../tools/azure-devtools +-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-administration/sdk_packaging.toml b/sdk/purview/azure-purview-administration/sdk_packaging.toml new file mode 100644 index 000000000000..58287ec51a84 --- /dev/null +++ b/sdk/purview/azure-purview-administration/sdk_packaging.toml @@ -0,0 +1,9 @@ +[packaging] +auto_update = false +package_name = "azure-purview-administration" +package_pprint_name = "Azure Purview Administration" +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-administration/setup.cfg b/sdk/purview/azure-purview-administration/setup.cfg new file mode 100644 index 000000000000..3480374bc2f2 --- /dev/null +++ b/sdk/purview/azure-purview-administration/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 \ No newline at end of file diff --git a/sdk/purview/azure-purview-administration/setup.py b/sdk/purview/azure-purview-administration/setup.py new file mode 100644 index 000000000000..1869a553dad6 --- /dev/null +++ b/sdk/purview/azure-purview-administration/setup.py @@ -0,0 +1,90 @@ +#!/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-administration" +PACKAGE_PPRINT_NAME = "Azure Purview Administration" + +# 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', + 'Programming Language :: Python :: 3.10', + '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.18.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-administration/swagger/README.md b/sdk/purview/azure-purview-administration/swagger/README.md new file mode 100644 index 000000000000..0a2bb1f57cc8 --- /dev/null +++ b/sdk/purview/azure-purview-administration/swagger/README.md @@ -0,0 +1,68 @@ +# Azure Purview for Python + +> see https://aka.ms/autorest + +### Setup + +Install Autorest v3 + +```ps +npm install -g autorest +``` + +### Generation + +```ps +cd +autorest +``` + +### Settings + +``` yaml +license-header: MICROSOFT_MIT_NO_VERSION +package-name: azure-purview-administration +no-namespace-folders: true +package-version: 1.0.0b1 +version-tolerant: true +``` + +### Python multi-client + +Generate all API versions currently shipped for this package + +```yaml +batch: + - tag: package-account + - tag: package-metadatapolicies +``` + +### Tag: package-account + +These settings apply only when `--tag=package-account` is specified on the command line. +Please also specify `--python-sdks-folder=`. + +``` yaml $(tag) == 'package-account' +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/administration/account +namespace: azure.purview.administration.account +clear-output-folder: true +title: PurviewAccountClient +add-credential: true +credential-scopes: https://purview.azure.net/.default +``` + +### Tag: package-metadatapolicies + +These settings apply only when `--tag=package-metadatapolicies` is specified on the command line. +Please also specify `--python-sdks-folder=`. + +``` yaml $(tag) == 'package-metadatapolicies' +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/purview/data-plane/Azure.Analytics.Purview.MetadataPolicies/preview/2021-07-01-preview/purviewMetadataPolicy.json +output-folder: ../azure/purview/administration/metadatapolicies +namespace: azure.purview.administration.metadatapolicies +clear-output-folder: true +title: PurviewMetadataPoliciesClient +add-credential: true +credential-scopes: https://purview.azure.net/.default +``` \ No newline at end of file diff --git a/sdk/purview/azure-purview-administration/tests/_util.py b/sdk/purview/azure-purview-administration/tests/_util.py new file mode 100644 index 000000000000..2f45bd9149a5 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/tests/conftest.py b/sdk/purview/azure-purview-administration/tests/conftest.py new file mode 100644 index 000000000000..a6ab83f7f5f0 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/tests/recordings/test_smoke.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_basic_smoke_test.yaml new file mode 100644 index 000000000000..bfa40ee25d97 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/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: + - Fri, 08 Oct 2021 06:38:56 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-administration/tests/recordings/test_smoke.test_collections_list.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_collections_list.yaml new file mode 100644 index 000000000000..41b73d345ae4 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/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: + - Fri, 08 Oct 2021 06:38:59 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-administration/tests/recordings/test_smoke.test_meta_policy_smoke_test.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_meta_policy_smoke_test.yaml new file mode 100644 index 000000000000..d3a84569e73d --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_meta_policy_smoke_test.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-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataPolicies?api-version=2021-07-01-preview + response: + body: + string: '{"values":[{"name":"policy_purview-msyyc","id":"2b6db6a7-2955-43ed-8372-0982730e48ef","version":5,"properties":{"description":"","decisionRules":[{"kind":"decisionrule","effect":"Permit","dnfCondition":[[{"attributeName":"resource.purview.collection","attributeValueIncludes":"purview-msyyc"},{"fromRule":"permission:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"permission:purview-msyyc"}]]}],"attributeRules":[{"kind":"attributerule","id":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","name":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_collection-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","name":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_purview-reader","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-curator:purview-msyyc","name":"purviewmetadatarole_builtin_data-curator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_data-curator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","name":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_data-source-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator"}]]},{"kind":"attributerule","id":"permission:purview-msyyc","name":"permission:purview-msyyc","dnfCondition":[[{"fromRule":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_data-curator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc"}]]}],"collection":{"type":"CollectionReference","referenceName":"purview-msyyc"}}}]}' + headers: + api-supported-versions: + - 2021-07-01-preview, 2021-07-01 + content-length: + - '3530' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 Oct 2021 06:39:02 GMT + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_meta_roles_smoke_test.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_meta_roles_smoke_test.yaml new file mode 100644 index 000000000000..c98c4bcf1fe1 --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke.test_meta_roles_smoke_test.yaml @@ -0,0 +1,70 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-purview-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview + response: + body: + string: '{"values":[{"id":"purviewmetadatarole_builtin_data-curator","name":"data-curator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Data + Curator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/data/read","Microsoft.Purview/accounts/data/write","Microsoft.Purview/accounts/collection/read"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_data-source-administrator","name":"data-source-administrator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Data + Source Administrator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/scan/read","Microsoft.Purview/accounts/scan/write","Microsoft.Purview/accounts/collection/read"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_collection-administrator","name":"collection-administrator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Collection + Administrator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/collection/read","Microsoft.Purview/accounts/collection/write"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_purview-reader","name":"purview-reader","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Purview + Reader","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/data/read","Microsoft.Purview/accounts/collection/read"]}]],"version":1}}],"nextLink":"https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview&skipToken=%2BRID%3A~OCYSANC6p-wJCT0AAAAAAA%3D%3D%23RT%3A1%23TRC%3A5%23ISV%3A2%23IEO%3A65551%23QCF%3A4%23FPC%3AAgH09PQEAAmJBoA%3D"}' + headers: + api-supported-versions: + - 2021-01-01-preview, 2021-07-01-preview, 2021-07-01 + content-length: + - '1991' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 Oct 2021 06:39:04 GMT + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - azsdk-python-purview-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview&skipToken=%2BRID%3A~OCYSANC6p-wJCT0AAAAAAA%3D%3D%23RT%3A1%23TRC%3A5%23ISV%3A2%23IEO%3A65551%23QCF%3A4%23FPC%3AAgH09PQEAAmJBoA%3D + response: + body: + string: '{"values":[]}' + headers: + api-supported-versions: + - 2021-01-01-preview, 2021-07-01-preview, 2021-07-01 + content-length: + - '13' + content-type: + - application/json; charset=utf-8 + date: + - Fri, 08 Oct 2021 06:39:04 GMT + server: + - Kestrel + strict-transport-security: + - max-age=31536000; includeSubDomains + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml new file mode 100644 index 000000000000..97c696d6e5fa --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/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: Fri, 08 Oct 2021 06:40:01 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-administration/tests/recordings/test_smoke_async.test_collections_list.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_collections_list.yaml new file mode 100644 index 000000000000..2825da50c2b5 --- /dev/null +++ b/sdk/purview/azure-purview-administration/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-administration/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: Fri, 08 Oct 2021 06:40:03 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-administration/tests/recordings/test_smoke_async.test_metadata_policy_smoke_async.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_metadata_policy_smoke_async.yaml new file mode 100644 index 000000000000..0eeb2f64922f --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_metadata_policy_smoke_async.yaml @@ -0,0 +1,25 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-purview-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataPolicies?api-version=2021-07-01-preview + response: + body: + string: '{"values":[{"name":"policy_purview-msyyc","id":"2b6db6a7-2955-43ed-8372-0982730e48ef","version":5,"properties":{"description":"","decisionRules":[{"kind":"decisionrule","effect":"Permit","dnfCondition":[[{"attributeName":"resource.purview.collection","attributeValueIncludes":"purview-msyyc"},{"fromRule":"permission:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"permission:purview-msyyc"}]]}],"attributeRules":[{"kind":"attributerule","id":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","name":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_collection-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","name":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_purview-reader","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-curator:purview-msyyc","name":"purviewmetadatarole_builtin_data-curator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_data-curator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator"}]]},{"kind":"attributerule","id":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","name":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","dnfCondition":[[{"attributeName":"principal.microsoft.id","attributeValueIncludedIn":["3bd37d68-b234-4fcd-bc83-0fedb27ccf5c","a7a853f3-da55-40e9-a48a-e5a5717e8b98"]},{"fromRule":"purviewmetadatarole_builtin_data-source-administrator","attributeName":"derived.purview.role","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator"}]]},{"kind":"attributerule","id":"permission:purview-msyyc","name":"permission:purview-msyyc","dnfCondition":[[{"fromRule":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_collection-administrator:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_purview-reader:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_purview-reader:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_data-curator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-curator:purview-msyyc"}],[{"fromRule":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc","attributeName":"derived.purview.permission","attributeValueIncludes":"purviewmetadatarole_builtin_data-source-administrator:purview-msyyc"}]]}],"collection":{"type":"CollectionReference","referenceName":"purview-msyyc"}}}]}' + headers: + api-supported-versions: 2021-07-01-preview, 2021-07-01 + content-length: '3530' + content-type: application/json; charset=utf-8 + date: Fri, 08 Oct 2021 06:40:05 GMT + server: Kestrel + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://purview-msyyc.purview.azure.com/policyStore/metadataPolicies?api-version=2021-07-01-preview +version: 1 diff --git a/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_metadata_role_smoke_async.yaml b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_metadata_role_smoke_async.yaml new file mode 100644 index 000000000000..9c8a62645d42 --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/recordings/test_smoke_async.test_metadata_role_smoke_async.yaml @@ -0,0 +1,52 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-purview-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview + response: + body: + string: '{"values":[{"id":"purviewmetadatarole_builtin_data-curator","name":"data-curator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Data + Curator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/data/read","Microsoft.Purview/accounts/data/write","Microsoft.Purview/accounts/collection/read"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_data-source-administrator","name":"data-source-administrator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Data + Source Administrator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/scan/read","Microsoft.Purview/accounts/scan/write","Microsoft.Purview/accounts/collection/read"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_collection-administrator","name":"collection-administrator","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Collection + Administrator","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/collection/read","Microsoft.Purview/accounts/collection/write"]}]],"version":1}},{"id":"purviewmetadatarole_builtin_purview-reader","name":"purview-reader","type":"Microsoft.Purview/role","properties":{"provisioningState":"Provisioned","roleType":"BuiltIn","friendlyName":"Purview + Reader","cnfCondition":[[{"attributeName":"request.azure.dataAction","attributeValueIncludedIn":["Microsoft.Purview/accounts/data/read","Microsoft.Purview/accounts/collection/read"]}]],"version":1}}],"nextLink":"https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview&skipToken=%2BRID%3A~OCYSANC6p-wJCT0AAAAAAA%3D%3D%23RT%3A1%23TRC%3A5%23ISV%3A2%23IEO%3A65551%23QCF%3A4%23FPC%3AAgH09PQEAAmJBoA%3D"}' + headers: + api-supported-versions: 2021-01-01-preview, 2021-07-01-preview, 2021-07-01 + content-length: '1991' + content-type: application/json; charset=utf-8 + date: Fri, 08 Oct 2021 06:40:07 GMT + server: Kestrel + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://purview-msyyc.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview +- request: + body: null + headers: + Accept: + - application/json + User-Agent: + - azsdk-python-purview-administration/1.0.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://fake_account.account.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview&skipToken=%2BRID:~OCYSANC6p-wJCT0AAAAAAA%3D%3D%23RT:1%23TRC:5%23ISV:2%23IEO:65551%23QCF:4%23FPC:AgH09PQEAAmJBoA%3D + response: + body: + string: '{"values":[]}' + headers: + api-supported-versions: 2021-01-01-preview, 2021-07-01-preview, 2021-07-01 + content-length: '13' + content-type: application/json; charset=utf-8 + date: Fri, 08 Oct 2021 06:40:07 GMT + server: Kestrel + strict-transport-security: max-age=31536000; includeSubDomains + status: + code: 200 + message: OK + url: https://purview-msyyc.purview.azure.com/policyStore/metadataRoles?api-version=2021-07-01-preview&skipToken=%2BRID:~OCYSANC6p-wJCT0AAAAAAA%3D%3D%23RT:1%23TRC:5%23ISV:2%23IEO:65551%23QCF:4%23FPC:AgH09PQEAAmJBoA%3D +version: 1 diff --git a/sdk/purview/azure-purview-administration/tests/test_smoke.py b/sdk/purview/azure-purview-administration/tests/test_smoke.py new file mode 100644 index 000000000000..94c82de3b2b2 --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/test_smoke.py @@ -0,0 +1,45 @@ +# 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 testcase import PurviewMetaPolicyTest, PurviewMetaPolicyPowerShellPreparer +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']) + + +class PurviewMetaPolicySmokeTest(PurviewMetaPolicyTest): + + @PurviewMetaPolicyPowerShellPreparer() + def test_meta_policy_smoke_test(self, purviewmetapolicy_endpoint): + client = self.create_client(endpoint=purviewmetapolicy_endpoint) + response = client.metadata_policy.list_all() + result = [item for item in response] + assert len(result) >= 1 + + @PurviewMetaPolicyPowerShellPreparer() + def test_meta_roles_smoke_test(self, purviewmetapolicy_endpoint): + client = self.create_client(endpoint=purviewmetapolicy_endpoint) + response = client.metadata_roles.list() + result = [item for item in response] + assert len(result) >= 4 diff --git a/sdk/purview/azure-purview-administration/tests/test_smoke_async.py b/sdk/purview/azure-purview-administration/tests/test_smoke_async.py new file mode 100644 index 000000000000..2210174de70f --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/test_smoke_async.py @@ -0,0 +1,45 @@ +# 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, PurviewMetaPolicyPowerShellPreparer +from testcase_async import PurviewAccountTestAsync, PurviewMetaPolicyTestAsync +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']) + + +class PurviewMetaDataPolicySmokeTestAsync(PurviewMetaPolicyTestAsync): + + @PurviewMetaPolicyPowerShellPreparer() + async def test_metadata_policy_smoke_async(self, purviewmetapolicy_endpoint): + client = self.create_async_client(endpoint=purviewmetapolicy_endpoint) + response = client.metadata_policy.list_all() + result = [item async for item in response] + assert len(result) >= 1 + + @PurviewMetaPolicyPowerShellPreparer() + async def test_metadata_role_smoke_async(self, purviewmetapolicy_endpoint): + client = self.create_async_client(endpoint=purviewmetapolicy_endpoint) + response = client.metadata_roles.list() + result = [item async for item in response] + assert len(result) >= 4 diff --git a/sdk/purview/azure-purview-administration/tests/testcase.py b/sdk/purview/azure-purview-administration/tests/testcase.py new file mode 100644 index 000000000000..f725222b5c43 --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/testcase.py @@ -0,0 +1,50 @@ +# 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.administration.account import PurviewAccountClient +from azure.purview.administration.metadatapolicies import PurviewMetadataPoliciesClient + + +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" +) + + +class PurviewMetaPolicyTest(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(PurviewMetaPolicyTest, self).__init__(method_name, **kwargs) + + def create_client(self, endpoint): + credential = self.get_credential(PurviewMetadataPoliciesClient) + return self.create_client_from_credential( + PurviewMetadataPoliciesClient, + credential=credential, + endpoint=endpoint, + ) + + +PurviewMetaPolicyPowerShellPreparer = functools.partial( + PowerShellPreparer, + "purviewmetapolicy", + purviewmetapolicy_endpoint="https://fake_account.account.purview.azure.com" +) diff --git a/sdk/purview/azure-purview-administration/tests/testcase_async.py b/sdk/purview/azure-purview-administration/tests/testcase_async.py new file mode 100644 index 000000000000..6fbab7190e9a --- /dev/null +++ b/sdk/purview/azure-purview-administration/tests/testcase_async.py @@ -0,0 +1,35 @@ +# 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.administration.account.aio import PurviewAccountClient as AsyncPurviewAccountClient +from azure.purview.administration.metadatapolicies.aio import PurviewMetadataPoliciesClient as AsyncPurviewMetadataPoliciesClient + + +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, + ) + + +class PurviewMetaPolicyTestAsync(AzureTestCase): + def __init__(self, method_name, **kwargs): + super(PurviewMetaPolicyTestAsync, self).__init__(method_name, **kwargs) + + def create_async_client(self, endpoint): + credential = self.get_credential(AsyncPurviewMetadataPoliciesClient, is_async=True) + return self.create_client_from_credential( + AsyncPurviewMetadataPoliciesClient, + credential=credential, + endpoint=endpoint, + ) diff --git a/sdk/purview/ci.yml b/sdk/purview/ci.yml index ec7853234383..c647395dd3be 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-administration + safeName: azurepurviewadministration diff --git a/shared_requirements.txt b/shared_requirements.txt index 9d666731a98c..02b8312126e1 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -283,6 +283,8 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #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-purview-administration msrest>=0.6.21 +#override azure-purview-administration azure-core<2.0.0,>=1.18.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