Skip to content

Commit b0acdfb

Browse files
authored
[purview scanning] new release by new LLC version (#20823)
1 parent ae69e4b commit b0acdfb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+8794
-6759
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Release History
22

3+
## 1.0.0b2 (2021-09-29)
4+
5+
**Features**
6+
7+
- Add convenience operations to client
8+
9+
**Breaking changes**
10+
11+
- Remove rest layer and request builders(detailed description is in `README.md`)
12+
- The HttpRequest parameter to send_request has changed from `http_request` to `request`
13+
- Ordering of endpoint and credential params have changed
14+
315
## 1.0.0b1 (2021-05-11)
416

517
- This is the initial release of the Azure Purview Scanning library.

sdk/purview/azure-purview-scanning/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,14 @@ The following section shows you how to initialize and authenticate your client,
7373
```python
7474
from azure.purview.scanning import PurviewScanningClient
7575
from azure.identity import DefaultAzureCredential
76-
from azure.purview.scanning.rest import data_sources
7776
from azure.core.exceptions import HttpResponseError
7877

7978
credential = DefaultAzureCredential()
8079
client = PurviewScanningClient(endpoint="https://<my-account-name>.scan.purview.azure.com", credential=credential)
81-
82-
request = data_sources.build_list_all_request()
83-
84-
response = client.send_request(request)
8580
try:
86-
response.raise_for_status()
87-
json_response = response.json()
88-
89-
assert len(json_response['value']) == json_response['count']
90-
for value in json_response['value']:
91-
print(value)
92-
81+
response = client.data_sources.list_all()
82+
result = [item for item in response]
83+
print(result)
9384
except HttpResponseError as e:
9485
print(e)
9586
```
@@ -135,7 +126,7 @@ Similarly, `logging_enable` can enable detailed logging for a single `send_reque
135126
even when it isn't enabled for the client:
136127

137128
```python
138-
result = client.send_request(request, logging_enable=True)
129+
result = client.data_sources.list_all(logging_enable=True)
139130
```
140131

141132
## Next steps

sdk/purview/azure-purview-scanning/azure/purview/scanning/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._azure_purview_scanning_client import PurviewScanningClient
9+
from ._purview_scanning_client import PurviewScanningClient
1010
from ._version import VERSION
1111

1212
__version__ = VERSION

sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py

Lines changed: 0 additions & 104 deletions
This file was deleted.

sdk/purview/azure-purview-scanning/azure/purview/scanning/_configuration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ class PurviewScanningClientConfiguration(Configuration):
2626
Note that all parameters used to create this instance are saved as instance
2727
attributes.
2828
29-
:param credential: Credential needed for the client to connect to Azure.
30-
:type credential: ~azure.core.credentials.TokenCredential
3129
:param endpoint: The scanning endpoint of your purview account. Example: https://{accountName}.scan.purview.azure.com.
3230
:type endpoint: str
31+
:param credential: Credential needed for the client to connect to Azure.
32+
:type credential: ~azure.core.credentials.TokenCredential
3333
"""
3434

3535
def __init__(
3636
self,
37-
credential, # type: "TokenCredential"
3837
endpoint, # type: str
38+
credential, # type: "TokenCredential"
3939
**kwargs # type: Any
4040
):
4141
# type: (...) -> None
42-
if credential is None:
43-
raise ValueError("Parameter 'credential' must not be None.")
4442
if endpoint is None:
4543
raise ValueError("Parameter 'endpoint' must not be None.")
44+
if credential is None:
45+
raise ValueError("Parameter 'credential' must not be None.")
4646
super(PurviewScanningClientConfiguration, self).__init__(**kwargs)
4747

48-
self.credential = credential
4948
self.endpoint = endpoint
49+
self.credential = credential
5050
self.api_version = "2018-12-01-preview"
5151
self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default'])
5252
kwargs.setdefault('sdk_moniker', 'purview-scanning/{}'.format(VERSION))
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) AutoRest Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import TYPE_CHECKING
11+
12+
from azure.core import PipelineClient
13+
from msrest import Deserializer, Serializer
14+
15+
from ._configuration import PurviewScanningClientConfiguration
16+
from .operations import ClassificationRulesOperations, DataSourcesOperations, FiltersOperations, KeyVaultConnectionsOperations, ScanResultOperations, ScanRulesetsOperations, ScansOperations, SystemScanRulesetsOperations, TriggersOperations
17+
18+
if TYPE_CHECKING:
19+
# pylint: disable=unused-import,ungrouped-imports
20+
from typing import Any, Dict, Optional
21+
22+
from azure.core.credentials import TokenCredential
23+
from azure.core.rest import HttpRequest, HttpResponse
24+
25+
class PurviewScanningClient(object):
26+
"""Creates a Microsoft.Scanning management client.
27+
28+
:ivar key_vault_connections: KeyVaultConnectionsOperations operations
29+
:vartype key_vault_connections: azure.purview.scanning.operations.KeyVaultConnectionsOperations
30+
:ivar classification_rules: ClassificationRulesOperations operations
31+
:vartype classification_rules: azure.purview.scanning.operations.ClassificationRulesOperations
32+
:ivar data_sources: DataSourcesOperations operations
33+
:vartype data_sources: azure.purview.scanning.operations.DataSourcesOperations
34+
:ivar filters: FiltersOperations operations
35+
:vartype filters: azure.purview.scanning.operations.FiltersOperations
36+
:ivar scans: ScansOperations operations
37+
:vartype scans: azure.purview.scanning.operations.ScansOperations
38+
:ivar scan_result: ScanResultOperations operations
39+
:vartype scan_result: azure.purview.scanning.operations.ScanResultOperations
40+
:ivar scan_rulesets: ScanRulesetsOperations operations
41+
:vartype scan_rulesets: azure.purview.scanning.operations.ScanRulesetsOperations
42+
:ivar system_scan_rulesets: SystemScanRulesetsOperations operations
43+
:vartype system_scan_rulesets: azure.purview.scanning.operations.SystemScanRulesetsOperations
44+
:ivar triggers: TriggersOperations operations
45+
:vartype triggers: azure.purview.scanning.operations.TriggersOperations
46+
:param endpoint: The scanning endpoint of your purview account. Example:
47+
https://{accountName}.scan.purview.azure.com.
48+
:type endpoint: str
49+
:param credential: Credential needed for the client to connect to Azure.
50+
:type credential: ~azure.core.credentials.TokenCredential
51+
"""
52+
53+
def __init__(
54+
self,
55+
endpoint, # type: str
56+
credential, # type: "TokenCredential"
57+
**kwargs # type: Any
58+
):
59+
# type: (...) -> None
60+
_endpoint = '{Endpoint}'
61+
self._config = PurviewScanningClientConfiguration(endpoint, credential, **kwargs)
62+
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
63+
64+
self._serialize = Serializer()
65+
self._deserialize = Deserializer()
66+
self._serialize.client_side_validation = False
67+
self.key_vault_connections = KeyVaultConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
68+
self.classification_rules = ClassificationRulesOperations(self._client, self._config, self._serialize, self._deserialize)
69+
self.data_sources = DataSourcesOperations(self._client, self._config, self._serialize, self._deserialize)
70+
self.filters = FiltersOperations(self._client, self._config, self._serialize, self._deserialize)
71+
self.scans = ScansOperations(self._client, self._config, self._serialize, self._deserialize)
72+
self.scan_result = ScanResultOperations(self._client, self._config, self._serialize, self._deserialize)
73+
self.scan_rulesets = ScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize)
74+
self.system_scan_rulesets = SystemScanRulesetsOperations(self._client, self._config, self._serialize, self._deserialize)
75+
self.triggers = TriggersOperations(self._client, self._config, self._serialize, self._deserialize)
76+
77+
78+
def send_request(
79+
self,
80+
request, # type: HttpRequest
81+
**kwargs # type: Any
82+
):
83+
# type: (...) -> HttpResponse
84+
"""Runs the network request through the client's chained policies.
85+
86+
>>> from azure.core.rest import HttpRequest
87+
>>> request = HttpRequest("GET", "https://www.example.org/")
88+
<HttpRequest [GET], url: 'https://www.example.org/'>
89+
>>> response = client.send_request(request)
90+
<HttpResponse: 200 OK>
91+
92+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
93+
94+
:param request: The network request you want to make. Required.
95+
:type request: ~azure.core.rest.HttpRequest
96+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
97+
:return: The response of your network call. Does not do error handling on your response.
98+
:rtype: ~azure.core.rest.HttpResponse
99+
"""
100+
101+
request_copy = deepcopy(request)
102+
path_format_arguments = {
103+
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
104+
}
105+
106+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
107+
return self._client.send_request(request_copy, **kwargs)
108+
109+
def close(self):
110+
# type: () -> None
111+
self._client.close()
112+
113+
def __enter__(self):
114+
# type: () -> PurviewScanningClient
115+
self._client.__enter__()
116+
return self
117+
118+
def __exit__(self, *exc_details):
119+
# type: (Any) -> None
120+
self._client.__exit__(*exc_details)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from azure.core.pipeline.transport import HttpRequest
9+
10+
def _convert_request(request, files=None):
11+
data = request.content if not files else None
12+
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
13+
if files:
14+
request.set_formdata_body(files)
15+
return request
16+
17+
def _format_url_section(template, **kwargs):
18+
components = template.split("/")
19+
while components:
20+
try:
21+
return template.format(**kwargs)
22+
except KeyError as key:
23+
formatted_components = template.split("/")
24+
components = [
25+
c for c in formatted_components if "{}".format(key.args[0]) not in c
26+
]
27+
template = "/".join(components)

sdk/purview/azure-purview-scanning/azure/purview/scanning/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "1.0.0b1"
9+
VERSION = "1.0.0b2"

sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._azure_purview_scanning_client import PurviewScanningClient
9+
from ._purview_scanning_client import PurviewScanningClient
1010
__all__ = ['PurviewScanningClient']

0 commit comments

Comments
 (0)