|
10 | 10 | from typing import TYPE_CHECKING |
11 | 11 |
|
12 | 12 | from azure.core import PipelineClient |
13 | | -from azure.purview.catalog.core.rest import HttpResponse, _StreamContextManager |
14 | 13 | from msrest import Deserializer, Serializer |
15 | 14 |
|
| 15 | +from ._configuration import PurviewCatalogClientConfiguration |
| 16 | +from .operations import CollectionOperations, DiscoveryOperations, EntityOperations, GlossaryOperations, LineageOperations, RelationshipOperations, TypesOperations |
| 17 | + |
16 | 18 | if TYPE_CHECKING: |
17 | 19 | # pylint: disable=unused-import,ungrouped-imports |
18 | | - from typing import Any, Dict |
| 20 | + from typing import Any, Dict, Optional |
19 | 21 |
|
20 | 22 | 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 |
25 | 24 |
|
26 | 25 | class PurviewCatalogClient(object): |
27 | 26 | """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. |
28 | 27 |
|
| 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 |
29 | 45 | :param credential: Credential needed for the client to connect to Azure. |
30 | 46 | :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. |
33 | 49 | """ |
34 | 50 |
|
35 | 51 | def __init__( |
36 | 52 | self, |
37 | | - credential, # type: "TokenCredential" |
38 | 53 | endpoint, # type: str |
| 54 | + credential, # type: "TokenCredential" |
39 | 55 | **kwargs # type: Any |
40 | 56 | ): |
41 | 57 | # 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) |
45 | 61 |
|
46 | 62 | self._serialize = Serializer() |
47 | 63 | self._deserialize = Deserializer() |
48 | 64 | 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) |
49 | 72 |
|
50 | | - def send_request(self, http_request, **kwargs): |
51 | | - # type: (HttpRequest, Any) -> HttpResponse |
52 | | - """Runs the network request through the client's chained policies. |
53 | 73 |
|
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. |
56 | 81 |
|
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/'> |
60 | 85 | >>> response = client.send_request(request) |
61 | 86 | <HttpResponse: 200 OK> |
62 | 87 |
|
63 | 88 | For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
64 | 89 |
|
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. |
71 | 93 | :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 |
73 | 95 | """ |
74 | | - request_copy = deepcopy(http_request) |
| 96 | + |
| 97 | + request_copy = deepcopy(request) |
75 | 98 | 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), |
77 | 100 | } |
| 101 | + |
78 | 102 | 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) |
92 | 104 |
|
93 | 105 | def close(self): |
94 | 106 | # type: () -> None |
|
0 commit comments