Skip to content

Commit 221abbb

Browse files
msyyciscai-msft
authored andcommitted
[Purview catalog] release for new api-version 2021-09-01 (#20822)
1 parent 72e59f2 commit 221abbb

Some content is hidden

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

42 files changed

+40614
-23797
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Release History
22

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

519
- This is the initial release of the Azure Purview Catalog library.

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

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

7978
credential = DefaultAzureCredential()
8079
client = PurviewCatalogClient(endpoint="https://<my-account-name>.catalog.purview.azure.com", credential=credential)
81-
82-
request = types.build_get_all_type_definitions_request()
83-
84-
response = client.send_request(request)
8580
try:
86-
response.raise_for_status()
87-
json_response = response.json()
81+
response = client.types.get_all_type_definitions()
8882
# print out all of your entity definitions
89-
print(json_response['entityDefs'])
83+
print(response['entityDefs'])
9084

9185
except HttpResponseError as e:
9286
print(e)
@@ -133,7 +127,7 @@ Similarly, `logging_enable` can enable detailed logging for a single `send_reque
133127
even when it isn't enabled for the client:
134128

135129
```python
136-
result = client.send_request(request, logging_enable=True)
130+
result = client.types.get_all_type_definitions(logging_enable=True)
137131
```
138132

139133
## Next steps

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,28 @@ class PurviewCatalogClientConfiguration(Configuration):
2626
Note that all parameters used to create this instance are saved as instance
2727
attributes.
2828
29+
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.purview.azure.com.
30+
:type endpoint: str
2931
:param credential: Credential needed for the client to connect to Azure.
3032
:type credential: ~azure.core.credentials.TokenCredential
31-
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
32-
:type endpoint: str
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(PurviewCatalogClientConfiguration, self).__init__(**kwargs)
4747

48-
self.credential = credential
4948
self.endpoint = endpoint
50-
self.api_version = "2021-05-01-preview"
49+
self.credential = credential
50+
self.api_version = "2021-09-01"
5151
self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default'])
5252
kwargs.setdefault('sdk_moniker', 'purview-catalog/{}'.format(VERSION))
5353
self._configure(**kwargs)

sdk/purview/azure-purview-catalog/azure/purview/catalog/_purview_catalog_client.py

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,85 +10,97 @@
1010
from typing import TYPE_CHECKING
1111

1212
from azure.core import PipelineClient
13-
from azure.purview.catalog.core.rest import HttpResponse, _StreamContextManager
1413
from msrest import Deserializer, Serializer
1514

15+
from ._configuration import PurviewCatalogClientConfiguration
16+
from .operations import CollectionOperations, DiscoveryOperations, EntityOperations, GlossaryOperations, LineageOperations, RelationshipOperations, TypesOperations
17+
1618
if TYPE_CHECKING:
1719
# pylint: disable=unused-import,ungrouped-imports
18-
from typing import Any, Dict
20+
from typing import Any, Dict, Optional
1921

2022
from azure.core.credentials import TokenCredential
21-
from azure.purview.catalog.core.rest import HttpRequest
22-
23-
from ._configuration import PurviewCatalogClientConfiguration
24-
23+
from azure.core.rest import HttpRequest, HttpResponse
2524

2625
class PurviewCatalogClient(object):
2726
"""Purview Catalog Service is a fully managed cloud service whose users can discover the data sources they need and understand the data sources they find. At the same time, Data Catalog helps organizations get more value from their existing investments. This spec defines REST API of Purview Catalog Service.
2827
28+
:ivar entity: EntityOperations operations
29+
:vartype entity: azure.purview.catalog.operations.EntityOperations
30+
:ivar glossary: GlossaryOperations operations
31+
:vartype glossary: azure.purview.catalog.operations.GlossaryOperations
32+
:ivar discovery: DiscoveryOperations operations
33+
:vartype discovery: azure.purview.catalog.operations.DiscoveryOperations
34+
:ivar lineage: LineageOperations operations
35+
:vartype lineage: azure.purview.catalog.operations.LineageOperations
36+
:ivar relationship: RelationshipOperations operations
37+
:vartype relationship: azure.purview.catalog.operations.RelationshipOperations
38+
:ivar types: TypesOperations operations
39+
:vartype types: azure.purview.catalog.operations.TypesOperations
40+
:ivar collection: CollectionOperations operations
41+
:vartype collection: azure.purview.catalog.operations.CollectionOperations
42+
:param endpoint: The catalog endpoint of your Purview account. Example:
43+
https://{accountName}.purview.azure.com.
44+
:type endpoint: str
2945
:param credential: Credential needed for the client to connect to Azure.
3046
:type credential: ~azure.core.credentials.TokenCredential
31-
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
32-
:type endpoint: str
47+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
48+
Retry-After header is present.
3349
"""
3450

3551
def __init__(
3652
self,
37-
credential, # type: "TokenCredential"
3853
endpoint, # type: str
54+
credential, # type: "TokenCredential"
3955
**kwargs # type: Any
4056
):
4157
# type: (...) -> None
42-
base_url = '{Endpoint}/api'
43-
self._config = PurviewCatalogClientConfiguration(credential, endpoint, **kwargs)
44-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
58+
_endpoint = '{Endpoint}/catalog/api'
59+
self._config = PurviewCatalogClientConfiguration(endpoint, credential, **kwargs)
60+
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
4561

4662
self._serialize = Serializer()
4763
self._deserialize = Deserializer()
4864
self._serialize.client_side_validation = False
65+
self.entity = EntityOperations(self._client, self._config, self._serialize, self._deserialize)
66+
self.glossary = GlossaryOperations(self._client, self._config, self._serialize, self._deserialize)
67+
self.discovery = DiscoveryOperations(self._client, self._config, self._serialize, self._deserialize)
68+
self.lineage = LineageOperations(self._client, self._config, self._serialize, self._deserialize)
69+
self.relationship = RelationshipOperations(self._client, self._config, self._serialize, self._deserialize)
70+
self.types = TypesOperations(self._client, self._config, self._serialize, self._deserialize)
71+
self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize)
4972

50-
def send_request(self, http_request, **kwargs):
51-
# type: (HttpRequest, Any) -> HttpResponse
52-
"""Runs the network request through the client's chained policies.
5373

54-
We have helper methods to create requests specific to this service in `azure.purview.catalog.rest`.
55-
Use these helper methods to create the request you pass to this method. See our example below:
74+
def send_request(
75+
self,
76+
request, # type: HttpRequest
77+
**kwargs # type: Any
78+
):
79+
# type: (...) -> HttpResponse
80+
"""Runs the network request through the client's chained policies.
5681
57-
>>> from azure.purview.catalog.rest import build_create_or_update_request
58-
>>> request = build_create_or_update_request(json, content)
59-
<HttpRequest [POST], url: '/atlas/v2/entity'>
82+
>>> from azure.core.rest import HttpRequest
83+
>>> request = HttpRequest("GET", "https://www.example.org/")
84+
<HttpRequest [GET], url: 'https://www.example.org/'>
6085
>>> response = client.send_request(request)
6186
<HttpResponse: 200 OK>
6287
6388
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
6489
65-
For advanced cases, you can also create your own :class:`~azure.purview.catalog.core.rest.HttpRequest`
66-
and pass it in.
67-
68-
:param http_request: The network request you want to make. Required.
69-
:type http_request: ~azure.purview.catalog.core.rest.HttpRequest
70-
:keyword bool stream_response: Whether the response payload will be streamed. Defaults to False.
90+
:param request: The network request you want to make. Required.
91+
:type request: ~azure.core.rest.HttpRequest
92+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
7193
:return: The response of your network call. Does not do error handling on your response.
72-
:rtype: ~azure.purview.catalog.core.rest.HttpResponse
94+
:rtype: ~azure.core.rest.HttpResponse
7395
"""
74-
request_copy = deepcopy(http_request)
96+
97+
request_copy = deepcopy(request)
7598
path_format_arguments = {
76-
'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
99+
"Endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
77100
}
101+
78102
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
79-
if kwargs.pop("stream_response", False):
80-
return _StreamContextManager(
81-
client=self._client._pipeline,
82-
request=request_copy,
83-
)
84-
pipeline_response = self._client._pipeline.run(request_copy._internal_request, **kwargs)
85-
response = HttpResponse(
86-
status_code=pipeline_response.http_response.status_code,
87-
request=request_copy,
88-
_internal_response=pipeline_response.http_response
89-
)
90-
response.read()
91-
return response
103+
return self._client.send_request(request_copy, **kwargs)
92104

93105
def close(self):
94106
# type: () -> None
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-catalog/azure/purview/catalog/_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-catalog/azure/purview/catalog/aio/_configuration.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ class PurviewCatalogClientConfiguration(Configuration):
2424
Note that all parameters used to create this instance are saved as instance
2525
attributes.
2626
27+
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.purview.azure.com.
28+
:type endpoint: str
2729
:param credential: Credential needed for the client to connect to Azure.
2830
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
29-
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
30-
:type endpoint: str
3131
"""
3232

3333
def __init__(
3434
self,
35-
credential: "AsyncTokenCredential",
3635
endpoint: str,
36+
credential: "AsyncTokenCredential",
3737
**kwargs: Any
3838
) -> None:
39-
if credential is None:
40-
raise ValueError("Parameter 'credential' must not be None.")
4139
if endpoint is None:
4240
raise ValueError("Parameter 'endpoint' must not be None.")
41+
if credential is None:
42+
raise ValueError("Parameter 'credential' must not be None.")
4343
super(PurviewCatalogClientConfiguration, self).__init__(**kwargs)
4444

45-
self.credential = credential
4645
self.endpoint = endpoint
47-
self.api_version = "2021-05-01-preview"
46+
self.credential = credential
47+
self.api_version = "2021-09-01"
4848
self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default'])
4949
kwargs.setdefault('sdk_moniker', 'purview-catalog/{}'.format(VERSION))
5050
self._configure(**kwargs)

0 commit comments

Comments
 (0)