Skip to content

Commit

Permalink
[Purview catalog] release for new api-version 2021-09-01 (#20822)
Browse files Browse the repository at this point in the history
  • Loading branch information
msyyc authored Sep 29, 2021
1 parent 66e4720 commit ae69e4b
Show file tree
Hide file tree
Showing 42 changed files with 40,614 additions and 23,797 deletions.
14 changes: 14 additions & 0 deletions sdk/purview/azure-purview-catalog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release History

## 1.0.0b2 (2021-09-29)

**Features**

- Add convenience operations to client
- Api version has gone from `2021-05-01-preview` ot `2021-09-01`

**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 Catalog library.
12 changes: 3 additions & 9 deletions sdk/purview/azure-purview-catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,14 @@ The following section shows you how to initialize and authenticate your client,
```python
from azure.purview.catalog import PurviewCatalogClient
from azure.identity import DefaultAzureCredential
from azure.purview.catalog.rest import types
from azure.core.exceptions import HttpResponseError

credential = DefaultAzureCredential()
client = PurviewCatalogClient(endpoint="https://<my-account-name>.catalog.purview.azure.com", credential=credential)

request = types.build_get_all_type_definitions_request()

response = client.send_request(request)
try:
response.raise_for_status()
json_response = response.json()
response = client.types.get_all_type_definitions()
# print out all of your entity definitions
print(json_response['entityDefs'])
print(response['entityDefs'])

except HttpResponseError as e:
print(e)
Expand Down Expand Up @@ -133,7 +127,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.types.get_all_type_definitions(logging_enable=True)
```

## Next steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ class PurviewCatalogClientConfiguration(Configuration):
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.purview.azure.com.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
:type endpoint: str
"""

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(PurviewCatalogClientConfiguration, self).__init__(**kwargs)

self.credential = credential
self.endpoint = endpoint
self.api_version = "2021-05-01-preview"
self.credential = credential
self.api_version = "2021-09-01"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default'])
kwargs.setdefault('sdk_moniker', 'purview-catalog/{}'.format(VERSION))
self._configure(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,85 +10,97 @@
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from azure.purview.catalog.core.rest import HttpResponse, _StreamContextManager
from msrest import Deserializer, Serializer

from ._configuration import PurviewCatalogClientConfiguration
from .operations import CollectionOperations, DiscoveryOperations, EntityOperations, GlossaryOperations, LineageOperations, RelationshipOperations, TypesOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any, Dict
from typing import Any, Dict, Optional

from azure.core.credentials import TokenCredential
from azure.purview.catalog.core.rest import HttpRequest

from ._configuration import PurviewCatalogClientConfiguration

from azure.core.rest import HttpRequest, HttpResponse

class PurviewCatalogClient(object):
"""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.
:ivar entity: EntityOperations operations
:vartype entity: azure.purview.catalog.operations.EntityOperations
:ivar glossary: GlossaryOperations operations
:vartype glossary: azure.purview.catalog.operations.GlossaryOperations
:ivar discovery: DiscoveryOperations operations
:vartype discovery: azure.purview.catalog.operations.DiscoveryOperations
:ivar lineage: LineageOperations operations
:vartype lineage: azure.purview.catalog.operations.LineageOperations
:ivar relationship: RelationshipOperations operations
:vartype relationship: azure.purview.catalog.operations.RelationshipOperations
:ivar types: TypesOperations operations
:vartype types: azure.purview.catalog.operations.TypesOperations
:ivar collection: CollectionOperations operations
:vartype collection: azure.purview.catalog.operations.CollectionOperations
:param endpoint: The catalog endpoint of your Purview account. Example:
https://{accountName}.purview.azure.com.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials.TokenCredential
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
:type endpoint: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
"""

def __init__(
self,
credential, # type: "TokenCredential"
endpoint, # type: str
credential, # type: "TokenCredential"
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{Endpoint}/api'
self._config = PurviewCatalogClientConfiguration(credential, endpoint, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
_endpoint = '{Endpoint}/catalog/api'
self._config = PurviewCatalogClientConfiguration(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.entity = EntityOperations(self._client, self._config, self._serialize, self._deserialize)
self.glossary = GlossaryOperations(self._client, self._config, self._serialize, self._deserialize)
self.discovery = DiscoveryOperations(self._client, self._config, self._serialize, self._deserialize)
self.lineage = LineageOperations(self._client, self._config, self._serialize, self._deserialize)
self.relationship = RelationshipOperations(self._client, self._config, self._serialize, self._deserialize)
self.types = TypesOperations(self._client, self._config, self._serialize, self._deserialize)
self.collection = CollectionOperations(self._client, self._config, self._serialize, self._deserialize)

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.catalog.rest`.
Use these helper methods to create the request you pass to this method. See our example below:
def send_request(
self,
request, # type: HttpRequest
**kwargs # type: Any
):
# type: (...) -> HttpResponse
"""Runs the network request through the client's chained policies.
>>> from azure.purview.catalog.rest import build_create_or_update_request
>>> request = build_create_or_update_request(json, content)
<HttpRequest [POST], url: '/atlas/v2/entity'>
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client.send_request(request)
<HttpResponse: 200 OK>
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.catalog.core.rest.HttpRequest`
and pass it in.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.purview.catalog.core.rest.HttpRequest
:keyword bool stream_response: Whether the response payload will be streamed. Defaults to False.
: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.purview.catalog.core.rest.HttpResponse
:rtype: ~azure.core.rest.HttpResponse
"""
request_copy = deepcopy(http_request)

request_copy = deepcopy(request)
path_format_arguments = {
'Endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
"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
return self._client.send_request(request_copy, **kwargs)

def close(self):
# type: () -> None
Expand Down
27 changes: 27 additions & 0 deletions sdk/purview/azure-purview-catalog/azure/purview/catalog/_vendor.py
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,27 @@ class PurviewCatalogClientConfiguration(Configuration):
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.purview.azure.com.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param endpoint: The catalog endpoint of your Purview account. Example: https://{accountName}.catalog.purview.azure.com.
:type endpoint: str
"""

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(PurviewCatalogClientConfiguration, self).__init__(**kwargs)

self.credential = credential
self.endpoint = endpoint
self.api_version = "2021-05-01-preview"
self.credential = credential
self.api_version = "2021-09-01"
self.credential_scopes = kwargs.pop('credential_scopes', ['https://purview.azure.net/.default'])
kwargs.setdefault('sdk_moniker', 'purview-catalog/{}'.format(VERSION))
self._configure(**kwargs)
Expand Down
Loading

0 comments on commit ae69e4b

Please sign in to comment.