From b0acdfba6984c680c10cb6aa0b73cd42cd91b4a4 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Thu, 30 Sep 2021 02:44:17 +0800 Subject: [PATCH] [purview scanning] new release by new LLC version (#20823) --- .../azure-purview-scanning/CHANGELOG.md | 12 + sdk/purview/azure-purview-scanning/README.md | 17 +- .../azure/purview/scanning/__init__.py | 2 +- .../_azure_purview_scanning_client.py | 104 - .../azure/purview/scanning/_configuration.py | 12 +- .../scanning/_purview_scanning_client.py | 120 + .../azure/purview/scanning/_vendor.py | 27 + .../azure/purview/scanning/_version.py | 2 +- .../azure/purview/scanning/aio/__init__.py | 2 +- .../aio/_azure_purview_scanning_client.py | 98 - .../purview/scanning/aio/_configuration.py | 12 +- .../scanning/aio/_purview_scanning_client.py | 118 + .../scanning/aio/operations/__init__.py | 29 + .../scanning/aio/operations/_operations.py | 3590 +++++++++++++ .../azure/purview/scanning/core/__init__.py | 0 .../purview/scanning/core/rest/__init__.py | 65 - .../azure/purview/scanning/core/rest/_rest.py | 597 -- .../purview/scanning/core/rest/_rest_py3.py | 706 --- .../purview/scanning/operations/__init__.py | 29 + .../scanning/operations/_operations.py | 4784 +++++++++++++++++ .../azure/purview/scanning/rest/__init__.py | 0 .../rest/classification_rules/__init__.py | 31 - .../classification_rules/_request_builders.py | 364 -- .../_request_builders_py3.py | 364 -- .../scanning/rest/data_sources/__init__.py | 25 - .../rest/data_sources/_request_builders.py | 377 -- .../data_sources/_request_builders_py3.py | 378 -- .../purview/scanning/rest/filters/__init__.py | 19 - .../rest/filters/_request_builders.py | 144 - .../rest/filters/_request_builders_py3.py | 147 - .../rest/key_vault_connections/__init__.py | 25 - .../_request_builders.py | 239 - .../_request_builders_py3.py | 240 - .../scanning/rest/scan_result/__init__.py | 22 - .../rest/scan_result/_request_builders.py | 231 - .../rest/scan_result/_request_builders_py3.py | 229 - .../scanning/rest/scan_rulesets/__init__.py | 25 - .../rest/scan_rulesets/_request_builders.py | 242 - .../scan_rulesets/_request_builders_py3.py | 243 - .../purview/scanning/rest/scans/__init__.py | 25 - .../scanning/rest/scans/_request_builders.py | 371 -- .../rest/scans/_request_builders_py3.py | 372 -- .../rest/system_scan_rulesets/__init__.py | 28 - .../system_scan_rulesets/_request_builders.py | 285 - .../_request_builders_py3.py | 283 - .../scanning/rest/triggers/__init__.py | 22 - .../rest/triggers/_request_builders.py | 200 - .../rest/triggers/_request_builders_py3.py | 198 - sdk/purview/azure-purview-scanning/setup.py | 2 +- .../azure-purview-scanning/swagger/README.md | 10 +- .../azure-purview-scanning/tests/_util.py | 19 + .../test_smoke.test_basic_smoke_test.yaml | 16 +- ...est_smoke_async.test_basic_smoke_test.yaml | 17 +- .../tests/test_smoke.py | 13 +- .../tests/test_smoke_async.py | 14 +- .../azure-purview-scanning/tests/testcase.py | 4 +- .../tests/testcase_async.py | 1 + shared_requirements.txt | 2 +- 58 files changed, 8794 insertions(+), 6759 deletions(-) delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/_purview_scanning_client.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/_vendor.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_azure_purview_scanning_client.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_purview_scanning_client.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/__init__.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/_operations.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/core/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest_py3.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/__init__.py create mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/_operations.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders_py3.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/__init__.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders.py delete mode 100644 sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders_py3.py create mode 100644 sdk/purview/azure-purview-scanning/tests/_util.py diff --git a/sdk/purview/azure-purview-scanning/CHANGELOG.md b/sdk/purview/azure-purview-scanning/CHANGELOG.md index c82d0937e6c7..87b5c044ebfe 100644 --- a/sdk/purview/azure-purview-scanning/CHANGELOG.md +++ b/sdk/purview/azure-purview-scanning/CHANGELOG.md @@ -1,5 +1,17 @@ # Release History +## 1.0.0b2 (2021-09-29) + +**Features** + + - Add convenience operations to client + +**Breaking changes** + + - Remove rest layer and request builders(detailed description is in `README.md`) + - The HttpRequest parameter to send_request has changed from `http_request` to `request` + - Ordering of endpoint and credential params have changed + ## 1.0.0b1 (2021-05-11) - This is the initial release of the Azure Purview Scanning library. diff --git a/sdk/purview/azure-purview-scanning/README.md b/sdk/purview/azure-purview-scanning/README.md index 3cb97f885da3..6e09e75dc30d 100644 --- a/sdk/purview/azure-purview-scanning/README.md +++ b/sdk/purview/azure-purview-scanning/README.md @@ -73,23 +73,14 @@ The following section shows you how to initialize and authenticate your client, ```python from azure.purview.scanning import PurviewScanningClient from azure.identity import DefaultAzureCredential -from azure.purview.scanning.rest import data_sources from azure.core.exceptions import HttpResponseError credential = DefaultAzureCredential() client = PurviewScanningClient(endpoint="https://.scan.purview.azure.com", credential=credential) - -request = data_sources.build_list_all_request() - -response = client.send_request(request) try: - response.raise_for_status() - json_response = response.json() - - assert len(json_response['value']) == json_response['count'] - for value in json_response['value']: - print(value) - + response = client.data_sources.list_all() + result = [item for item in response] + print(result) except HttpResponseError as e: print(e) ``` @@ -135,7 +126,7 @@ Similarly, `logging_enable` can enable detailed logging for a single `send_reque even when it isn't enabled for the client: ```python -result = client.send_request(request, logging_enable=True) +result = client.data_sources.list_all(logging_enable=True) ``` ## Next steps diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/__init__.py index 27c175f1ceb9..d19c0b8bd063 100644 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/__init__.py +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/__init__.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._azure_purview_scanning_client import PurviewScanningClient +from ._purview_scanning_client import PurviewScanningClient from ._version import VERSION __version__ = VERSION diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py deleted file mode 100644 index 6cd9c6bd6ec5..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py +++ /dev/null @@ -1,104 +0,0 @@ -# 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 azure.purview.scanning.core.rest import HttpResponse, _StreamContextManager -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Dict - - from azure.core.credentials import TokenCredential - from azure.purview.scanning.core.rest import HttpRequest - -from ._configuration import PurviewScanningClientConfiguration - - -class PurviewScanningClient(object): - """Creates a Microsoft.Scanning management client. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.purview.azure.com. - :type endpoint: str - """ - - def __init__( - self, - credential, # type: "TokenCredential" - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = '{Endpoint}' - self._config = PurviewScanningClientConfiguration(credential, endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - def send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - We have helper methods to create requests specific to this service in `azure.purview.scanning.rest`. - Use these helper methods to create the request you pass to this method. See our example below: - - >>> from azure.purview.scanning.rest import build_get_request - >>> request = build_get_request(key_vault_name) - - >>> response = client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart - - For advanced cases, you can also create your own :class:`~azure.purview.scanning.core.rest.HttpRequest` - and pass it in. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.purview.scanning.core.rest.HttpRequest - :keyword bool stream_response: 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.purview.scanning.core.rest.HttpResponse - """ - request_copy = deepcopy(http_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) - if kwargs.pop("stream_response", False): - return _StreamContextManager( - client=self._client._pipeline, - request=request_copy, - ) - pipeline_response = self._client._pipeline.run(request_copy._internal_request, **kwargs) - response = HttpResponse( - status_code=pipeline_response.http_response.status_code, - request=request_copy, - _internal_response=pipeline_response.http_response - ) - response.read() - return response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> PurviewScanningClient - 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-scanning/azure/purview/scanning/_configuration.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_configuration.py index cb58733b76f8..e38efe391ef1 100644 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/_configuration.py +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_configuration.py @@ -26,27 +26,27 @@ class PurviewScanningClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential :param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.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, - credential, # type: "TokenCredential" endpoint, # type: str + credential, # type: "TokenCredential" **kwargs # type: Any ): # type: (...) -> None - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") super(PurviewScanningClientConfiguration, self).__init__(**kwargs) - self.credential = credential self.endpoint = endpoint + self.credential = credential self.api_version = "2018-12-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default']) kwargs.setdefault('sdk_moniker', 'purview-scanning/{}'.format(VERSION)) diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/_purview_scanning_client.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_purview_scanning_client.py new file mode 100644 index 000000000000..87f7f40de987 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_purview_scanning_client.py @@ -0,0 +1,120 @@ +# 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 PurviewScanningClientConfiguration +from .operations import ClassificationRulesOperations, DataSourcesOperations, FiltersOperations, KeyVaultConnectionsOperations, ScanResultOperations, ScanRulesetsOperations, ScansOperations, SystemScanRulesetsOperations, TriggersOperations + +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 PurviewScanningClient(object): + """Creates a Microsoft.Scanning management client. + + :ivar key_vault_connections: KeyVaultConnectionsOperations operations + :vartype key_vault_connections: azure.purview.scanning.operations.KeyVaultConnectionsOperations + :ivar classification_rules: ClassificationRulesOperations operations + :vartype classification_rules: azure.purview.scanning.operations.ClassificationRulesOperations + :ivar data_sources: DataSourcesOperations operations + :vartype data_sources: azure.purview.scanning.operations.DataSourcesOperations + :ivar filters: FiltersOperations operations + :vartype filters: azure.purview.scanning.operations.FiltersOperations + :ivar scans: ScansOperations operations + :vartype scans: azure.purview.scanning.operations.ScansOperations + :ivar scan_result: ScanResultOperations operations + :vartype scan_result: azure.purview.scanning.operations.ScanResultOperations + :ivar scan_rulesets: ScanRulesetsOperations operations + :vartype scan_rulesets: azure.purview.scanning.operations.ScanRulesetsOperations + :ivar system_scan_rulesets: SystemScanRulesetsOperations operations + :vartype system_scan_rulesets: azure.purview.scanning.operations.SystemScanRulesetsOperations + :ivar triggers: TriggersOperations operations + :vartype triggers: azure.purview.scanning.operations.TriggersOperations + :param endpoint: The scanning endpoint of your purview account. Example: + https://{accountName}.scan.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}' + self._config = PurviewScanningClientConfiguration(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.key_vault_connections = KeyVaultConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classification_rules = ClassificationRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.filters = FiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.scans = ScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.scan_result = ScanResultOperations(self._client, self._config, self._serialize, self._deserialize) + self.scan_rulesets = ScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.system_scan_rulesets = SystemScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(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: () -> PurviewScanningClient + 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-scanning/azure/purview/scanning/_vendor.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_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-scanning/azure/purview/scanning/_version.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_version.py index e5754a47ce68..dfa6ee022f15 100644 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/_version.py +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/__init__.py index f158671c2959..05881913d621 100644 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/__init__.py +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/__init__.py @@ -6,5 +6,5 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._azure_purview_scanning_client import PurviewScanningClient +from ._purview_scanning_client import PurviewScanningClient __all__ = ['PurviewScanningClient'] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_azure_purview_scanning_client.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_azure_purview_scanning_client.py deleted file mode 100644 index de7220452f46..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_azure_purview_scanning_client.py +++ /dev/null @@ -1,98 +0,0 @@ -# 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, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.purview.scanning.core.rest import AsyncHttpResponse, HttpRequest, _AsyncStreamContextManager -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Dict - - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import PurviewScanningClientConfiguration - - -class PurviewScanningClient(object): - """Creates a Microsoft.Scanning management client. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.purview.azure.com. - :type endpoint: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - endpoint: str, - **kwargs: Any - ) -> None: - base_url = '{Endpoint}' - self._config = PurviewScanningClientConfiguration(credential, endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - self._serialize = Serializer() - self._deserialize = Deserializer() - self._serialize.client_side_validation = False - - async def send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - We have helper methods to create requests specific to this service in `azure.purview.scanning.rest`. - Use these helper methods to create the request you pass to this method. See our example below: - - >>> from azure.purview.scanning.rest import build_get_request - >>> request = build_get_request(key_vault_name) - - >>> response = await client.send_request(request) - - - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart - - For advanced cases, you can also create your own :class:`~azure.purview.scanning.core.rest.HttpRequest` - and pass it in. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.purview.scanning.core.rest.HttpRequest - :keyword bool stream_response: 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.purview.scanning.core.rest.AsyncHttpResponse - """ - request_copy = deepcopy(http_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) - if kwargs.pop("stream_response", False): - return _AsyncStreamContextManager( - client=self._client._pipeline, - request=request_copy, - ) - pipeline_response = await self._client._pipeline.run(request_copy._internal_request, **kwargs) - response = AsyncHttpResponse( - status_code=pipeline_response.http_response.status_code, - request=request_copy, - _internal_response=pipeline_response.http_response - ) - await response.read() - return response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "PurviewScanningClient": - 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-scanning/azure/purview/scanning/aio/_configuration.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_configuration.py index 4d6fb0afec06..72a4bac216fe 100644 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_configuration.py +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_configuration.py @@ -24,26 +24,26 @@ class PurviewScanningClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.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, - credential: "AsyncTokenCredential", endpoint: str, + credential: "AsyncTokenCredential", **kwargs: Any ) -> None: - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") super(PurviewScanningClientConfiguration, self).__init__(**kwargs) - self.credential = credential self.endpoint = endpoint + self.credential = credential self.api_version = "2018-12-01-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default']) kwargs.setdefault('sdk_moniker', 'purview-scanning/{}'.format(VERSION)) diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_purview_scanning_client.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_purview_scanning_client.py new file mode 100644 index 000000000000..3e8e7f3987a7 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_purview_scanning_client.py @@ -0,0 +1,118 @@ +# 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 PurviewScanningClientConfiguration +from .operations import ClassificationRulesOperations, DataSourcesOperations, FiltersOperations, KeyVaultConnectionsOperations, ScanResultOperations, ScanRulesetsOperations, ScansOperations, SystemScanRulesetsOperations, TriggersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Dict + + from azure.core.credentials_async import AsyncTokenCredential + +class PurviewScanningClient: + """Creates a Microsoft.Scanning management client. + + :ivar key_vault_connections: KeyVaultConnectionsOperations operations + :vartype key_vault_connections: + azure.purview.scanning.aio.operations.KeyVaultConnectionsOperations + :ivar classification_rules: ClassificationRulesOperations operations + :vartype classification_rules: + azure.purview.scanning.aio.operations.ClassificationRulesOperations + :ivar data_sources: DataSourcesOperations operations + :vartype data_sources: azure.purview.scanning.aio.operations.DataSourcesOperations + :ivar filters: FiltersOperations operations + :vartype filters: azure.purview.scanning.aio.operations.FiltersOperations + :ivar scans: ScansOperations operations + :vartype scans: azure.purview.scanning.aio.operations.ScansOperations + :ivar scan_result: ScanResultOperations operations + :vartype scan_result: azure.purview.scanning.aio.operations.ScanResultOperations + :ivar scan_rulesets: ScanRulesetsOperations operations + :vartype scan_rulesets: azure.purview.scanning.aio.operations.ScanRulesetsOperations + :ivar system_scan_rulesets: SystemScanRulesetsOperations operations + :vartype system_scan_rulesets: + azure.purview.scanning.aio.operations.SystemScanRulesetsOperations + :ivar triggers: TriggersOperations operations + :vartype triggers: azure.purview.scanning.aio.operations.TriggersOperations + :param endpoint: The scanning endpoint of your purview account. Example: + https://{accountName}.scan.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}' + self._config = PurviewScanningClientConfiguration(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.key_vault_connections = KeyVaultConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classification_rules = ClassificationRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.filters = FiltersOperations(self._client, self._config, self._serialize, self._deserialize) + self.scans = ScansOperations(self._client, self._config, self._serialize, self._deserialize) + self.scan_result = ScanResultOperations(self._client, self._config, self._serialize, self._deserialize) + self.scan_rulesets = ScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.system_scan_rulesets = SystemScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.triggers = TriggersOperations(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) -> "PurviewScanningClient": + 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-scanning/azure/purview/scanning/aio/operations/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/__init__.py new file mode 100644 index 000000000000..949a0417fbfd --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 KeyVaultConnectionsOperations +from ._operations import ClassificationRulesOperations +from ._operations import DataSourcesOperations +from ._operations import FiltersOperations +from ._operations import ScansOperations +from ._operations import ScanResultOperations +from ._operations import ScanRulesetsOperations +from ._operations import SystemScanRulesetsOperations +from ._operations import TriggersOperations + +__all__ = [ + 'KeyVaultConnectionsOperations', + 'ClassificationRulesOperations', + 'DataSourcesOperations', + 'FiltersOperations', + 'ScansOperations', + 'ScanResultOperations', + 'ScanRulesetsOperations', + 'SystemScanRulesetsOperations', + 'TriggersOperations', +] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/_operations.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/_operations.py new file mode 100644 index 000000000000..b716a34e9864 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/operations/_operations.py @@ -0,0 +1,3590 @@ +# 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, Union +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_classification_rules_create_or_update_request, build_classification_rules_delete_request, build_classification_rules_get_request, build_classification_rules_list_all_request, build_classification_rules_list_versions_by_classification_rule_name_request, build_classification_rules_tag_classification_version_request, build_data_sources_create_or_update_request, build_data_sources_delete_request, build_data_sources_get_request, build_data_sources_list_all_request, build_filters_create_or_update_request, build_filters_get_request, build_key_vault_connections_create_request, build_key_vault_connections_delete_request, build_key_vault_connections_get_request, build_key_vault_connections_list_all_request, build_scan_result_cancel_scan_request, build_scan_result_list_scan_history_request, build_scan_result_run_scan_request, build_scan_rulesets_create_or_update_request, build_scan_rulesets_delete_request, build_scan_rulesets_get_request, build_scan_rulesets_list_all_request, build_scans_create_or_update_request, build_scans_delete_request, build_scans_get_request, build_scans_list_by_data_source_request, build_system_scan_rulesets_get_by_version_request, build_system_scan_rulesets_get_latest_request, build_system_scan_rulesets_get_request, build_system_scan_rulesets_list_all_request, build_system_scan_rulesets_list_versions_by_data_source_request, build_triggers_create_trigger_request, build_triggers_delete_trigger_request, build_triggers_get_trigger_request + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class KeyVaultConnectionsOperations: + """KeyVaultConnectionsOperations 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( + self, + key_vault_name: str, + **kwargs: Any + ) -> Any: + """Gets key vault information. + + :param key_vault_name: + :type key_vault_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_key_vault_connections_get_request( + key_vault_name=key_vault_name, + 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': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace_async + async def create( + self, + key_vault_name: str, + body: Any, + **kwargs: Any + ) -> Any: + """Creates an instance of a key vault connection. + + :param key_vault_name: + :type key_vault_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = body + + request = build_key_vault_connections_create_request( + key_vault_name=key_vault_name, + content_type=content_type, + json=json, + template_url=self.create.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.metadata = {'url': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + key_vault_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes the key vault connection associated with the account. + + :param key_vault_name: + :type key_vault_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_key_vault_connections_delete_request( + key_vault_name=key_vault_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List key vault connections in 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_key_vault_connections_list_all_request( + 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_key_vault_connections_list_all_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["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_all.metadata = {'url': '/azureKeyVaults'} # type: ignore +class ClassificationRulesOperations: + """ClassificationRulesOperations 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( + self, + classification_rule_name: str, + **kwargs: Any + ) -> Any: + """Get a classification rule. + + :param classification_rule_name: + :type classification_rule_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + 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_classification_rules_get_request( + classification_rule_name=classification_rule_name, + 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': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + classification_rule_name: str, + body: Any = None, + **kwargs: Any + ) -> Any: + """Creates or Updates a classification rule. + + :param classification_rule_name: + :type classification_rule_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'CustomClassificationRule' or 'SystemClassificationRule' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + 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_classification_rules_create_or_update_request( + classification_rule_name=classification_rule_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + classification_rule_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes a classification rule. + + :param classification_rule_name: + :type classification_rule_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_classification_rules_delete_request( + classification_rule_name=classification_rule_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List classification rules in 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + ] + } + """ + 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_classification_rules_list_all_request( + 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_classification_rules_list_all_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["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_all.metadata = {'url': '/classificationrules'} # type: ignore + + @distributed_trace + def list_versions_by_classification_rule_name( + self, + classification_rule_name: str, + **kwargs: Any + ) -> AsyncIterable[Any]: + """Lists the rule versions of a classification rule. + + :param classification_rule_name: + :type classification_rule_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + ] + } + """ + 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_classification_rules_list_versions_by_classification_rule_name_request( + classification_rule_name=classification_rule_name, + template_url=self.list_versions_by_classification_rule_name.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_classification_rules_list_versions_by_classification_rule_name_request( + classification_rule_name=classification_rule_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["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_versions_by_classification_rule_name.metadata = {'url': '/classificationrules/{classificationRuleName}/versions'} # type: ignore + + @distributed_trace_async + async def tag_classification_version( + self, + classification_rule_name: str, + classification_rule_version: int, + *, + action: str, + **kwargs: Any + ) -> Any: + """Sets Classification Action on a specific classification rule version. + + :param classification_rule_name: + :type classification_rule_name: str + :param classification_rule_version: + :type classification_rule_version: int + :keyword action: Possible values are: "Keep" or "Delete". + :paramtype action: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + 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_classification_rules_tag_classification_version_request( + classification_rule_name=classification_rule_name, + classification_rule_version=classification_rule_version, + action=action, + template_url=self.tag_classification_version.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 [202]: + 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 + + tag_classification_version.metadata = {'url': '/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag'} # type: ignore + +class DataSourcesOperations: + """DataSourcesOperations 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 create_or_update( + self, + data_source_name: str, + body: Any = None, + **kwargs: Any + ) -> Any: + """Creates or Updates a data source. + + :param data_source_name: + :type data_source_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1DataSource' or 'AdlsGen2DataSource' or 'AmazonAccountDataSource' or 'AmazonPostgreSqlDataSource' or 'AmazonS3DataSource' or 'AmazonSqlDataSource' or 'AzureCosmosDbDataSource' or 'AzureDataExplorerDataSource' or 'AzureFileServiceDataSource' or 'AzureMySqlDataSource' or 'AzurePostgreSqlDataSource' or 'AzureResourceGroupDataSource' or 'AzureSqlDataWarehouseDataSource' or 'AzureSqlDatabaseDataSource' or 'AzureSqlDatabaseManagedInstanceDataSource' or 'AzureStorageDataSource' or 'AzureSubscriptionDataSource' or 'AzureSynapseDataSource' or 'AzureSynapseWorkspaceDataSource' or 'OracleDataSource' or 'PowerBIDataSource' or 'SapEccDataSource' or 'SapS4HanaDataSource' or 'SqlServerDatabaseDataSource' or 'TeradataDataSource' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + 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_data_sources_create_or_update_request( + data_source_name=data_source_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + data_source_name: str, + **kwargs: Any + ) -> Any: + """Get a data source. + + :param data_source_name: + :type data_source_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + 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_data_sources_get_request( + data_source_name=data_source_name, + 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': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + data_source_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes a data source. + + :param data_source_name: + :type data_source_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_data_sources_delete_request( + data_source_name=data_source_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List data sources in Data catalog. + + :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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + ] + } + """ + 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_data_sources_list_all_request( + 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_data_sources_list_all_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["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_all.metadata = {'url': '/datasources'} # type: ignore +class FiltersOperations: + """FiltersOperations 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( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> Any: + """Get a filter. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_filters_get_request( + data_source_name=data_source_name, + scan_name=scan_name, + 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': '/datasources/{dataSourceName}/scans/{scanName}/filters/custom'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + data_source_name: str, + scan_name: str, + body: Any = None, + **kwargs: Any + ) -> Any: + """Creates or updates a filter. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + json = body + else: + json = None + + request = build_filters_create_or_update_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/filters/custom'} # type: ignore + +class ScansOperations: + """ScansOperations 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 create_or_update( + self, + data_source_name: str, + scan_name: str, + body: Any, + **kwargs: Any + ) -> Any: + """Creates an instance of a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1CredentialScan' or 'AdlsGen1MsiScan' or 'AdlsGen2CredentialScan' or 'AdlsGen2MsiScan' or 'AmazonAccountCredentialScan' or 'AmazonPostgreSqlCredentialScan' or 'AmazonS3CredentialScan' or 'AmazonS3RoleARNScan' or 'AmazonSqlCredentialScan' or 'AzureCosmosDbCredentialScan' or 'AzureDataExplorerCredentialScan' or 'AzureDataExplorerMsiScan' or 'AzureFileServiceCredentialScan' or 'AzureMySqlCredentialScan' or 'AzurePostgreSqlCredentialScan' or 'AzureResourceGroupCredentialScan' or 'AzureResourceGroupMsiScan' or 'AzureSqlDataWarehouseCredentialScan' or 'AzureSqlDataWarehouseMsiScan' or 'AzureSqlDatabaseCredentialScan' or 'AzureSqlDatabaseManagedInstanceCredentialScan' or 'AzureSqlDatabaseManagedInstanceMsiScan' or 'AzureSqlDatabaseMsiScan' or 'AzureStorageCredentialScan' or 'AzureStorageMsiScan' or 'AzureSubscriptionCredentialScan' or 'AzureSubscriptionMsiScan' or 'AzureSynapseCredentialScan' or 'AzureSynapseMsiScan' or 'AzureSynapseWorkspaceCredentialScan' or 'AzureSynapseWorkspaceMsiScan' or 'OracleCredentialScan' or 'OracleUserPassScan' or 'PowerBIDelegatedScan' or 'PowerBIMsiScan' or 'SapEccCredentialScan' or 'SapEccUserPassScan' or 'SapS4HanaSapS4HanaCredentialScan' or 'SapS4HanaSapS4HanaUserPassScan' or 'SqlServerDatabaseCredentialScan' or 'TeradataCredentialScan' or 'TeradataUserPassScanAutoGenerated' or 'TeradataUserPassScan' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + 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 = body + + request = build_scans_create_or_update_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace_async + async def get( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> Any: + """Gets a scan information. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + 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_scans_get_request( + data_source_name=data_source_name, + scan_name=scan_name, + 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': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes the scan associated with the data source. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_scans_delete_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace + def list_by_data_source( + self, + data_source_name: str, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List scans in data source. + + :param data_source_name: + :type data_source_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ] + } + """ + 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_scans_list_by_data_source_request( + data_source_name=data_source_name, + template_url=self.list_by_data_source.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_scans_list_by_data_source_request( + data_source_name=data_source_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["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_by_data_source.metadata = {'url': '/datasources/{dataSourceName}/scans'} # type: ignore +class ScanResultOperations: + """ScanResultOperations 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 run_scan( + self, + data_source_name: str, + scan_name: str, + run_id: str, + *, + scan_level: Optional[str] = None, + **kwargs: Any + ) -> Any: + """Runs the scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param run_id: + :type run_id: str + :keyword scan_level: Possible values are: "Full" or "Incremental". + :paramtype scan_level: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + 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_scan_result_run_scan_request( + data_source_name=data_source_name, + scan_name=scan_name, + run_id=run_id, + scan_level=scan_level, + template_url=self.run_scan.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 [202]: + 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 + + run_scan.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}'} # type: ignore + + + @distributed_trace_async + async def cancel_scan( + self, + data_source_name: str, + scan_name: str, + run_id: str, + **kwargs: Any + ) -> Any: + """Cancels a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param run_id: + :type run_id: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + 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_scan_result_cancel_scan_request( + data_source_name=data_source_name, + scan_name=scan_name, + run_id=run_id, + template_url=self.cancel_scan.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 [202]: + 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 + + cancel_scan.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel'} # type: ignore + + + @distributed_trace + def list_scan_history( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> AsyncIterable[Any]: + """Lists the scan history of a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_scan_result_list_scan_history_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.list_scan_history.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_scan_result_list_scan_history_request( + data_source_name=data_source_name, + scan_name=scan_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["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_scan_history.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs'} # type: ignore +class ScanRulesetsOperations: + """ScanRulesetsOperations 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( + self, + scan_ruleset_name: str, + **kwargs: Any + ) -> Any: + """Get a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + 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_scan_rulesets_get_request( + scan_ruleset_name=scan_ruleset_name, + 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': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + scan_ruleset_name: str, + body: Any = None, + **kwargs: Any + ) -> Any: + """Creates or Updates a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1ScanRuleset' or 'AdlsGen2ScanRuleset' or 'AmazonAccountScanRuleset' or 'AmazonPostgreSqlScanRuleset' or 'AmazonS3ScanRuleset' or 'AmazonSqlScanRuleset' or 'AzureCosmosDbScanRuleset' or 'AzureDataExplorerScanRuleset' or 'AzureFileServiceScanRuleset' or 'AzureMySqlScanRuleset' or 'AzurePostgreSqlScanRuleset' or 'AzureResourceGroupScanRuleset' or 'AzureSqlDataWarehouseScanRuleset' or 'AzureSqlDatabaseScanRuleset' or 'AzureSqlDatabaseManagedInstanceScanRuleset' or 'AzureStorageScanRuleset' or 'AzureSubscriptionScanRuleset' or 'AzureSynapseScanRuleset' or 'AzureSynapseWorkspaceScanRuleset' or 'OracleScanRuleset' or 'PowerBIScanRuleset' or 'SapEccScanRuleset' or 'SapS4HanaScanRuleset' or 'SqlServerDatabaseScanRuleset' or 'TeradataScanRuleset' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + 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_scan_rulesets_create_or_update_request( + scan_ruleset_name=scan_ruleset_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + scan_ruleset_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_scan_rulesets_delete_request( + scan_ruleset_name=scan_ruleset_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List scan rulesets in Data catalog. + + :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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + ] + } + """ + 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_scan_rulesets_list_all_request( + 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_scan_rulesets_list_all_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["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_all.metadata = {'url': '/scanrulesets'} # type: ignore +class SystemScanRulesetsOperations: + """SystemScanRulesetsOperations 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, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List all system scan rulesets for an 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + ] + } + """ + 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_system_scan_rulesets_list_all_request( + 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_system_scan_rulesets_list_all_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["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_all.metadata = {'url': '/systemScanRulesets'} # type: ignore + + @distributed_trace_async + async def get( + self, + data_source_type: str, + **kwargs: Any + ) -> Any: + """Get a system scan ruleset for a data source. + + :param data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :type data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + 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_system_scan_rulesets_get_request( + data_source_type=data_source_type, + 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': '/systemScanRulesets/datasources/{dataSourceType}'} # type: ignore + + + @distributed_trace_async + async def get_by_version( + self, + version: int, + *, + data_source_type: Optional[str] = None, + **kwargs: Any + ) -> Any: + """Get a scan ruleset by version. + + :param version: + :type version: int + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + 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_system_scan_rulesets_get_by_version_request( + version=version, + data_source_type=data_source_type, + template_url=self.get_by_version.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_by_version.metadata = {'url': '/systemScanRulesets/versions/{version}'} # type: ignore + + + @distributed_trace_async + async def get_latest( + self, + *, + data_source_type: Optional[str] = None, + **kwargs: Any + ) -> Any: + """Get the latest version of a system scan ruleset. + + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + 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_system_scan_rulesets_get_latest_request( + data_source_type=data_source_type, + template_url=self.get_latest.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_latest.metadata = {'url': '/systemScanRulesets/versions/latest'} # type: ignore + + + @distributed_trace + def list_versions_by_data_source( + self, + *, + data_source_type: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[Any]: + """List system scan ruleset versions in Data catalog. + + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + ] + } + """ + 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_system_scan_rulesets_list_versions_by_data_source_request( + data_source_type=data_source_type, + template_url=self.list_versions_by_data_source.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_system_scan_rulesets_list_versions_by_data_source_request( + data_source_type=data_source_type, + 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_versions_by_data_source.metadata = {'url': '/systemScanRulesets/versions'} # type: ignore +class TriggersOperations: + """TriggersOperations 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_trigger( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> Any: + """Gets trigger information. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + 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_triggers_get_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.get_trigger.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_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + + + @distributed_trace_async + async def create_trigger( + self, + data_source_name: str, + scan_name: str, + body: Any, + **kwargs: Any + ) -> Any: + """Creates an instance of a trigger. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + 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 = body + + request = build_triggers_create_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_trigger.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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + + + @distributed_trace_async + async def delete_trigger( + self, + data_source_name: str, + scan_name: str, + **kwargs: Any + ) -> Optional[Any]: + """Deletes the trigger associated with the scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_triggers_delete_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.delete_trigger.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/__init__.py deleted file mode 100644 index a70aae7c472a..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/__init__.py +++ /dev/null @@ -1,65 +0,0 @@ -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- -try: - from ._rest_py3 import ( - HttpRequest, - HttpResponse, - AsyncHttpResponse, - _StreamContextManager, - _AsyncStreamContextManager, - StreamConsumedError, - ResponseNotReadError, - ResponseClosedError, - ) - - __all__ = [ - "HttpRequest", - "HttpResponse", - "AsyncHttpResponse", - "_StreamContextManager", - "_AsyncStreamContextManager", - "StreamConsumedError", - "ResponseNotReadError", - "ResponseClosedError", - ] -except (SyntaxError, ImportError): - from ._rest import ( - HttpRequest, - HttpResponse, - _StreamContextManager, - StreamConsumedError, - ResponseNotReadError, - ResponseClosedError, - ) - - __all__ = [ - "HttpRequest", - "HttpResponse", - "_StreamContextManager", - "StreamConsumedError", - "ResponseNotReadError", - "ResponseClosedError", - ] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest.py deleted file mode 100644 index b6230745d0ae..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest.py +++ /dev/null @@ -1,597 +0,0 @@ -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- - -from abc import abstractmethod -import sys -import six -import os -import binascii -import codecs -import cgi -import json -from enum import Enum -import xml.etree.ElementTree as ET -from typing import TYPE_CHECKING, Iterable - -from azure.core.pipeline.transport import ( - HttpRequest as _PipelineTransportHttpRequest, -) - -if TYPE_CHECKING: - from typing import ( - Any, Optional, Union, Mapping, Sequence, Tuple, Iterator - ) - ByteStream = Iterable[bytes] - - HeadersType = Union[ - Mapping[str, str], - Sequence[Tuple[str, str]] - ] - ContentType = Union[str, bytes, ByteStream] - from azure.core.pipeline.transport._base import ( - _HttpResponseBase as _PipelineTransportHttpResponseBase - ) - from azure.core.pipeline import Pipeline - -class HttpVerbs(str, Enum): - GET = "GET" - PUT = "PUT" - POST = "POST" - HEAD = "HEAD" - PATCH = "PATCH" - DELETE = "DELETE" - MERGE = "MERGE" -from azure.core.exceptions import HttpResponseError - -########################### UTILS SECTION ################################# - -def _is_stream_or_str_bytes(content): - return isinstance(content, (str, bytes)) or any( - hasattr(content, attr) for attr in ["read", "__iter__", "__aiter__"] - ) - -def _lookup_encoding(encoding): - # type: (str) -> bool - # including check for whether encoding is known taken from httpx - try: - codecs.lookup(encoding) - return True - except LookupError: - return False - -def _set_content_length_header(header_name, header_value, internal_request): - # type: (str, str, _PipelineTransportHttpRequest) -> None - valid_methods = ["put", "post", "patch"] - content_length_headers = ["Content-Length", "Transfer-Encoding"] - if ( - internal_request.method.lower() in valid_methods and - not any([c for c in content_length_headers if c in internal_request.headers]) - ): - internal_request.headers[header_name] = header_value - -def _set_content_type_header(header_value, internal_request): - # type: (str, _PipelineTransportHttpRequest) -> None - if not internal_request.headers.get("Content-Type"): - internal_request.headers["Content-Type"] = header_value - -def _set_content_body(content, internal_request): - # type: (ContentType, _PipelineTransportHttpRequest) -> None - headers = internal_request.headers - content_type = headers.get("Content-Type") - if _is_stream_or_str_bytes(content): - # stream will be bytes / str, or iterator of bytes / str - internal_request.set_streamed_data_body(content) - if isinstance(content, (str, bytes)) and content: - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - if isinstance(content, six.string_types): - _set_content_type_header("text/plain", internal_request) - else: - _set_content_type_header("application/octet-stream", internal_request) - elif isinstance(content, Iterable): - _set_content_length_header("Transfer-Encoding", "chunked", internal_request) - _set_content_type_header("application/octet-stream", internal_request) - elif isinstance(content, ET.Element): - # XML body - internal_request.set_xml_body(content) - _set_content_type_header("application/xml", internal_request) - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - elif content_type and content_type.startswith("text/"): - # Text body - internal_request.set_text_body(content) - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - else: - # Other body - internal_request.data = content - internal_request.headers = headers - -def _set_body(content, data, files, json_body, internal_request): - # type: (ContentType, dict, Any, Any, _PipelineTransportHttpRequest) -> None - if data is not None and not isinstance(data, dict): - content = data - data = None - if content is not None: - _set_content_body(content, internal_request) - elif json_body is not None: - internal_request.set_json_body(json_body) - _set_content_type_header("application/json", internal_request) - elif files is not None: - internal_request.set_formdata_body(files) - # if you don't supply your content type, we'll create a boundary for you with multipart/form-data - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") # got logic from httpx, thanks httpx! - # _set_content_type_header("multipart/form-data; boundary={}".format(boundary), internal_request) - elif data: - _set_content_type_header("application/x-www-form-urlencoded", internal_request) - internal_request.set_formdata_body(data) - # need to set twice because Content-Type is being popped in set_formdata_body - # don't want to risk changing pipeline.transport, so doing twice here - _set_content_type_header("application/x-www-form-urlencoded", internal_request) - -def _parse_lines_from_text(text): - # largely taken from httpx's LineDecoder code - lines = [] - last_chunk_of_text = "" - while text: - text_length = len(text) - for idx in range(text_length): - curr_char = text[idx] - next_char = None if idx == len(text) - 1 else text[idx + 1] - if curr_char == "\n": - lines.append(text[: idx + 1]) - text = text[idx + 1: ] - break - if curr_char == "\r" and next_char == "\n": - # if it ends with \r\n, we only do \n - lines.append(text[:idx] + "\n") - text = text[idx + 2:] - break - if curr_char == "\r" and next_char is not None: - # if it's \r then a normal character, we switch \r to \n - lines.append(text[:idx] + "\n") - text = text[idx + 1:] - break - if next_char is None: - text = "" - last_chunk_of_text += text - break - if last_chunk_of_text.endswith("\r"): - # if ends with \r, we switch \r to \n - lines.append(last_chunk_of_text[:-1] + "\n") - elif last_chunk_of_text: - lines.append(last_chunk_of_text) - return lines - -################################## CLASSES ###################################### -class _StreamContextManager(object): - def __init__(self, pipeline, request, **kwargs): - # type: (Pipeline, HttpRequest, Any) -> None - """Used so we can treat stream requests and responses as a context manager. - In Autorest, we only return a `StreamContextManager` if users pass in `stream_response` True - Actually sends request when we enter the context manager, closes response when we exit. - Heavily inspired from httpx, we want the same behavior for it to feel consistent for users - """ - self.pipeline = pipeline - self.request = request - self.kwargs = kwargs - - def __enter__(self): - # type: (...) -> HttpResponse - """Actually make the call only when we enter. For sync stream_response calls""" - pipeline_transport_response = self.pipeline.run( - self.request._internal_request, - stream=True, - **self.kwargs - ).http_response - self.response = HttpResponse( - request=self.request, - _internal_response=pipeline_transport_response - ) - return self.response - - def __exit__(self, *args): - """Close our stream connection. For sync calls""" - self.response.__exit__(*args) - - def close(self): - self.response.close() - -class HttpRequest(object): - """Represents an HTTP request. - - :param method: HTTP method (GET, HEAD, etc.) - :type method: str or ~azure.core.protocol.HttpVerbs - :param str url: The url for your request - :keyword params: Query parameters to be mapped into your URL. Your input - should be a mapping or sequence of query name to query value(s). - :paramtype params: mapping or sequence - :keyword headers: HTTP headers you want in your request. Your input should - be a mapping or sequence of header name to header value. - :paramtype headers: mapping or sequence - :keyword dict data: Form data you want in your request body. Use for form-encoded data, i.e. - HTML forms. - :keyword any json: A JSON serializable object. We handle JSON-serialization for your - object, so use this for more complicated data structures than `data`. - :keyword files: Files you want to in your request body. Use for uploading files with - multipart encoding. Your input should be a mapping or sequence of file name to file content. - Use the `data` kwarg in addition if you want to include non-file data files as part of your request. - :paramtype files: mapping or sequence - :keyword content: Content you want in your request body. Think of it as the kwarg you should input - if your data doesn't fit into `json`, `data`, or `files`. Accepts a bytes type, or a generator - that yields bytes. - :paramtype content: str or bytes or iterable[bytes] or asynciterable[bytes] - :ivar str url: The URL this request is against. - :ivar str method: The method type of this request. - :ivar headers: The HTTP headers you passed in to your request - :vartype headers: mapping or sequence - :ivar bytes content: The content passed in for the request - """ - - def __init__(self, method, url, **kwargs): - # type: (str, str, Any) -> None - - data = kwargs.pop("data", None) - content = kwargs.pop("content", None) - json_body = kwargs.pop("json", None) - files = kwargs.pop("files", None) - - self._internal_request = kwargs.pop("_internal_request", _PipelineTransportHttpRequest( - method=method, - url=url, - headers=kwargs.pop("headers", None), - )) - params = kwargs.pop("params", None) - - if params: - self._internal_request.format_parameters(params) - - _set_body( - content=content, - data=data, - files=files, - json_body=json_body, - internal_request=self._internal_request - ) - - if kwargs: - raise TypeError( - "You have passed in kwargs '{}' that are not valid kwargs.".format( - "', '".join(list(kwargs.keys())) - ) - ) - - def _set_content_length_header(self): - method_check = self._internal_request.method.lower() in ["put", "post", "patch"] - content_length_unset = "Content-Length" not in self._internal_request.headers - if method_check and content_length_unset: - self._internal_request.headers["Content-Length"] = str(len(self._internal_request.data)) - - @property - def url(self): - # type: (...) -> str - return self._internal_request.url - - @url.setter - def url(self, val): - # type: (str) -> None - self._internal_request.url = val - - @property - def method(self): - # type: (...) -> str - return self._internal_request.method - - @property - def headers(self): - # type: (...) -> HeadersType - return self._internal_request.headers - - @property - def content(self): - # type: (...) -> Any - """Gets the request content. - """ - return self._internal_request.data or self._internal_request.files - - def __repr__(self): - return self._internal_request.__repr__() - - def __deepcopy__(self, memo=None): - return HttpRequest( - self.method, - self.url, - _internal_request=self._internal_request.__deepcopy__(memo) - ) - -class _HttpResponseBase(object): - """Base class for HttpResponse and AsyncHttpResponse. - - :keyword request: The request that resulted in this response. - :paramtype request: ~azure.core.rest.HttpRequest - :ivar int status_code: The status code of this response - :ivar headers: The response headers - :vartype headers: dict[str, any] - :ivar str reason: The reason phrase for this response - :ivar bytes content: The response content in bytes - :ivar str url: The URL that resulted in this response - :ivar str encoding: The response encoding. Is settable, by default - is the response Content-Type header - :ivar str text: The response body as a string. - :ivar request: The request that resulted in this response. - :vartype request: ~azure.core.rest.HttpRequest - :ivar str content_type: The content type of the response - :ivar bool is_error: Whether this response is an error. - """ - - def __init__(self, **kwargs): - # type: (Any) -> None - self._internal_response = kwargs.pop("_internal_response") # type: _PipelineTransportHttpResponseBase - self._request = kwargs.pop("request") - self.is_closed = False - self.is_stream_consumed = False - self._num_bytes_downloaded = 0 - - @property - def status_code(self): - # type: (...) -> int - """Returns the status code of the response""" - return self._internal_response.status_code - - @status_code.setter - def status_code(self, val): - # type: (int) -> None - """Set the status code of the response""" - self._internal_response.status_code = val - - @property - def headers(self): - # type: (...) -> HeadersType - """Returns the response headers""" - return self._internal_response.headers - - @property - def reason(self): - # type: (...) -> str - """Returns the reason phrase for the response""" - return self._internal_response.reason - - @property - def content(self): - # type: (...) -> bytes - """Returns the response content in bytes""" - try: - return self._content - except AttributeError: - raise ResponseNotReadError() - - @property - def url(self): - # type: (...) -> str - """Returns the URL that resulted in this response""" - return self._internal_response.request.url - - @property - def encoding(self): - # type: (...) -> Optional[str] - """Returns the response encoding. By default, is specified - by the response Content-Type header. - """ - - try: - return self._encoding - except AttributeError: - return self._get_charset_encoding() - - def _get_charset_encoding(self): - content_type = self.headers.get("Content-Type") - - if not content_type: - return None - _, params = cgi.parse_header(content_type) - encoding = params.get('charset') # -> utf-8 - if encoding is None or not _lookup_encoding(encoding): - return None - return encoding - - @encoding.setter - def encoding(self, value): - # type: (str) -> None - """Sets the response encoding""" - self._encoding = value - - @property - def text(self): - # type: (...) -> str - """Returns the response body as a string""" - self.content # access content to make sure we trigger if response not fully read in - return self._internal_response.text(encoding=self.encoding) - - @property - def request(self): - # type: (...) -> HttpRequest - if self._request: - return self._request - raise RuntimeError( - "You are trying to access the 'request', but there is no request associated with this HttpResponse" - ) - - @request.setter - def request(self, val): - # type: (HttpRequest) -> None - self._request = val - - @property - def content_type(self): - # type: (...) -> Optional[str] - """Content Type of the response""" - return self._internal_response.content_type or self.headers.get("Content-Type") - - @property - def num_bytes_downloaded(self): - # type: (...) -> int - """See how many bytes of your stream response have been downloaded""" - return self._num_bytes_downloaded - - @property - def is_error(self): - # type: (...) -> bool - """See whether your HttpResponse is an error. - - Use .raise_for_status() if you want to raise if this response is an error. - """ - return self.status_code < 400 - - def json(self): - # type: (...) -> Any - """Returns the whole body as a json object. - - :return: The JSON deserialized response body - :rtype: any - :raises json.decoder.JSONDecodeError or ValueError (in python 2.7) if object is not JSON decodable: - """ - return json.loads(self.text) - - def raise_for_status(self): - # type: (...) -> None - """Raises an HttpResponseError if the response has an error status code. - - If response is good, does nothing. - """ - if self.status_code >= 400: - raise HttpResponseError(response=self) - - def __repr__(self): - # type: (...) -> str - content_type_str = ( - ", Content-Type: {}".format(self.content_type) if self.content_type else "" - ) - return "<{}: {} {}{}>".format( - type(self).__name__, self.status_code, self.reason, content_type_str - ) - - def _validate_streaming_access(self): - # type: (...) -> None - if self.is_closed: - raise ResponseClosedError() - if self.is_stream_consumed: - raise StreamConsumedError() - -class HttpResponse(_HttpResponseBase): - - def close(self): - # type: (...) -> None - self.is_closed = True - self._internal_response.internal_response.close() - - def __exit__(self, *args): - # type: (...) -> None - self.close() - - def read(self): - # type: (...) -> bytes - """ - Read the response's bytes. - - """ - try: - return self._content - except AttributeError: - self._validate_streaming_access() - self._content = ( - self._internal_response.body() or - b"".join(self.iter_raw()) - ) - self._close_stream() - return self._content - - def iter_bytes(self, chunk_size=None): - # type: (int) -> Iterator[bytes] - """Iterate over the bytes in the response stream - """ - try: - chunk_size = len(self._content) if chunk_size is None else chunk_size - for i in range(0, len(self._content), chunk_size): - yield self._content[i: i + chunk_size] - - except AttributeError: - for raw_bytes in self.iter_raw(chunk_size=chunk_size): - yield raw_bytes - - def iter_text(self, chunk_size=None): - # type: (int) -> Iterator[str] - """Iterate over the response text - """ - for byte in self.iter_bytes(chunk_size): - text = byte.decode(self.encoding or "utf-8") - yield text - - def iter_lines(self, chunk_size=None): - # type: (int) -> Iterator[str] - for text in self.iter_text(chunk_size): - lines = _parse_lines_from_text(text) - for line in lines: - yield line - - def _close_stream(self): - # type: (...) -> None - self.is_stream_consumed = True - self.close() - - def iter_raw(self, chunk_size=None): - # type: (int) -> Iterator[bytes] - """Iterate over the raw response bytes - """ - self._validate_streaming_access() - stream_download = self._internal_response.stream_download(None, chunk_size=chunk_size) - for raw_bytes in stream_download: - self._num_bytes_downloaded += len(raw_bytes) - yield raw_bytes - - self._close_stream() - -########################### ERRORS SECTION ################################# - -class StreamConsumedError(Exception): - def __init__(self): - message = ( - "You are attempting to read or stream content that has already been streamed. " - "You have likely already consumed this stream, so it can not be accessed anymore." - ) - super(StreamConsumedError, self).__init__(message) - -class ResponseClosedError(Exception): - def __init__(self): - message = ( - "You can not try to read or stream this response's content, since the " - "response has been closed." - ) - super(ResponseClosedError, self).__init__(message) - -class ResponseNotReadError(Exception): - - def __init__(self): - message = ( - "You have not read in the response's bytes yet. Call response.read() first." - ) - super(ResponseNotReadError, self).__init__(message) \ No newline at end of file diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest_py3.py deleted file mode 100644 index 77487f231237..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest_py3.py +++ /dev/null @@ -1,706 +0,0 @@ -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- -import asyncio -import os -import binascii -import codecs -import cgi -import json -from enum import Enum -import xml.etree.ElementTree as ET -from typing import ( - Any, - AsyncIterable, - IO, - Iterable, Iterator, - Optional, - Type, - Union, - Mapping, - Sequence, - Tuple, - List, -) -from abc import abstractmethod -from azure.core.exceptions import HttpResponseError - -################################### TYPES SECTION ######################### - -ByteStream = Union[Iterable[bytes], AsyncIterable[bytes]] -PrimitiveData = Optional[Union[str, int, float, bool]] - - -ParamsType = Union[ - Mapping[str, Union[PrimitiveData, Sequence[PrimitiveData]]], - List[Tuple[str, PrimitiveData]] -] - -HeadersType = Union[ - Mapping[str, str], - Sequence[Tuple[str, str]] -] - -ContentType = Union[str, bytes, ByteStream] - -FileContent = Union[str, bytes, IO[str], IO[bytes]] -FileType = Union[ - Tuple[Optional[str], FileContent], -] - -FilesType = Union[ - Mapping[str, FileType], - Sequence[Tuple[str, FileType]] -] - -from azure.core.pipeline import Pipeline, AsyncPipeline -from azure.core.pipeline.transport import ( - HttpRequest as _PipelineTransportHttpRequest, -) - -from azure.core.pipeline.transport._base import ( - _HttpResponseBase as _PipelineTransportHttpResponseBase -) - -from azure.core._pipeline_client import PipelineClient as _PipelineClient -from azure.core._pipeline_client_async import AsyncPipelineClient as _AsyncPipelineClient - -class HttpVerbs(str, Enum): - GET = "GET" - PUT = "PUT" - POST = "POST" - HEAD = "HEAD" - PATCH = "PATCH" - DELETE = "DELETE" - MERGE = "MERGE" - -########################### UTILS SECTION ################################# - -def _is_stream_or_str_bytes(content: Any) -> bool: - return isinstance(content, (str, bytes)) or any( - hasattr(content, attr) for attr in ["read", "__iter__", "__aiter__"] - ) - -def _lookup_encoding(encoding: str) -> bool: - # including check for whether encoding is known taken from httpx - try: - codecs.lookup(encoding) - return True - except LookupError: - return False - -def _set_content_length_header(header_name: str, header_value: str, internal_request: _PipelineTransportHttpRequest) -> None: - valid_methods = ["put", "post", "patch"] - content_length_headers = ["Content-Length", "Transfer-Encoding"] - if ( - internal_request.method.lower() in valid_methods and - not any([c for c in content_length_headers if c in internal_request.headers]) - ): - internal_request.headers[header_name] = header_value - -def _set_content_type_header(header_value: str, internal_request: _PipelineTransportHttpRequest) -> None: - if not internal_request.headers.get("Content-Type"): - internal_request.headers["Content-Type"] = header_value - -def _set_content_body(content: ContentType, internal_request: _PipelineTransportHttpRequest) -> None: - headers = internal_request.headers - content_type = headers.get("Content-Type") - if _is_stream_or_str_bytes(content): - # stream will be bytes / str, or iterator of bytes / str - internal_request.set_streamed_data_body(content) - if isinstance(content, str) and content: - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - _set_content_type_header("text/plain", internal_request) - elif isinstance(content, bytes) and content: - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - _set_content_type_header("application/octet-stream", internal_request) - elif isinstance(content, (Iterable, AsyncIterable)): - _set_content_length_header("Transfer-Encoding", "chunked", internal_request) - _set_content_type_header("application/octet-stream", internal_request) - elif isinstance(content, ET.Element): - # XML body - internal_request.set_xml_body(content) - _set_content_type_header("application/xml", internal_request) - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - elif content_type and content_type.startswith("text/"): - # Text body - internal_request.set_text_body(content) - _set_content_length_header("Content-Length", str(len(internal_request.data)), internal_request) - else: - # Other body - internal_request.data = content - internal_request.headers = headers - -def _set_body( - content: ContentType, data: dict, files: Any, json_body: Any, internal_request: _PipelineTransportHttpRequest -) -> None: - if data is not None and not isinstance(data, dict): - content = data - data = None - if content is not None: - _set_content_body(content, internal_request) - elif json_body is not None: - internal_request.set_json_body(json_body) - _set_content_type_header("application/json", internal_request) - elif files is not None: - internal_request.set_formdata_body(files) - # if you don't supply your content type, we'll create a boundary for you with multipart/form-data - boundary = binascii.hexlify(os.urandom(16)).decode("ascii") # got logic from httpx, thanks httpx! - # _set_content_type_header("multipart/form-data; boundary={}".format(boundary), internal_request) - elif data: - _set_content_type_header("application/x-www-form-urlencoded", internal_request) - internal_request.set_formdata_body(data) - # need to set twice because Content-Type is being popped in set_formdata_body - # don't want to risk changing pipeline.transport, so doing twice here - _set_content_type_header("application/x-www-form-urlencoded", internal_request) - -def _parse_lines_from_text(text): - # largely taken from httpx's LineDecoder code - lines = [] - last_chunk_of_text = "" - while text: - text_length = len(text) - for idx in range(text_length): - curr_char = text[idx] - next_char = None if idx == len(text) - 1 else text[idx + 1] - if curr_char == "\n": - lines.append(text[: idx + 1]) - text = text[idx + 1: ] - break - if curr_char == "\r" and next_char == "\n": - # if it ends with \r\n, we only do \n - lines.append(text[:idx] + "\n") - text = text[idx + 2:] - break - if curr_char == "\r" and next_char is not None: - # if it's \r then a normal character, we switch \r to \n - lines.append(text[:idx] + "\n") - text = text[idx + 1:] - break - if next_char is None: - text = "" - last_chunk_of_text += text - break - if last_chunk_of_text.endswith("\r"): - # if ends with \r, we switch \r to \n - lines.append(last_chunk_of_text[:-1] + "\n") - elif last_chunk_of_text: - lines.append(last_chunk_of_text) - return lines - - -class _StreamContextManagerBase: - def __init__( - self, - pipeline: Union[Pipeline, AsyncPipeline], - request: "HttpRequest", - **kwargs - ): - """Used so we can treat stream requests and responses as a context manager. - - In Autorest, we only return a `StreamContextManager` if users pass in `stream_response` True - - Actually sends request when we enter the context manager, closes response when we exit. - - Heavily inspired from httpx, we want the same behavior for it to feel consistent for users - """ - self.pipeline = pipeline - self.request = request - self.kwargs = kwargs - - @abstractmethod - def close(self): - ... - -class _StreamContextManager(_StreamContextManagerBase): - def __enter__(self) -> "HttpResponse": - """Actually make the call only when we enter. For sync stream_response calls""" - pipeline_transport_response = self.pipeline.run( - self.request._internal_request, - stream=True, - **self.kwargs - ).http_response - self.response = HttpResponse( - request=self.request, - _internal_response=pipeline_transport_response - ) - return self.response - - def __exit__(self, *args): - """Close our stream connection. For sync calls""" - self.response.__exit__(*args) - - def close(self): - self.response.close() - -class _AsyncStreamContextManager(_StreamContextManagerBase): - async def __aenter__(self) -> "AsyncHttpResponse": - """Actually make the call only when we enter. For async stream_response calls.""" - if not isinstance(self.pipeline, AsyncPipeline): - raise TypeError( - "Only async calls should enter here. If you mean to do a sync call, " - "make sure to use 'with' instead." - ) - pipeline_transport_response = (await self.pipeline.run( - self.request._internal_request, - stream=True, - **self.kwargs - )).http_response - self.response = AsyncHttpResponse( - request=self.request, - _internal_response=pipeline_transport_response - ) - return self.response - - async def __aexit__(self, *args): - await self.response.__aexit__(*args) - - async def close(self): - await self.response.close() - -################################## CLASSES ###################################### - -class HttpRequest: - """Represents an HTTP request. - - :param method: HTTP method (GET, HEAD, etc.) - :type method: str or ~azure.core.protocol.HttpVerbs - :param str url: The url for your request - :keyword params: Query parameters to be mapped into your URL. Your input - should be a mapping or sequence of query name to query value(s). - :paramtype params: mapping or sequence - :keyword headers: HTTP headers you want in your request. Your input should - be a mapping or sequence of header name to header value. - :paramtype headers: mapping or sequence - :keyword any json: A JSON serializable object. We handle JSON-serialization for your - object, so use this for more complicated data structures than `data`. - :keyword content: Content you want in your request body. Think of it as the kwarg you should input - if your data doesn't fit into `json`, `data`, or `files`. Accepts a bytes type, or a generator - that yields bytes. - :paramtype content: str or bytes or iterable[bytes] or asynciterable[bytes] - :keyword dict data: Form data you want in your request body. Use for form-encoded data, i.e. - HTML forms. - :keyword files: Files you want to in your request body. Use for uploading files with - multipart encoding. Your input should be a mapping or sequence of file name to file content. - Use the `data` kwarg in addition if you want to include non-file data files as part of your request. - :paramtype files: mapping or sequence - :ivar str url: The URL this request is against. - :ivar str method: The method type of this request. - :ivar headers: The HTTP headers you passed in to your request - :vartype headers: mapping or sequence - :ivar bytes content: The content passed in for the request - """ - - def __init__( - self, - method: str, - url: str, - *, - params: Optional[ParamsType] = None, - headers: Optional[HeadersType] = None, - json: Any = None, - content: Optional[ContentType] = None, - data: Optional[dict] = None, - files: Optional[FilesType] = None, - **kwargs - ): - # type: (str, str, Any) -> None - - self._internal_request = kwargs.pop("_internal_request", _PipelineTransportHttpRequest( - method=method, - url=url, - headers=headers, - )) - - if params: - self._internal_request.format_parameters(params) - - _set_body( - content=content, - data=data, - files=files, - json_body=json, - internal_request=self._internal_request - ) - - if kwargs: - raise TypeError( - "You have passed in kwargs '{}' that are not valid kwargs.".format( - "', '".join(list(kwargs.keys())) - ) - ) - - def _set_content_length_header(self) -> None: - method_check = self._internal_request.method.lower() in ["put", "post", "patch"] - content_length_unset = "Content-Length" not in self._internal_request.headers - if method_check and content_length_unset: - self._internal_request.headers["Content-Length"] = str(len(self._internal_request.data)) - - @property - def url(self) -> str: - return self._internal_request.url - - @url.setter - def url(self, val: str) -> None: - self._internal_request.url = val - - @property - def method(self) -> str: - return self._internal_request.method - - @property - def headers(self) -> HeadersType: - return self._internal_request.headers - - @property - def content(self) -> Any: - """Gets the request content. - """ - return self._internal_request.data or self._internal_request.files - - def __repr__(self) -> str: - return self._internal_request.__repr__() - - def __deepcopy__(self, memo=None) -> "HttpRequest": - return HttpRequest( - self.method, - self.url, - _internal_request=self._internal_request.__deepcopy__(memo) - ) - -class _HttpResponseBase: - """Base class for HttpResponse and AsyncHttpResponse. - - :keyword request: The request that resulted in this response. - :paramtype request: ~azure.core.rest.HttpRequest - :ivar int status_code: The status code of this response - :ivar headers: The response headers - :vartype headers: dict[str, any] - :ivar str reason: The reason phrase for this response - :ivar bytes content: The response content in bytes - :ivar str url: The URL that resulted in this response - :ivar str encoding: The response encoding. Is settable, by default - is the response Content-Type header - :ivar str text: The response body as a string. - :ivar request: The request that resulted in this response. - :vartype request: ~azure.core.rest.HttpRequest - :ivar str content_type: The content type of the response - :ivar bool is_closed: Whether the network connection has been closed yet - :ivar bool is_stream_consumed: When getting a stream response, checks - whether the stream has been fully consumed - :ivar int num_bytes_downloaded: The number of bytes in your stream that - have been downloaded - """ - - def __init__( - self, - *, - request: HttpRequest, - **kwargs - ): - self._internal_response = kwargs.pop("_internal_response") # type: _PipelineTransportHttpResponseBase - self._request = request - self.is_closed = False - self.is_stream_consumed = False - self._num_bytes_downloaded = 0 - - @property - def status_code(self) -> int: - """Returns the status code of the response""" - return self._internal_response.status_code - - @status_code.setter - def status_code(self, val: int) -> None: - """Set the status code of the response""" - self._internal_response.status_code = val - - @property - def headers(self) -> HeadersType: - """Returns the response headers""" - return self._internal_response.headers - - @property - def reason(self) -> str: - """Returns the reason phrase for the response""" - return self._internal_response.reason - - @property - def url(self) -> str: - """Returns the URL that resulted in this response""" - return self._internal_response.request.url - - @property - def encoding(self) -> str: - """Returns the response encoding. By default, is specified - by the response Content-Type header. - """ - - try: - return self._encoding - except AttributeError: - return self._get_charset_encoding() - - def _get_charset_encoding(self) -> str: - content_type = self.headers.get("Content-Type") - - if not content_type: - return None - _, params = cgi.parse_header(content_type) - encoding = params.get('charset') # -> utf-8 - if encoding is None or not _lookup_encoding(encoding): - return None - return encoding - - @encoding.setter - def encoding(self, value: str) -> None: - # type: (str) -> None - """Sets the response encoding""" - self._encoding = value - - @property - def text(self) -> str: - """Returns the response body as a string""" - self.content # access content to make sure we trigger if response not fully read in - return self._internal_response.text(encoding=self.encoding) - - @property - def request(self) -> HttpRequest: - if self._request: - return self._request - raise RuntimeError( - "You are trying to access the 'request', but there is no request associated with this HttpResponse" - ) - - @request.setter - def request(self, val: HttpRequest) -> None: - self._request = val - - @property - def content_type(self) -> Optional[str]: - """Content Type of the response""" - return self._internal_response.content_type or self.headers.get("Content-Type") - - @property - def num_bytes_downloaded(self) -> int: - """See how many bytes of your stream response have been downloaded""" - return self._num_bytes_downloaded - - def json(self) -> Any: - """Returns the whole body as a json object. - - :return: The JSON deserialized response body - :rtype: any - :raises json.decoder.JSONDecodeError or ValueError (in python 2.7) if object is not JSON decodable: - """ - return json.loads(self.text) - - def raise_for_status(self) -> None: - """Raises an HttpResponseError if the response has an error status code. - - If response is good, does nothing. - """ - if self.status_code >= 400: - raise HttpResponseError(response=self) - - @property - def content(self) -> bytes: - """Return the response's content in bytes.""" - try: - return self._content - except AttributeError: - raise ResponseNotReadError() - - def __repr__(self) -> str: - content_type_str = ( - ", Content-Type: {}".format(self.content_type) if self.content_type else "" - ) - return "<{}: {} {}{}>".format( - type(self).__name__, self.status_code, self.reason, content_type_str - ) - - def _validate_streaming_access(self) -> None: - if self.is_closed: - raise ResponseClosedError() - if self.is_stream_consumed: - raise StreamConsumedError() - -class HttpResponse(_HttpResponseBase): - - def close(self) -> None: - self.is_closed = True - self._internal_response.internal_response.close() - - def __exit__(self, *args) -> None: - self.is_closed = True - self._internal_response.internal_response.__exit__(*args) - - def read(self) -> bytes: - """ - Read the response's bytes. - - """ - try: - return self._content - except AttributeError: - self._validate_streaming_access() - self._content = ( - self._internal_response.body() or - b"".join(self.iter_raw()) - ) - self._close_stream() - return self._content - - def iter_bytes(self, chunk_size: int = None) -> Iterator[bytes]: - """Iterate over the bytes in the response stream - """ - try: - chunk_size = len(self._content) if chunk_size is None else chunk_size - for i in range(0, len(self._content), chunk_size): - yield self._content[i: i + chunk_size] - - except AttributeError: - for raw_bytes in self.iter_raw(chunk_size=chunk_size): - yield raw_bytes - - def iter_text(self, chunk_size: int = None) -> Iterator[str]: - """Iterate over the response text - """ - for byte in self.iter_bytes(chunk_size): - text = byte.decode(self.encoding or "utf-8") - yield text - - def iter_lines(self, chunk_size: int = None) -> Iterator[str]: - for text in self.iter_text(chunk_size): - lines = _parse_lines_from_text(text) - for line in lines: - yield line - - def _close_stream(self) -> None: - self.is_stream_consumed = True - self.close() - - def iter_raw(self, chunk_size: int = None) -> Iterator[bytes]: - """Iterate over the raw response bytes - """ - self._validate_streaming_access() - stream_download = self._internal_response.stream_download(None, chunk_size=chunk_size) - for raw_bytes in stream_download: - self._num_bytes_downloaded += len(raw_bytes) - yield raw_bytes - - self._close_stream() - - -class AsyncHttpResponse(_HttpResponseBase): - - async def _close_stream(self) -> None: - self.is_stream_consumed = True - await self.close() - - async def read(self) -> bytes: - """ - Read the response's bytes. - - """ - try: - return self._content - except AttributeError: - self._validate_streaming_access() - await self._internal_response.load_body() - self._content = self._internal_response._body - await self._close_stream() - return self._content - - async def iter_bytes(self, chunk_size: int = None) -> Iterator[bytes]: - """Iterate over the bytes in the response stream - """ - try: - chunk_size = len(self._content) if chunk_size is None else chunk_size - for i in range(0, len(self._content), chunk_size): - yield self._content[i: i + chunk_size] - - except AttributeError: - async for raw_bytes in self.iter_raw(chunk_size=chunk_size): - yield raw_bytes - - async def iter_text(self, chunk_size: int = None) -> Iterator[str]: - """Iterate over the response text - """ - async for byte in self.iter_bytes(chunk_size): - text = byte.decode(self.encoding or "utf-8") - yield text - - async def iter_lines(self, chunk_size: int = None) -> Iterator[str]: - async for text in self.iter_text(chunk_size): - lines = _parse_lines_from_text(text) - for line in lines: - yield line - - async def iter_raw(self, chunk_size: int = None) -> Iterator[bytes]: - """Iterate over the raw response bytes - """ - self._validate_streaming_access() - stream_download = self._internal_response.stream_download(None, chunk_size=chunk_size) - async for raw_bytes in stream_download: - self._num_bytes_downloaded += len(raw_bytes) - yield raw_bytes - - await self._close_stream() - - async def close(self) -> None: - self.is_closed = True - self._internal_response.internal_response.close() - await asyncio.sleep(0) - - async def __aexit__(self, *args) -> None: - self.is_closed = True - await self._internal_response.internal_response.__aexit__(*args) - - -########################### ERRORS SECTION ################################# - -class StreamConsumedError(Exception): - def __init__(self) -> None: - message = ( - "You are attempting to read or stream content that has already been streamed. " - "You have likely already consumed this stream, so it can not be accessed anymore." - ) - super().__init__(message) - -class ResponseClosedError(Exception): - def __init__(self) -> None: - message = ( - "You can not try to read or stream this response's content, since the " - "response has been closed." - ) - super().__init__(message) - -class ResponseNotReadError(Exception): - - def __init__(self) -> None: - message = ( - "You have not read in the response's bytes yet. Call response.read() first." - ) - super().__init__(message) diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/__init__.py new file mode 100644 index 000000000000..949a0417fbfd --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/__init__.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# 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 KeyVaultConnectionsOperations +from ._operations import ClassificationRulesOperations +from ._operations import DataSourcesOperations +from ._operations import FiltersOperations +from ._operations import ScansOperations +from ._operations import ScanResultOperations +from ._operations import ScanRulesetsOperations +from ._operations import SystemScanRulesetsOperations +from ._operations import TriggersOperations + +__all__ = [ + 'KeyVaultConnectionsOperations', + 'ClassificationRulesOperations', + 'DataSourcesOperations', + 'FiltersOperations', + 'ScansOperations', + 'ScanResultOperations', + 'ScanRulesetsOperations', + 'SystemScanRulesetsOperations', + 'TriggersOperations', +] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/_operations.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/_operations.py new file mode 100644 index 000000000000..a5907eba8648 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/azure/purview/scanning/operations/_operations.py @@ -0,0 +1,4784 @@ +# 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, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +# fmt: off + +def build_key_vault_connections_get_request( + key_vault_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') + path_format_arguments = { + "keyVaultName": _SERIALIZER.url("key_vault_name", key_vault_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_key_vault_connections_create_request( + key_vault_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') + path_format_arguments = { + "keyVaultName": _SERIALIZER.url("key_vault_name", key_vault_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_key_vault_connections_delete_request( + key_vault_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') + path_format_arguments = { + "keyVaultName": _SERIALIZER.url("key_vault_name", key_vault_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_key_vault_connections_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/azureKeyVaults') + + # 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_classification_rules_get_request( + classification_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') + path_format_arguments = { + "classificationRuleName": _SERIALIZER.url("classification_rule_name", classification_rule_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_classification_rules_create_or_update_request( + classification_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') + path_format_arguments = { + "classificationRuleName": _SERIALIZER.url("classification_rule_name", classification_rule_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_classification_rules_delete_request( + classification_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') + path_format_arguments = { + "classificationRuleName": _SERIALIZER.url("classification_rule_name", classification_rule_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_classification_rules_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules') + + # 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_classification_rules_list_versions_by_classification_rule_name_request( + classification_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions') + path_format_arguments = { + "classificationRuleName": _SERIALIZER.url("classification_rule_name", classification_rule_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_classification_rules_tag_classification_version_request( + classification_rule_name, # type: str + classification_rule_version, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + action = kwargs.pop('action') # type: str + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag') + path_format_arguments = { + "classificationRuleName": _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), + "classificationRuleVersion": _SERIALIZER.url("classification_rule_version", classification_rule_version, 'int'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['action'] = _SERIALIZER.query("action", action, '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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_data_sources_create_or_update_request( + data_source_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_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_data_sources_get_request( + data_source_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_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_data_sources_delete_request( + data_source_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_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_data_sources_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources') + + # 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_filters_get_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_filters_create_or_update_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_scans_create_or_update_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_scans_get_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_scans_delete_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_scans_list_by_data_source_request( + data_source_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_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_scan_result_run_scan_request( + data_source_name, # type: str + scan_name, # type: str + run_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + scan_level = kwargs.pop('scan_level', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_name, 'str'), + "runId": _SERIALIZER.url("run_id", run_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if scan_level is not None: + query_parameters['scanLevel'] = _SERIALIZER.query("scan_level", scan_level, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_scan_result_cancel_scan_request( + data_source_name, # type: str + scan_name, # type: str + run_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_name, 'str'), + "runId": _SERIALIZER.url("run_id", run_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_scan_result_list_scan_history_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_scan_rulesets_get_request( + scan_ruleset_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') + path_format_arguments = { + "scanRulesetName": _SERIALIZER.url("scan_ruleset_name", scan_ruleset_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_scan_rulesets_create_or_update_request( + scan_ruleset_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') + path_format_arguments = { + "scanRulesetName": _SERIALIZER.url("scan_ruleset_name", scan_ruleset_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_scan_rulesets_delete_request( + scan_ruleset_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') + path_format_arguments = { + "scanRulesetName": _SERIALIZER.url("scan_ruleset_name", scan_ruleset_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_scan_rulesets_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/scanrulesets') + + # 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_system_scan_rulesets_list_all_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/systemScanRulesets') + + # 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_system_scan_rulesets_get_request( + data_source_type, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/systemScanRulesets/datasources/{dataSourceType}') + path_format_arguments = { + "dataSourceType": _SERIALIZER.url("data_source_type", data_source_type, '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_system_scan_rulesets_get_by_version_request( + version, # type: int + **kwargs # type: Any +): + # type: (...) -> HttpRequest + data_source_type = kwargs.pop('data_source_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/systemScanRulesets/versions/{version}') + path_format_arguments = { + "version": _SERIALIZER.url("version", version, 'int'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if data_source_type is not None: + query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_system_scan_rulesets_get_latest_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + data_source_type = kwargs.pop('data_source_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/systemScanRulesets/versions/latest') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if data_source_type is not None: + query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_system_scan_rulesets_list_versions_by_data_source_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + data_source_type = kwargs.pop('data_source_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/systemScanRulesets/versions') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if data_source_type is not None: + query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_triggers_get_trigger_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_triggers_create_trigger_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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_triggers_delete_trigger_request( + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') + path_format_arguments = { + "dataSourceName": _SERIALIZER.url("data_source_name", data_source_name, 'str'), + "scanName": _SERIALIZER.url("scan_name", scan_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 + ) + +# fmt: on +class KeyVaultConnectionsOperations(object): + """KeyVaultConnectionsOperations 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( + self, + key_vault_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Gets key vault information. + + :param key_vault_name: + :type key_vault_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_key_vault_connections_get_request( + key_vault_name=key_vault_name, + 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': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace + def create( + self, + key_vault_name, # type: str + body, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates an instance of a key vault connection. + + :param key_vault_name: + :type key_vault_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + json = body + + request = build_key_vault_connections_create_request( + key_vault_name=key_vault_name, + content_type=content_type, + json=json, + template_url=self.create.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.metadata = {'url': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace + def delete( + self, + key_vault_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes the key vault connection associated with the account. + + :param key_vault_name: + :type key_vault_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_key_vault_connections_delete_request( + key_vault_name=key_vault_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/azureKeyVaults/{keyVaultName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List key vault connections in 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "baseUrl": "str", # Optional. + "description": "str" # Optional. + } + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_key_vault_connections_list_all_request( + 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_key_vault_connections_list_all_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["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_all.metadata = {'url': '/azureKeyVaults'} # type: ignore +class ClassificationRulesOperations(object): + """ClassificationRulesOperations 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( + self, + classification_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a classification rule. + + :param classification_rule_name: + :type classification_rule_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + 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_classification_rules_get_request( + classification_rule_name=classification_rule_name, + 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': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + classification_rule_name, # type: str + body=None, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or Updates a classification rule. + + :param classification_rule_name: + :type classification_rule_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'CustomClassificationRule' or 'SystemClassificationRule' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + 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_classification_rules_create_or_update_request( + classification_rule_name=classification_rule_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace + def delete( + self, + classification_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes a classification rule. + + :param classification_rule_name: + :type classification_rule_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_classification_rules_delete_request( + classification_rule_name=classification_rule_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/classificationrules/{classificationRuleName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List classification rules in 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + ] + } + """ + 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_classification_rules_list_all_request( + 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_classification_rules_list_all_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["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_all.metadata = {'url': '/classificationrules'} # type: ignore + + @distributed_trace + def list_versions_by_classification_rule_name( + self, + classification_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """Lists the rule versions of a classification rule. + + :param classification_rule_name: + :type classification_rule_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + kind: ClassificationRule + } + ] + } + """ + 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_classification_rules_list_versions_by_classification_rule_name_request( + classification_rule_name=classification_rule_name, + template_url=self.list_versions_by_classification_rule_name.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_classification_rules_list_versions_by_classification_rule_name_request( + classification_rule_name=classification_rule_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["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_versions_by_classification_rule_name.metadata = {'url': '/classificationrules/{classificationRuleName}/versions'} # type: ignore + + @distributed_trace + def tag_classification_version( + self, + classification_rule_name, # type: str + classification_rule_version, # type: int + **kwargs # type: Any + ): + # type: (...) -> Any + """Sets Classification Action on a specific classification rule version. + + :param classification_rule_name: + :type classification_rule_name: str + :param classification_rule_version: + :type classification_rule_version: int + :keyword action: Possible values are: "Keep" or "Delete". + :paramtype action: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + action = kwargs.pop('action') # type: str + + + request = build_classification_rules_tag_classification_version_request( + classification_rule_name=classification_rule_name, + classification_rule_version=classification_rule_version, + action=action, + template_url=self.tag_classification_version.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 [202]: + 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 + + tag_classification_version.metadata = {'url': '/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag'} # type: ignore + +class DataSourcesOperations(object): + """DataSourcesOperations 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 create_or_update( + self, + data_source_name, # type: str + body=None, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or Updates a data source. + + :param data_source_name: + :type data_source_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1DataSource' or 'AdlsGen2DataSource' or 'AmazonAccountDataSource' or 'AmazonPostgreSqlDataSource' or 'AmazonS3DataSource' or 'AmazonSqlDataSource' or 'AzureCosmosDbDataSource' or 'AzureDataExplorerDataSource' or 'AzureFileServiceDataSource' or 'AzureMySqlDataSource' or 'AzurePostgreSqlDataSource' or 'AzureResourceGroupDataSource' or 'AzureSqlDataWarehouseDataSource' or 'AzureSqlDatabaseDataSource' or 'AzureSqlDatabaseManagedInstanceDataSource' or 'AzureStorageDataSource' or 'AzureSubscriptionDataSource' or 'AzureSynapseDataSource' or 'AzureSynapseWorkspaceDataSource' or 'OracleDataSource' or 'PowerBIDataSource' or 'SapEccDataSource' or 'SapS4HanaDataSource' or 'SqlServerDatabaseDataSource' or 'TeradataDataSource' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + 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_data_sources_create_or_update_request( + data_source_name=data_source_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace + def get( + self, + data_source_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a data source. + + :param data_source_name: + :type data_source_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + 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_data_sources_get_request( + data_source_name=data_source_name, + 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': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace + def delete( + self, + data_source_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes a data source. + + :param data_source_name: + :type data_source_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_data_sources_delete_request( + data_source_name=data_source_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/datasources/{dataSourceName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List data sources in Data catalog. + + :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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scans": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ], + kind: DataSource + } + ] + } + """ + 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_data_sources_list_all_request( + 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_data_sources_list_all_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["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_all.metadata = {'url': '/datasources'} # type: ignore +class FiltersOperations(object): + """FiltersOperations 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( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a filter. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_filters_get_request( + data_source_name=data_source_name, + scan_name=scan_name, + 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': '/datasources/{dataSourceName}/scans/{scanName}/filters/custom'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + data_source_name, # type: str + scan_name, # type: str + body=None, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or updates a filter. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "excludeUriPrefixes": [ + "str" # Optional. + ], + "includeUriPrefixes": [ + "str" # Optional. + ] + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + if body is not None: + json = body + else: + json = None + + request = build_filters_create_or_update_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/filters/custom'} # type: ignore + +class ScansOperations(object): + """ScansOperations 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 create_or_update( + self, + data_source_name, # type: str + scan_name, # type: str + body, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates an instance of a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1CredentialScan' or 'AdlsGen1MsiScan' or 'AdlsGen2CredentialScan' or 'AdlsGen2MsiScan' or 'AmazonAccountCredentialScan' or 'AmazonPostgreSqlCredentialScan' or 'AmazonS3CredentialScan' or 'AmazonS3RoleARNScan' or 'AmazonSqlCredentialScan' or 'AzureCosmosDbCredentialScan' or 'AzureDataExplorerCredentialScan' or 'AzureDataExplorerMsiScan' or 'AzureFileServiceCredentialScan' or 'AzureMySqlCredentialScan' or 'AzurePostgreSqlCredentialScan' or 'AzureResourceGroupCredentialScan' or 'AzureResourceGroupMsiScan' or 'AzureSqlDataWarehouseCredentialScan' or 'AzureSqlDataWarehouseMsiScan' or 'AzureSqlDatabaseCredentialScan' or 'AzureSqlDatabaseManagedInstanceCredentialScan' or 'AzureSqlDatabaseManagedInstanceMsiScan' or 'AzureSqlDatabaseMsiScan' or 'AzureStorageCredentialScan' or 'AzureStorageMsiScan' or 'AzureSubscriptionCredentialScan' or 'AzureSubscriptionMsiScan' or 'AzureSynapseCredentialScan' or 'AzureSynapseMsiScan' or 'AzureSynapseWorkspaceCredentialScan' or 'AzureSynapseWorkspaceMsiScan' or 'OracleCredentialScan' or 'OracleUserPassScan' or 'PowerBIDelegatedScan' or 'PowerBIMsiScan' or 'SapEccCredentialScan' or 'SapEccUserPassScan' or 'SapS4HanaSapS4HanaCredentialScan' or 'SapS4HanaSapS4HanaUserPassScan' or 'SqlServerDatabaseCredentialScan' or 'TeradataCredentialScan' or 'TeradataUserPassScanAutoGenerated' or 'TeradataUserPassScan' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + 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 = body + + request = build_scans_create_or_update_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace + def get( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Gets a scan information. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + 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_scans_get_request( + data_source_name=data_source_name, + scan_name=scan_name, + 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': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace + def delete( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes the scan associated with the data source. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_scans_delete_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}'} # type: ignore + + + @distributed_trace + def list_by_data_source( + self, + data_source_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List scans in data source. + + :param data_source_name: + :type data_source_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanResults": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ], + kind: Scan + } + ] + } + """ + 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_scans_list_by_data_source_request( + data_source_name=data_source_name, + template_url=self.list_by_data_source.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_scans_list_by_data_source_request( + data_source_name=data_source_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["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_by_data_source.metadata = {'url': '/datasources/{dataSourceName}/scans'} # type: ignore +class ScanResultOperations(object): + """ScanResultOperations 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 run_scan( + self, + data_source_name, # type: str + scan_name, # type: str + run_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Runs the scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param run_id: + :type run_id: str + :keyword scan_level: Possible values are: "Full" or "Incremental". + :paramtype scan_level: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + scan_level = kwargs.pop('scan_level', None) # type: Optional[str] + + + request = build_scan_result_run_scan_request( + data_source_name=data_source_name, + scan_name=scan_name, + run_id=run_id, + scan_level=scan_level, + template_url=self.run_scan.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 [202]: + 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 + + run_scan.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}'} # type: ignore + + + @distributed_trace + def cancel_scan( + self, + data_source_name, # type: str + scan_name, # type: str + run_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Cancels a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param run_id: + :type run_id: str + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 202 + response.json() == { + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "scanResultId": str, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. Possible values include: "Accepted", "InProgress", "TransientFailure", "Succeeded", "Failed", "Canceled". + } + """ + 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_scan_result_cancel_scan_request( + data_source_name=data_source_name, + scan_name=scan_name, + run_id=run_id, + template_url=self.cancel_scan.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 [202]: + 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 + + cancel_scan.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel'} # type: ignore + + + @distributed_trace + def list_scan_history( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """Lists the scan history of a scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "assetsClassified": 0.0, # Optional. + "assetsDiscovered": 0.0, # Optional. + "dataSourceType": "str", # Optional. Possible values include: "None", "AzureSubscription", "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", "PowerBI". + "diagnostics": { + "exceptionCountMap": { + "str": 0 # Optional. Dictionary of :code:``. + }, + "notifications": [ + { + "code": 0, # Optional. + "message": "str" # Optional. + } + ] + }, + "endTime": "2020-02-20 00:00:00", # Optional. + "error": { + "code": "str", # Optional. + "details": [ + { + "code": "str", # Optional. + "details": [ + ... + ], + "message": "str", # Optional. + "target": "str" # Optional. + } + ], + "message": "str", # Optional. + "target": "str" # Optional. + }, + "errorMessage": "str", # Optional. + "id": "str", # Optional. + "parentId": "str", # Optional. + "pipelineStartTime": "2020-02-20 00:00:00", # Optional. + "queuedTime": "2020-02-20 00:00:00", # Optional. + "resourceId": "str", # Optional. + "runType": "str", # Optional. + "scanLevelType": "str", # Optional. Possible values include: "Full", "Incremental". + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "scanRulesetVersion": 0, # Optional. + "startTime": "2020-02-20 00:00:00", # Optional. + "status": "str" # Optional. + } + ] + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_scan_result_list_scan_history_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.list_scan_history.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_scan_result_list_scan_history_request( + data_source_name=data_source_name, + scan_name=scan_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["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_scan_history.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/runs'} # type: ignore +class ScanRulesetsOperations(object): + """ScanRulesetsOperations 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( + self, + scan_ruleset_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + 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_scan_rulesets_get_request( + scan_ruleset_name=scan_ruleset_name, + 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': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + scan_ruleset_name, # type: str + body=None, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates or Updates a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_name: str + :param body: + :type body: Any + :return: JSON object + :rtype: Any + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + kind = 'AdlsGen1ScanRuleset' or 'AdlsGen2ScanRuleset' or 'AmazonAccountScanRuleset' or 'AmazonPostgreSqlScanRuleset' or 'AmazonS3ScanRuleset' or 'AmazonSqlScanRuleset' or 'AzureCosmosDbScanRuleset' or 'AzureDataExplorerScanRuleset' or 'AzureFileServiceScanRuleset' or 'AzureMySqlScanRuleset' or 'AzurePostgreSqlScanRuleset' or 'AzureResourceGroupScanRuleset' or 'AzureSqlDataWarehouseScanRuleset' or 'AzureSqlDatabaseScanRuleset' or 'AzureSqlDatabaseManagedInstanceScanRuleset' or 'AzureStorageScanRuleset' or 'AzureSubscriptionScanRuleset' or 'AzureSynapseScanRuleset' or 'AzureSynapseWorkspaceScanRuleset' or 'OracleScanRuleset' or 'PowerBIScanRuleset' or 'SapEccScanRuleset' or 'SapS4HanaScanRuleset' or 'SqlServerDatabaseScanRuleset' or 'TeradataScanRuleset' + + # JSON input template you can fill out and use as your body input. + body = { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + 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_scan_rulesets_create_or_update_request( + scan_ruleset_name=scan_ruleset_name, + content_type=content_type, + json=json, + template_url=self.create_or_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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace + def delete( + self, + scan_ruleset_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes a scan ruleset. + + :param scan_ruleset_name: + :type scan_ruleset_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_scan_rulesets_delete_request( + scan_ruleset_name=scan_ruleset_name, + template_url=self.delete.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete.metadata = {'url': '/scanrulesets/{scanRulesetName}'} # type: ignore + + + @distributed_trace + def list_all( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List scan rulesets in Data catalog. + + :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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: ScanRuleset + } + ] + } + """ + 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_scan_rulesets_list_all_request( + 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_scan_rulesets_list_all_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["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_all.metadata = {'url': '/scanrulesets'} # type: ignore +class SystemScanRulesetsOperations(object): + """SystemScanRulesetsOperations 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 all system scan rulesets for an 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() == { + "count": 0.0, # Optional. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + ] + } + """ + 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_system_scan_rulesets_list_all_request( + 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_system_scan_rulesets_list_all_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["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_all.metadata = {'url': '/systemScanRulesets'} # type: ignore + + @distributed_trace + def get( + self, + data_source_type, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a system scan ruleset for a data source. + + :param data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :type data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + 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_system_scan_rulesets_get_request( + data_source_type=data_source_type, + 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': '/systemScanRulesets/datasources/{dataSourceType}'} # type: ignore + + + @distributed_trace + def get_by_version( + self, + version, # type: int + **kwargs # type: Any + ): + # type: (...) -> Any + """Get a scan ruleset by version. + + :param version: + :type version: int + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + data_source_type = kwargs.pop('data_source_type', None) # type: Optional[str] + + + request = build_system_scan_rulesets_get_by_version_request( + version=version, + data_source_type=data_source_type, + template_url=self.get_by_version.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_by_version.metadata = {'url': '/systemScanRulesets/versions/{version}'} # type: ignore + + + @distributed_trace + def get_latest( + self, + **kwargs # type: Any + ): + # type: (...) -> Any + """Get the latest version of a system scan ruleset. + + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Any] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + data_source_type = kwargs.pop('data_source_type', None) # type: Optional[str] + + + request = build_system_scan_rulesets_get_latest_request( + data_source_type=data_source_type, + template_url=self.get_latest.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_latest.metadata = {'url': '/systemScanRulesets/versions/latest'} # type: ignore + + + @distributed_trace + def list_versions_by_data_source( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable[Any] + """List system scan ruleset versions in Data catalog. + + :keyword data_source_type: Possible values are: "None", "AzureSubscription", + "AzureResourceGroup", "AzureSynapseWorkspace", "AzureSynapse", "AdlsGen1", "AdlsGen2", + "AmazonAccount", "AmazonS3", "AmazonSql", "AzureCosmosDb", "AzureDataExplorer", + "AzureFileService", "AzureSqlDatabase", "AmazonPostgreSql", "AzurePostgreSql", + "SqlServerDatabase", "AzureSqlDatabaseManagedInstance", "AzureSqlDataWarehouse", "AzureMySql", + "AzureStorage", "Teradata", "Oracle", "SapS4Hana", "SapEcc", and "PowerBI". + :paramtype data_source_type: 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. + "nextLink": "str", # Optional. + "value": [ + { + "id": "str", # Optional. + "name": "str", # Optional. + "scanRulesetType": "str", # Optional. Possible values include: "Custom", "System". + "status": "str", # Optional. Possible values include: "Enabled", "Disabled". + "version": 0, # Optional. + kind: SystemScanRuleset + } + ] + } + """ + data_source_type = kwargs.pop('data_source_type', 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_system_scan_rulesets_list_versions_by_data_source_request( + data_source_type=data_source_type, + template_url=self.list_versions_by_data_source.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_system_scan_rulesets_list_versions_by_data_source_request( + data_source_type=data_source_type, + 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_versions_by_data_source.metadata = {'url': '/systemScanRulesets/versions'} # type: ignore +class TriggersOperations(object): + """TriggersOperations 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_trigger( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Any + """Gets trigger information. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_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() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + 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_triggers_get_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.get_trigger.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_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + + + @distributed_trace + def create_trigger( + self, + data_source_name, # type: str + scan_name, # type: str + body, # type: Any + **kwargs # type: Any + ): + # type: (...) -> Any + """Creates an instance of a trigger. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :param body: + :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. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + + # response body for status code(s): 200, 201 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + 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 = body + + request = build_triggers_create_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + content_type=content_type, + json=json, + template_url=self.create_trigger.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, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if response.status_code == 201: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + + + @distributed_trace + def delete_trigger( + self, + data_source_name, # type: str + scan_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> Optional[Any] + """Deletes the trigger associated with the scan. + + :param data_source_name: + :type data_source_name: str + :param scan_name: + :type scan_name: str + :return: JSON object + :rtype: Any or None + :raises: ~azure.core.exceptions.HttpResponseError + + Example: + .. code-block:: python + + # response body for status code(s): 200 + response.json() == { + "id": "str", # Optional. + "name": "str", # Optional. + "properties": { + "createdAt": "2020-02-20 00:00:00", # Optional. + "incrementalScanStartTime": "2020-02-20 00:00:00", # Optional. + "lastModifiedAt": "2020-02-20 00:00:00", # Optional. + "lastScheduled": "2020-02-20 00:00:00", # Optional. + "recurrence": { + "endTime": "2020-02-20 00:00:00", # Optional. + "frequency": "str", # Optional. Possible values include: "Week", "Month". + "interval": 0, # Optional. + "schedule": { + "hours": [ + 0 # Optional. + ], + "minutes": [ + 0 # Optional. + ], + "monthDays": [ + 0 # Optional. + ], + "monthlyOccurrences": [ + { + "day": "str", # Optional. Possible values include: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday". + "occurrence": 0 # Optional. + } + ], + "weekDays": [ + "str" # Optional. + ] + }, + "startTime": "2020-02-20 00:00:00", # Optional. + "timeZone": "str" # Optional. + }, + "recurrenceInterval": "str", # Optional. + "scanLevel": "str" # Optional. Possible values include: "Full", "Incremental". + } + } + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional[Any]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_triggers_delete_trigger_request( + data_source_name=data_source_name, + scan_name=scan_name, + template_url=self.delete_trigger.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) + + deserialized = None + if response.status_code == 200: + if response.content: + deserialized = response.json() + else: + deserialized = None + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + delete_trigger.metadata = {'url': '/datasources/{dataSourceName}/scans/{scanName}/triggers/default'} # type: ignore + diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/__init__.py deleted file mode 100644 index 9b505e8d1b80..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_create_or_update_request - from ._request_builders_py3 import build_delete_request - from ._request_builders_py3 import build_list_all_request - from ._request_builders_py3 import build_list_versions_by_classification_rule_name_request - from ._request_builders_py3 import build_tag_classification_version_request -except (SyntaxError, ImportError): - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_create_or_update_request # type: ignore - from ._request_builders import build_delete_request # type: ignore - from ._request_builders import build_list_all_request # type: ignore - from ._request_builders import build_list_versions_by_classification_rule_name_request # type: ignore - from ._request_builders import build_tag_classification_version_request # type: ignore - -__all__ = [ - 'build_get_request', - 'build_create_or_update_request', - 'build_delete_request', - 'build_list_all_request', - 'build_list_versions_by_classification_rule_name_request', - 'build_tag_classification_version_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders.py deleted file mode 100644 index dd544e15d599..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders.py +++ /dev/null @@ -1,364 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_get_request( - classification_rule_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ClassificationRule" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - classification_rule_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates or Updates a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'CustomClassificationRule' or 'SystemClassificationRule' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "ClassificationRule" - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "ClassificationRule" - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_delete_request( - classification_rule_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ClassificationRule" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List classification rules in Account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ClassificationRule" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules') - - # 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_list_versions_by_classification_rule_name_request( - classification_rule_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Lists the rule versions of a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ClassificationRule" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_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_tag_classification_version_request( - classification_rule_name, # type: str - classification_rule_version, # type: int - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Sets Classification Action on a specific classification rule version. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :param classification_rule_version: - :type classification_rule_version: int - :keyword action: - :paramtype action: str or ~azure.purview.scanning.models.ClassificationAction - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - action = kwargs.pop('action') # type: Union[str, "_models.ClassificationAction"] - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - 'classificationRuleVersion': _SERIALIZER.url("classification_rule_version", classification_rule_version, 'int'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['action'] = _SERIALIZER.query("action", action, '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="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders_py3.py deleted file mode 100644 index 0b3e2be5c4cd..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders_py3.py +++ /dev/null @@ -1,364 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_get_request( - classification_rule_name: str, - **kwargs: Any -) -> HttpRequest: - """Get a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ClassificationRule" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - classification_rule_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates or Updates a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'CustomClassificationRule' or 'SystemClassificationRule' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "ClassificationRule" - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "ClassificationRule" - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - classification_rule_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ClassificationRule" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs: Any -) -> HttpRequest: - """List classification rules in Account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ClassificationRule" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules') - - # 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_list_versions_by_classification_rule_name_request( - classification_rule_name: str, - **kwargs: Any -) -> HttpRequest: - """Lists the rule versions of a classification rule. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ClassificationRule" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_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_tag_classification_version_request( - classification_rule_name: str, - classification_rule_version: int, - *, - action: Union[str, "_models.ClassificationAction"], - **kwargs: Any -) -> HttpRequest: - """Sets Classification Action on a specific classification rule version. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param classification_rule_name: - :type classification_rule_name: str - :param classification_rule_version: - :type classification_rule_version: int - :keyword action: - :paramtype action: str or ~azure.purview.scanning.models.ClassificationAction - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/classificationrules/{classificationRuleName}/versions/{classificationRuleVersion}/:tag') - path_format_arguments = { - 'classificationRuleName': _SERIALIZER.url("classification_rule_name", classification_rule_name, 'str'), - 'classificationRuleVersion': _SERIALIZER.url("classification_rule_version", classification_rule_version, 'int'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['action'] = _SERIALIZER.query("action", action, '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="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/__init__.py deleted file mode 100644 index 576da9d1455a..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_create_or_update_request - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_delete_request - from ._request_builders_py3 import build_list_all_request -except (SyntaxError, ImportError): - from ._request_builders import build_create_or_update_request # type: ignore - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_delete_request # type: ignore - from ._request_builders import build_list_all_request # type: ignore - -__all__ = [ - 'build_create_or_update_request', - 'build_get_request', - 'build_delete_request', - 'build_list_all_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders.py deleted file mode 100644 index 7c532b1fe77d..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders.py +++ /dev/null @@ -1,377 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_create_or_update_request( - data_source_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates or Updates a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1DataSource' or 'AdlsGen2DataSource' or 'AmazonAccountDataSource' or 'AmazonPostgreSqlDataSource' or 'AmazonS3DataSource' or 'AmazonSqlDataSource' or 'AzureCosmosDbDataSource' or 'AzureDataExplorerDataSource' or 'AzureFileServiceDataSource' or 'AzureMySqlDataSource' or 'AzurePostgreSqlDataSource' or 'AzureResourceGroupDataSource' or 'AzureSqlDataWarehouseDataSource' or 'AzureSqlDatabaseDataSource' or 'AzureSqlDatabaseManagedInstanceDataSource' or 'AzureStorageDataSource' or 'AzureSubscriptionDataSource' or 'AzureSynapseDataSource' or 'AzureSynapseWorkspaceDataSource' or 'OracleDataSource' or 'PowerBIDataSource' or 'SapEccDataSource' or 'SapS4HanaDataSource' or 'SqlServerDatabaseDataSource' or 'TeradataDataSource' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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_get_request( - data_source_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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_delete_request( - data_source_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List data sources in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders_py3.py deleted file mode 100644 index 15987479ae3c..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders_py3.py +++ /dev/null @@ -1,378 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_create_or_update_request( - data_source_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates or Updates a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1DataSource' or 'AdlsGen2DataSource' or 'AmazonAccountDataSource' or 'AmazonPostgreSqlDataSource' or 'AmazonS3DataSource' or 'AmazonSqlDataSource' or 'AzureCosmosDbDataSource' or 'AzureDataExplorerDataSource' or 'AzureFileServiceDataSource' or 'AzureMySqlDataSource' or 'AzurePostgreSqlDataSource' or 'AzureResourceGroupDataSource' or 'AzureSqlDataWarehouseDataSource' or 'AzureSqlDatabaseDataSource' or 'AzureSqlDatabaseManagedInstanceDataSource' or 'AzureStorageDataSource' or 'AzureSubscriptionDataSource' or 'AzureSynapseDataSource' or 'AzureSynapseWorkspaceDataSource' or 'OracleDataSource' or 'PowerBIDataSource' or 'SapEccDataSource' or 'SapS4HanaDataSource' or 'SqlServerDatabaseDataSource' or 'TeradataDataSource' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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, - json=json, - content=content, - **kwargs - ) - - -def build_get_request( - data_source_name: str, - **kwargs: Any -) -> HttpRequest: - """Get a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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_delete_request( - data_source_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs: Any -) -> HttpRequest: - """List data sources in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "DataSource", - "scans": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/__init__.py deleted file mode 100644 index 38dd8728ec1f..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_create_or_update_request -except (SyntaxError, ImportError): - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_create_or_update_request # type: ignore - -__all__ = [ - 'build_get_request', - 'build_create_or_update_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders.py deleted file mode 100644 index 1ec646686332..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders.py +++ /dev/null @@ -1,144 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_get_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a filter. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates or updates a filter. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200, 201 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders_py3.py deleted file mode 100644 index 8317ea32b952..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders_py3.py +++ /dev/null @@ -1,147 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_get_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Get a filter. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - data_source_name: str, - scan_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates or updates a filter. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200, 201 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/filters/custom') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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, - json=json, - content=content, - **kwargs - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/__init__.py deleted file mode 100644 index f320f0045505..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_create_request - from ._request_builders_py3 import build_delete_request - from ._request_builders_py3 import build_list_all_request -except (SyntaxError, ImportError): - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_create_request # type: ignore - from ._request_builders import build_delete_request # type: ignore - from ._request_builders import build_list_all_request # type: ignore - -__all__ = [ - 'build_get_request', - 'build_create_request', - 'build_delete_request', - 'build_list_all_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders.py deleted file mode 100644 index 507b22bb3839..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders.py +++ /dev/null @@ -1,239 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_get_request( - key_vault_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Gets key vault information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_request( - key_vault_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates an instance of a key vault connection. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_delete_request( - key_vault_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes the key vault connection associated with the account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List key vault connections in account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "properties": {} - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders_py3.py deleted file mode 100644 index bc70ecade024..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/key_vault_connections/_request_builders_py3.py +++ /dev/null @@ -1,240 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_get_request( - key_vault_name: str, - **kwargs: Any -) -> HttpRequest: - """Gets key vault information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_request( - key_vault_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates an instance of a key vault connection. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - key_vault_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes the key vault connection associated with the account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param key_vault_name: - :type key_vault_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults/{keyVaultName}') - path_format_arguments = { - 'keyVaultName': _SERIALIZER.url("key_vault_name", key_vault_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs: Any -) -> HttpRequest: - """List key vault connections in account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "properties": {} - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/azureKeyVaults') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/__init__.py deleted file mode 100644 index 443945e2809f..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_run_scan_request - from ._request_builders_py3 import build_cancel_scan_request - from ._request_builders_py3 import build_list_scan_history_request -except (SyntaxError, ImportError): - from ._request_builders import build_run_scan_request # type: ignore - from ._request_builders import build_cancel_scan_request # type: ignore - from ._request_builders import build_list_scan_history_request # type: ignore - -__all__ = [ - 'build_run_scan_request', - 'build_cancel_scan_request', - 'build_list_scan_history_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders.py deleted file mode 100644 index 351c783cf8f4..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders.py +++ /dev/null @@ -1,231 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_run_scan_request( - data_source_name, # type: str - scan_name, # type: str - run_id, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Runs the scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :param run_id: - :type run_id: str - :keyword scan_level: - :paramtype scan_level: str or ~azure.purview.scanning.models.ScanLevelType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - scan_level = kwargs.pop('scan_level', None) # type: Optional[Union[str, "_models.ScanLevelType"]] - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - 'runId': _SERIALIZER.url("run_id", run_id, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if scan_level is not None: - query_parameters['scanLevel'] = _SERIALIZER.query("scan_level", scan_level, '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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_cancel_scan_request( - data_source_name, # type: str - scan_name, # type: str - run_id, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Cancels a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :param run_id: - :type run_id: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - 'runId': _SERIALIZER.url("run_id", run_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="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_scan_history_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Lists the scan history of a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders_py3.py deleted file mode 100644 index 178ef20f39e9..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_result/_request_builders_py3.py +++ /dev/null @@ -1,229 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_run_scan_request( - data_source_name: str, - scan_name: str, - run_id: str, - *, - scan_level: Optional[Union[str, "_models.ScanLevelType"]] = None, - **kwargs: Any -) -> HttpRequest: - """Runs the scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :param run_id: - :type run_id: str - :keyword scan_level: - :paramtype scan_level: str or ~azure.purview.scanning.models.ScanLevelType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - 'runId': _SERIALIZER.url("run_id", run_id, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if scan_level is not None: - query_parameters['scanLevel'] = _SERIALIZER.query("scan_level", scan_level, '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="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_cancel_scan_request( - data_source_name: str, - scan_name: str, - run_id: str, - **kwargs: Any -) -> HttpRequest: - """Cancels a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :param run_id: - :type run_id: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 202 - response_body == { - "endTime": "datetime (optional)", - "error": {}, - "scanResultId": "str (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs/{runId}/:cancel') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - 'runId': _SERIALIZER.url("run_id", run_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="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_scan_history_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Lists the scan history of a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/runs') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/__init__.py deleted file mode 100644 index ca87846e92d6..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_create_or_update_request - from ._request_builders_py3 import build_delete_request - from ._request_builders_py3 import build_list_all_request -except (SyntaxError, ImportError): - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_create_or_update_request # type: ignore - from ._request_builders import build_delete_request # type: ignore - from ._request_builders import build_list_all_request # type: ignore - -__all__ = [ - 'build_get_request', - 'build_create_or_update_request', - 'build_delete_request', - 'build_list_all_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders.py deleted file mode 100644 index e18cd6759548..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders.py +++ /dev/null @@ -1,242 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_get_request( - scan_ruleset_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - scan_ruleset_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates or Updates a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1ScanRuleset' or 'AdlsGen2ScanRuleset' or 'AmazonAccountScanRuleset' or 'AmazonPostgreSqlScanRuleset' or 'AmazonS3ScanRuleset' or 'AmazonSqlScanRuleset' or 'AzureCosmosDbScanRuleset' or 'AzureDataExplorerScanRuleset' or 'AzureFileServiceScanRuleset' or 'AzureMySqlScanRuleset' or 'AzurePostgreSqlScanRuleset' or 'AzureResourceGroupScanRuleset' or 'AzureSqlDataWarehouseScanRuleset' or 'AzureSqlDatabaseScanRuleset' or 'AzureSqlDatabaseManagedInstanceScanRuleset' or 'AzureStorageScanRuleset' or 'AzureSubscriptionScanRuleset' or 'AzureSynapseScanRuleset' or 'AzureSynapseWorkspaceScanRuleset' or 'OracleScanRuleset' or 'PowerBIScanRuleset' or 'SapEccScanRuleset' or 'SapS4HanaScanRuleset' or 'SqlServerDatabaseScanRuleset' or 'TeradataScanRuleset' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "ScanRuleset" - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "ScanRuleset" - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_delete_request( - scan_ruleset_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List scan rulesets in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ScanRuleset" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders_py3.py deleted file mode 100644 index 798a196c4d79..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders_py3.py +++ /dev/null @@ -1,243 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_get_request( - scan_ruleset_name: str, - **kwargs: Any -) -> HttpRequest: - """Get a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request( - scan_ruleset_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates or Updates a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1ScanRuleset' or 'AdlsGen2ScanRuleset' or 'AmazonAccountScanRuleset' or 'AmazonPostgreSqlScanRuleset' or 'AmazonS3ScanRuleset' or 'AmazonSqlScanRuleset' or 'AzureCosmosDbScanRuleset' or 'AzureDataExplorerScanRuleset' or 'AzureFileServiceScanRuleset' or 'AzureMySqlScanRuleset' or 'AzurePostgreSqlScanRuleset' or 'AzureResourceGroupScanRuleset' or 'AzureSqlDataWarehouseScanRuleset' or 'AzureSqlDatabaseScanRuleset' or 'AzureSqlDatabaseManagedInstanceScanRuleset' or 'AzureStorageScanRuleset' or 'AzureSubscriptionScanRuleset' or 'AzureSynapseScanRuleset' or 'AzureSynapseWorkspaceScanRuleset' or 'OracleScanRuleset' or 'PowerBIScanRuleset' or 'SapEccScanRuleset' or 'SapS4HanaScanRuleset' or 'SqlServerDatabaseScanRuleset' or 'TeradataScanRuleset' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "ScanRuleset" - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "ScanRuleset" - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request( - scan_ruleset_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes a scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param scan_ruleset_name: - :type scan_ruleset_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "ScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets/{scanRulesetName}') - path_format_arguments = { - 'scanRulesetName': _SERIALIZER.url("scan_ruleset_name", scan_ruleset_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_all_request( - **kwargs: Any -) -> HttpRequest: - """List scan rulesets in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "ScanRuleset" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/scanrulesets') - - # 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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/__init__.py deleted file mode 100644 index 94d392cc69b7..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_create_or_update_request - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_delete_request - from ._request_builders_py3 import build_list_by_data_source_request -except (SyntaxError, ImportError): - from ._request_builders import build_create_or_update_request # type: ignore - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_delete_request # type: ignore - from ._request_builders import build_list_by_data_source_request # type: ignore - -__all__ = [ - 'build_create_or_update_request', - 'build_get_request', - 'build_delete_request', - 'build_list_by_data_source_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders.py deleted file mode 100644 index fb18dbf1aebd..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders.py +++ /dev/null @@ -1,371 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_create_or_update_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates an instance of a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1CredentialScan' or 'AdlsGen1MsiScan' or 'AdlsGen2CredentialScan' or 'AdlsGen2MsiScan' or 'AmazonAccountCredentialScan' or 'AmazonPostgreSqlCredentialScan' or 'AmazonS3CredentialScan' or 'AmazonS3RoleARNScan' or 'AmazonSqlCredentialScan' or 'AzureCosmosDbCredentialScan' or 'AzureDataExplorerCredentialScan' or 'AzureDataExplorerMsiScan' or 'AzureFileServiceCredentialScan' or 'AzureMySqlCredentialScan' or 'AzurePostgreSqlCredentialScan' or 'AzureResourceGroupCredentialScan' or 'AzureResourceGroupMsiScan' or 'AzureSqlDataWarehouseCredentialScan' or 'AzureSqlDataWarehouseMsiScan' or 'AzureSqlDatabaseCredentialScan' or 'AzureSqlDatabaseManagedInstanceCredentialScan' or 'AzureSqlDatabaseManagedInstanceMsiScan' or 'AzureSqlDatabaseMsiScan' or 'AzureStorageCredentialScan' or 'AzureStorageMsiScan' or 'AzureSubscriptionCredentialScan' or 'AzureSubscriptionMsiScan' or 'AzureSynapseCredentialScan' or 'AzureSynapseMsiScan' or 'AzureSynapseWorkspaceCredentialScan' or 'AzureSynapseWorkspaceMsiScan' or 'OracleCredentialScan' or 'OracleUserPassScan' or 'PowerBIDelegatedScan' or 'PowerBIMsiScan' or 'SapEccCredentialScan' or 'SapEccUserPassScan' or 'SapS4HanaSapS4HanaCredentialScan' or 'SapS4HanaSapS4HanaUserPassScan' or 'SqlServerDatabaseCredentialScan' or 'TeradataCredentialScan' or 'TeradataUserPassScanAutoGenerated' or 'TeradataUserPassScan' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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_get_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Gets a scan information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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_delete_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes the scan associated with the data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_by_data_source_request( - data_source_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List scans in data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders_py3.py deleted file mode 100644 index 2ab8551f3bf9..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders_py3.py +++ /dev/null @@ -1,372 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_create_or_update_request( - data_source_name: str, - scan_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates an instance of a scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # kind template as part of your input body - kind = 'AdlsGen1CredentialScan' or 'AdlsGen1MsiScan' or 'AdlsGen2CredentialScan' or 'AdlsGen2MsiScan' or 'AmazonAccountCredentialScan' or 'AmazonPostgreSqlCredentialScan' or 'AmazonS3CredentialScan' or 'AmazonS3RoleARNScan' or 'AmazonSqlCredentialScan' or 'AzureCosmosDbCredentialScan' or 'AzureDataExplorerCredentialScan' or 'AzureDataExplorerMsiScan' or 'AzureFileServiceCredentialScan' or 'AzureMySqlCredentialScan' or 'AzurePostgreSqlCredentialScan' or 'AzureResourceGroupCredentialScan' or 'AzureResourceGroupMsiScan' or 'AzureSqlDataWarehouseCredentialScan' or 'AzureSqlDataWarehouseMsiScan' or 'AzureSqlDatabaseCredentialScan' or 'AzureSqlDatabaseManagedInstanceCredentialScan' or 'AzureSqlDatabaseManagedInstanceMsiScan' or 'AzureSqlDatabaseMsiScan' or 'AzureStorageCredentialScan' or 'AzureStorageMsiScan' or 'AzureSubscriptionCredentialScan' or 'AzureSubscriptionMsiScan' or 'AzureSynapseCredentialScan' or 'AzureSynapseMsiScan' or 'AzureSynapseWorkspaceCredentialScan' or 'AzureSynapseWorkspaceMsiScan' or 'OracleCredentialScan' or 'OracleUserPassScan' or 'PowerBIDelegatedScan' or 'PowerBIMsiScan' or 'SapEccCredentialScan' or 'SapEccUserPassScan' or 'SapS4HanaSapS4HanaCredentialScan' or 'SapS4HanaSapS4HanaUserPassScan' or 'SqlServerDatabaseCredentialScan' or 'TeradataCredentialScan' or 'TeradataUserPassScanAutoGenerated' or 'TeradataUserPassScan' - - # JSON input template you can fill out and use as your `json` input. - json = { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - - # response body for status code(s): 200, 201 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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, - json=json, - content=content, - **kwargs - ) - - -def build_get_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Gets a scan information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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_delete_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes the scan associated with the data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_by_data_source_request( - data_source_name: str, - **kwargs: Any -) -> HttpRequest: - """List scans in data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "Scan", - "scanResults": [ - { - "assetsClassified": "long (optional)", - "assetsDiscovered": "long (optional)", - "dataSourceType": "str (optional)", - "diagnostics": {}, - "endTime": "datetime (optional)", - "error": {}, - "errorMessage": "str (optional)", - "id": "str (optional)", - "parentId": "str (optional)", - "pipelineStartTime": "datetime (optional)", - "queuedTime": "datetime (optional)", - "resourceId": "str (optional)", - "runType": "str (optional)", - "scanLevelType": "str (optional)", - "scanRulesetType": "str (optional)", - "scanRulesetVersion": "int (optional)", - "startTime": "datetime (optional)", - "status": "str (optional)" - } - ] - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/__init__.py deleted file mode 100644 index 44a087ac8ed4..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_list_all_request - from ._request_builders_py3 import build_get_request - from ._request_builders_py3 import build_get_by_version_request - from ._request_builders_py3 import build_get_latest_request - from ._request_builders_py3 import build_list_versions_by_data_source_request -except (SyntaxError, ImportError): - from ._request_builders import build_list_all_request # type: ignore - from ._request_builders import build_get_request # type: ignore - from ._request_builders import build_get_by_version_request # type: ignore - from ._request_builders import build_get_latest_request # type: ignore - from ._request_builders import build_list_versions_by_data_source_request # type: ignore - -__all__ = [ - 'build_list_all_request', - 'build_get_request', - 'build_get_by_version_request', - 'build_get_latest_request', - 'build_list_versions_by_data_source_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders.py deleted file mode 100644 index 9e309fef1cf2..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders.py +++ /dev/null @@ -1,285 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_list_all_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List all system scan rulesets for an account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "SystemScanRuleset" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets') - - # 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_get_request( - data_source_type, # type: Union[str, "_models.DataSourceType"] - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a system scan ruleset for a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_type: - :type data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/datasources/{dataSourceType}') - path_format_arguments = { - 'dataSourceType': _SERIALIZER.url("data_source_type", data_source_type, '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_get_by_version_request( - version, # type: int - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get a scan ruleset by version. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param version: - :type version: int - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - data_source_type = kwargs.pop('data_source_type', None) # type: Optional[Union[str, "_models.DataSourceType"]] - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions/{version}') - path_format_arguments = { - 'version': _SERIALIZER.url("version", version, 'int'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_get_latest_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Get the latest version of a system scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - data_source_type = kwargs.pop('data_source_type', None) # type: Optional[Union[str, "_models.DataSourceType"]] - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions/latest') - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_list_versions_by_data_source_request( - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """List system scan ruleset versions in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "SystemScanRuleset" - } - ] - } - - """ - data_source_type = kwargs.pop('data_source_type', None) # type: Optional[Union[str, "_models.DataSourceType"]] - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions') - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders_py3.py deleted file mode 100644 index c2549983a5a6..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/system_scan_rulesets/_request_builders_py3.py +++ /dev/null @@ -1,283 +0,0 @@ -# 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, Optional, TYPE_CHECKING, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - -_SERIALIZER = Serializer() - - -def build_list_all_request( - **kwargs: Any -) -> HttpRequest: - """List all system scan rulesets for an account. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "SystemScanRuleset" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets') - - # 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_get_request( - data_source_type: Union[str, "_models.DataSourceType"], - **kwargs: Any -) -> HttpRequest: - """Get a system scan ruleset for a data source. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_type: - :type data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/datasources/{dataSourceType}') - path_format_arguments = { - 'dataSourceType': _SERIALIZER.url("data_source_type", data_source_type, '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_get_by_version_request( - version: int, - *, - data_source_type: Optional[Union[str, "_models.DataSourceType"]] = None, - **kwargs: Any -) -> HttpRequest: - """Get a scan ruleset by version. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param version: - :type version: int - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions/{version}') - path_format_arguments = { - 'version': _SERIALIZER.url("version", version, 'int'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_get_latest_request( - *, - data_source_type: Optional[Union[str, "_models.DataSourceType"]] = None, - **kwargs: Any -) -> HttpRequest: - """Get the latest version of a system scan ruleset. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "kind": "SystemScanRuleset" - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions/latest') - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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_list_versions_by_data_source_request( - *, - data_source_type: Optional[Union[str, "_models.DataSourceType"]] = None, - **kwargs: Any -) -> HttpRequest: - """List system scan ruleset versions in Data catalog. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :keyword data_source_type: - :paramtype data_source_type: str or ~azure.purview.scanning.models.DataSourceType - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "count": "long (optional)", - "nextLink": "str (optional)", - "value": [ - { - "kind": "SystemScanRuleset" - } - ] - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/systemScanRulesets/versions') - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - if data_source_type is not None: - query_parameters['dataSourceType'] = _SERIALIZER.query("data_source_type", data_source_type, '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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/__init__.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/__init__.py deleted file mode 100644 index 2f277b6913db..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -try: - from ._request_builders_py3 import build_get_trigger_request - from ._request_builders_py3 import build_create_trigger_request - from ._request_builders_py3 import build_delete_trigger_request -except (SyntaxError, ImportError): - from ._request_builders import build_get_trigger_request # type: ignore - from ._request_builders import build_create_trigger_request # type: ignore - from ._request_builders import build_delete_trigger_request # type: ignore - -__all__ = [ - 'build_get_trigger_request', - 'build_create_trigger_request', - 'build_delete_trigger_request', -] diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders.py deleted file mode 100644 index 0069ca0e78a3..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders.py +++ /dev/null @@ -1,200 +0,0 @@ -# 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.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional, Union - -_SERIALIZER = Serializer() - - -def build_get_trigger_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Gets trigger information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_trigger_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Creates an instance of a trigger. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200, 201 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_delete_trigger_request( - data_source_name, # type: str - scan_name, # type: str - **kwargs # type: Any -): - # type: (...) -> HttpRequest - """Deletes the trigger associated with the scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders_py3.py b/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders_py3.py deleted file mode 100644 index c7e4584a5479..000000000000 --- a/sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders_py3.py +++ /dev/null @@ -1,198 +0,0 @@ -# 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, Optional, Union - -from azure.core.pipeline.transport._base import _format_url_section -from azure.purview.scanning.core.rest import HttpRequest -from msrest import Serializer - -_SERIALIZER = Serializer() - - -def build_get_trigger_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Gets trigger information. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_name, 'str'), - } - url = _format_url_section(url, **path_format_arguments) - - # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_trigger_request( - data_source_name: str, - scan_name: str, - *, - json: Any = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - """Creates an instance of a trigger. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :keyword json: - :paramtype json: Any - :keyword content: - :paramtype content: Any - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # JSON input template you can fill out and use as your `json` input. - json = { - "properties": {} - } - - - # response body for status code(s): 200, 201 - response_body == { - "properties": {} - } - - """ - content_type = kwargs.pop("content_type", None) - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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, - json=json, - content=content, - **kwargs - ) - - -def build_delete_trigger_request( - data_source_name: str, - scan_name: str, - **kwargs: Any -) -> HttpRequest: - """Deletes the trigger associated with the scan. - - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this request builder into your code flow. - - :param data_source_name: - :type data_source_name: str - :param scan_name: - :type scan_name: str - :return: Returns an :class:`~azure.purview.scanning.core.rest.HttpRequest` that you will pass to the client's `send_request` method. - See https://aka.ms/azsdk/python/protocol/quickstart for how to incorporate this response into your code flow. - :rtype: ~azure.purview.scanning.core.rest.HttpRequest - - Example: - .. code-block:: python - - - # response body for status code(s): 200 - response_body == { - "properties": {} - } - - """ - api_version = "2018-12-01-preview" - accept = "application/json" - - # Construct URL - url = kwargs.pop("template_url", '/datasources/{dataSourceName}/scans/{scanName}/triggers/default') - path_format_arguments = { - 'dataSourceName': _SERIALIZER.url("data_source_name", data_source_name, 'str'), - 'scanName': _SERIALIZER.url("scan_name", scan_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 - ) - diff --git a/sdk/purview/azure-purview-scanning/setup.py b/sdk/purview/azure-purview-scanning/setup.py index ee79850a9729..b0c6a88eadf9 100644 --- a/sdk/purview/azure-purview-scanning/setup.py +++ b/sdk/purview/azure-purview-scanning/setup.py @@ -78,7 +78,7 @@ 'azure.purview', ]), install_requires=[ - "azure-core<2.0.0,>=1.8.2", + "azure-core<2.0.0,>=1.18.0", "msrest>=0.6.21", 'six>=1.11.0', ], diff --git a/sdk/purview/azure-purview-scanning/swagger/README.md b/sdk/purview/azure-purview-scanning/swagger/README.md index 861a1a812de5..07e360e17568 100644 --- a/sdk/purview/azure-purview-scanning/swagger/README.md +++ b/sdk/purview/azure-purview-scanning/swagger/README.md @@ -29,9 +29,13 @@ clear-output-folder: true no-namespace-folders: true python: true title: PurviewScanningClient -low-level-client: true -vendor: true -package-version: 1.0.0b1 +version-tolerant: true +package-version: 1.0.0b2 add-credential: true credential-scopes: https://purview.azure.net/.default ``` + +``` yaml +modelerfour: + lenient-model-deduplication: true +``` \ No newline at end of file diff --git a/sdk/purview/azure-purview-scanning/tests/_util.py b/sdk/purview/azure-purview-scanning/tests/_util.py new file mode 100644 index 000000000000..50ee62f8e5d7 --- /dev/null +++ b/sdk/purview/azure-purview-scanning/tests/_util.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. +# -------------------------------------------------------------------------- +from azure_devtools.scenario_tests import RecordingProcessor +import json + + +class PurviewScanningRecordingProcessor(RecordingProcessor): + def process_response(self, response): + try: + body = json.loads(response["body"]["string"]) + for value in body["value"]: + value["properties"]["subscriptionId"] = "000" + response["body"]["string"] = json.dumps(body) + finally: + return response diff --git a/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke.test_basic_smoke_test.yaml index e7d37aa5f319..b156f46f45a3 100644 --- a/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke.test_basic_smoke_test.yaml +++ b/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke.test_basic_smoke_test.yaml @@ -9,19 +9,27 @@ interactions: Connection: - keep-alive User-Agent: - - azsdk-python-purview-scanning/1.0.0b1 Python/3.9.1 (macOS-10.16-x86_64-i386-64bit) + - azsdk-python-purview-scanning/1.0.0b2 Python/3.7.3 (Windows-10-10.0.19041-SP0) method: GET uri: https://fake_account.scan.purview.azure.com/datasources?api-version=2018-12-01-preview response: body: - string: '{"value":[{"properties":{"createdAt":"2021-04-01T19:18:25.6411232Z","lastModifiedAt":"2021-04-01T19:18:25.6411233Z","parentCollection":null},"kind":"Collection","id":"datasources/Collection-vaR","name":"Collection-vaR"},{"properties":{"endpoint":"https://joherediteststorage.blob.core.windows.net/","resourceGroup":"joheredi-test","subscriptionId":"faa080af-c1d8-40ad-9cce-e1a450ca5b57","location":"westus","resourceName":"joherediteststorage","createdAt":"2021-04-01T19:19:37.3396977Z","lastModifiedAt":"2021-04-01T19:19:37.3396984Z","parentCollection":{"type":"DataSourceReference","referenceName":"Collection-vaR"}},"kind":"AzureStorage","id":"datasources/AzureBlob-BzV","name":"AzureBlob-BzV"}],"count":2}' + string: '{"value": [{"properties": {"endpoint": "https://storageyyc.blob.core.windows.net/", + "resourceGroup": "python-sdk-test", "subscriptionId": "000", "location": "westus", + "resourceName": "storageyyc", "createdAt": "2021-09-29T03:35:39.2638722Z", + "lastModifiedAt": "2021-09-29T03:35:39.2638722Z", "parentCollection": null, + "collection": {"lastModifiedAt": "2021-09-29T03:35:39.2638722Z", "referenceName": + "purview-msyyc", "type": "CollectionReference"}}, "kind": "AzureStorage", + "id": "datasources/storageyyc", "name": "storageyyc"}], "count": 1}' headers: content-length: - - '709' + - '542' content-type: - application/json; charset=utf-8 date: - - Tue, 20 Apr 2021 21:11:57 GMT + - Wed, 29 Sep 2021 04:49:26 GMT + request-context: + - appId=cid-v1:caaf2286-a721-4ba8-a2bd-9a1b7993b4fd server: - Kestrel strict-transport-security: diff --git a/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml b/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml index 19ddb9e72634..b98e6e82b192 100644 --- a/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml +++ b/sdk/purview/azure-purview-scanning/tests/recordings/test_smoke_async.test_basic_smoke_test.yaml @@ -5,20 +5,27 @@ interactions: Accept: - application/json User-Agent: - - azsdk-python-purview-scanning/1.0.0b1 Python/3.9.1 (macOS-10.16-x86_64-i386-64bit) + - azsdk-python-purview-scanning/1.0.0b2 Python/3.7.3 (Windows-10-10.0.19041-SP0) method: GET uri: https://fake_account.scan.purview.azure.com/datasources?api-version=2018-12-01-preview response: body: - string: '{"value":[{"properties":{"createdAt":"2021-04-01T19:18:25.6411232Z","lastModifiedAt":"2021-04-01T19:18:25.6411233Z","parentCollection":null},"kind":"Collection","id":"datasources/Collection-vaR","name":"Collection-vaR"},{"properties":{"endpoint":"https://joherediteststorage.blob.core.windows.net/","resourceGroup":"joheredi-test","subscriptionId":"faa080af-c1d8-40ad-9cce-e1a450ca5b57","location":"westus","resourceName":"joherediteststorage","createdAt":"2021-04-01T19:19:37.3396977Z","lastModifiedAt":"2021-04-01T19:19:37.3396984Z","parentCollection":{"type":"DataSourceReference","referenceName":"Collection-vaR"}},"kind":"AzureStorage","id":"datasources/AzureBlob-BzV","name":"AzureBlob-BzV"}],"count":2}' + string: '{"value": [{"properties": {"endpoint": "https://storageyyc.blob.core.windows.net/", + "resourceGroup": "python-sdk-test", "subscriptionId": "000", "location": "westus", + "resourceName": "storageyyc", "createdAt": "2021-09-29T03:35:39.2638722Z", + "lastModifiedAt": "2021-09-29T03:35:39.2638722Z", "parentCollection": null, + "collection": {"lastModifiedAt": "2021-09-29T03:35:39.2638722Z", "referenceName": + "purview-msyyc", "type": "CollectionReference"}}, "kind": "AzureStorage", + "id": "datasources/storageyyc", "name": "storageyyc"}], "count": 1}' headers: - content-length: '709' + content-length: '542' content-type: application/json; charset=utf-8 - date: Tue, 20 Apr 2021 21:11:57 GMT + date: Wed, 29 Sep 2021 04:50:29 GMT + request-context: appId=cid-v1:caaf2286-a721-4ba8-a2bd-9a1b7993b4fd server: Kestrel strict-transport-security: max-age=31536000; includeSubDomains status: code: 200 message: OK - url: https://llcpurview.scan.purview.azure.com/datasources?api-version=2018-12-01-preview + url: https://purview-msyyc.scan.purview.azure.com/datasources?api-version=2018-12-01-preview version: 1 diff --git a/sdk/purview/azure-purview-scanning/tests/test_smoke.py b/sdk/purview/azure-purview-scanning/tests/test_smoke.py index a67a99902e8c..ed98c3344d81 100644 --- a/sdk/purview/azure-purview-scanning/tests/test_smoke.py +++ b/sdk/purview/azure-purview-scanning/tests/test_smoke.py @@ -5,17 +5,14 @@ # license information. # ------------------------------------------------------------------------- from testcase import PurviewScanningTest, PurviewScanningPowerShellPreparer -from azure.purview.scanning.rest import data_sources +from _util import PurviewScanningRecordingProcessor class PurviewScanningSmokeTest(PurviewScanningTest): @PurviewScanningPowerShellPreparer() def test_basic_smoke_test(self, purviewscanning_endpoint): + self.recording_processors.append(PurviewScanningRecordingProcessor()) client = self.create_client(endpoint=purviewscanning_endpoint) - request = data_sources.build_list_all_request() - response = client.send_request(request) - response.raise_for_status() - assert response.status_code == 200 - json_response = response.json() - assert set(json_response.keys()) == set(['value', 'count']) - assert len(json_response['value']) == json_response['count'] + response = client.data_sources.list_all() + result = [item for item in response] + assert len(result) >= 1 diff --git a/sdk/purview/azure-purview-scanning/tests/test_smoke_async.py b/sdk/purview/azure-purview-scanning/tests/test_smoke_async.py index b9eb4f29b1a5..3798d26df16f 100644 --- a/sdk/purview/azure-purview-scanning/tests/test_smoke_async.py +++ b/sdk/purview/azure-purview-scanning/tests/test_smoke_async.py @@ -6,18 +6,14 @@ # ------------------------------------------------------------------------- from testcase import PurviewScanningPowerShellPreparer from testcase_async import PurviewScanningTestAsync -from azure.purview.scanning.rest import data_sources +from _util import PurviewScanningRecordingProcessor class PurviewScanningSmokeTestAsync(PurviewScanningTestAsync): @PurviewScanningPowerShellPreparer() async def test_basic_smoke_test(self, purviewscanning_endpoint): - request = data_sources.build_list_all_request() - + self.recording_processors.append(PurviewScanningRecordingProcessor()) client = self.create_async_client(endpoint=purviewscanning_endpoint) - response = await client.send_request(request) - response.raise_for_status() - assert response.status_code == 200 - json_response = response.json() - assert set(json_response.keys()) == set(['value', 'count']) - assert len(json_response['value']) == json_response['count'] + response = client.data_sources.list_all() + result = [item async for item in response] + assert len(result) >= 1 diff --git a/sdk/purview/azure-purview-scanning/tests/testcase.py b/sdk/purview/azure-purview-scanning/tests/testcase.py index 1be0e0ecc1bf..96452942dc3a 100644 --- a/sdk/purview/azure-purview-scanning/tests/testcase.py +++ b/sdk/purview/azure-purview-scanning/tests/testcase.py @@ -8,6 +8,7 @@ from devtools_testutils import AzureTestCase, PowerShellPreparer from azure.purview.scanning import PurviewScanningClient + class PurviewScanningTest(AzureTestCase): def create_client(self, endpoint): @@ -18,8 +19,9 @@ def create_client(self, endpoint): endpoint=endpoint, ) + PurviewScanningPowerShellPreparer = functools.partial( PowerShellPreparer, "purviewscanning", purviewscanning_endpoint="https://fake_account.scan.purview.azure.com" -) \ No newline at end of file +) diff --git a/sdk/purview/azure-purview-scanning/tests/testcase_async.py b/sdk/purview/azure-purview-scanning/tests/testcase_async.py index 545d8dc7fd18..4580662b4178 100644 --- a/sdk/purview/azure-purview-scanning/tests/testcase_async.py +++ b/sdk/purview/azure-purview-scanning/tests/testcase_async.py @@ -7,6 +7,7 @@ from devtools_testutils import AzureTestCase from azure.purview.scanning.aio import PurviewScanningClient as AsyncPurviewScanningClient + class PurviewScanningTestAsync(AzureTestCase): def create_async_client(self, endpoint): diff --git a/shared_requirements.txt b/shared_requirements.txt index 0dc36b756e1a..7c661af6eaf2 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -278,7 +278,7 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-purview-catalog azure-core<2.0.0,>=1.18.0 #override azure-purview-catalog msrest>=0.6.21 #override azure-mgmt-resourcegraph msrest>=0.6.21 -#override azure-purview-scanning azure-core<2.0.0,>=1.8.2 +#override azure-purview-scanning azure-core<2.0.0,>=1.18.0 #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