|
6 | 6 | # Changes may cause incorrect behavior and will be lost if the code is regenerated. |
7 | 7 | # -------------------------------------------------------------------------- |
8 | 8 |
|
9 | | -from typing import TYPE_CHECKING |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, Optional, TYPE_CHECKING |
10 | 11 |
|
| 12 | +from azure.core.rest import HttpRequest, HttpResponse |
11 | 13 | from azure.mgmt.core import ARMPipelineClient |
12 | 14 | from msrest import Deserializer, Serializer |
13 | 15 |
|
| 16 | +from . import models |
| 17 | +from ._configuration import KustoManagementClientConfiguration |
| 18 | +from .operations import AttachedDatabaseConfigurationsOperations, ClusterPrincipalAssignmentsOperations, ClustersOperations, DataConnectionsOperations, DatabasePrincipalAssignmentsOperations, DatabasesOperations, ManagedPrivateEndpointsOperations, Operations, OperationsResultsLocationOperations, OperationsResultsOperations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ScriptsOperations |
| 19 | + |
14 | 20 | if TYPE_CHECKING: |
15 | 21 | # pylint: disable=unused-import,ungrouped-imports |
16 | | - from typing import Any, Optional |
17 | | - |
18 | 22 | from azure.core.credentials import TokenCredential |
19 | | - from azure.core.pipeline.transport import HttpRequest, HttpResponse |
20 | | - |
21 | | -from ._configuration import KustoManagementClientConfiguration |
22 | | -from .operations import ClustersOperations |
23 | | -from .operations import ClusterPrincipalAssignmentsOperations |
24 | | -from .operations import DatabasesOperations |
25 | | -from .operations import AttachedDatabaseConfigurationsOperations |
26 | | -from .operations import ManagedPrivateEndpointsOperations |
27 | | -from .operations import DatabasePrincipalAssignmentsOperations |
28 | | -from .operations import ScriptsOperations |
29 | | -from .operations import PrivateEndpointConnectionsOperations |
30 | | -from .operations import PrivateLinkResourcesOperations |
31 | | -from .operations import DataConnectionsOperations |
32 | | -from .operations import Operations |
33 | | -from .operations import OperationsResultsOperations |
34 | | -from . import models |
35 | | - |
36 | 23 |
|
37 | | -class KustoManagementClient(object): |
| 24 | +class KustoManagementClient: |
38 | 25 | """The Azure Kusto management API provides a RESTful set of web services that interact with Azure Kusto services to manage your clusters and databases. The API enables you to create, update, and delete clusters and databases. |
39 | 26 |
|
40 | 27 | :ivar clusters: ClustersOperations operations |
41 | 28 | :vartype clusters: kusto_management_client.operations.ClustersOperations |
42 | 29 | :ivar cluster_principal_assignments: ClusterPrincipalAssignmentsOperations operations |
43 | | - :vartype cluster_principal_assignments: kusto_management_client.operations.ClusterPrincipalAssignmentsOperations |
| 30 | + :vartype cluster_principal_assignments: |
| 31 | + kusto_management_client.operations.ClusterPrincipalAssignmentsOperations |
44 | 32 | :ivar databases: DatabasesOperations operations |
45 | 33 | :vartype databases: kusto_management_client.operations.DatabasesOperations |
46 | 34 | :ivar attached_database_configurations: AttachedDatabaseConfigurationsOperations operations |
47 | | - :vartype attached_database_configurations: kusto_management_client.operations.AttachedDatabaseConfigurationsOperations |
| 35 | + :vartype attached_database_configurations: |
| 36 | + kusto_management_client.operations.AttachedDatabaseConfigurationsOperations |
48 | 37 | :ivar managed_private_endpoints: ManagedPrivateEndpointsOperations operations |
49 | | - :vartype managed_private_endpoints: kusto_management_client.operations.ManagedPrivateEndpointsOperations |
| 38 | + :vartype managed_private_endpoints: |
| 39 | + kusto_management_client.operations.ManagedPrivateEndpointsOperations |
50 | 40 | :ivar database_principal_assignments: DatabasePrincipalAssignmentsOperations operations |
51 | | - :vartype database_principal_assignments: kusto_management_client.operations.DatabasePrincipalAssignmentsOperations |
| 41 | + :vartype database_principal_assignments: |
| 42 | + kusto_management_client.operations.DatabasePrincipalAssignmentsOperations |
52 | 43 | :ivar scripts: ScriptsOperations operations |
53 | 44 | :vartype scripts: kusto_management_client.operations.ScriptsOperations |
54 | 45 | :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations |
55 | | - :vartype private_endpoint_connections: kusto_management_client.operations.PrivateEndpointConnectionsOperations |
| 46 | + :vartype private_endpoint_connections: |
| 47 | + kusto_management_client.operations.PrivateEndpointConnectionsOperations |
56 | 48 | :ivar private_link_resources: PrivateLinkResourcesOperations operations |
57 | | - :vartype private_link_resources: kusto_management_client.operations.PrivateLinkResourcesOperations |
| 49 | + :vartype private_link_resources: |
| 50 | + kusto_management_client.operations.PrivateLinkResourcesOperations |
58 | 51 | :ivar data_connections: DataConnectionsOperations operations |
59 | 52 | :vartype data_connections: kusto_management_client.operations.DataConnectionsOperations |
60 | 53 | :ivar operations: Operations operations |
61 | 54 | :vartype operations: kusto_management_client.operations.Operations |
62 | 55 | :ivar operations_results: OperationsResultsOperations operations |
63 | 56 | :vartype operations_results: kusto_management_client.operations.OperationsResultsOperations |
| 57 | + :ivar operations_results_location: OperationsResultsLocationOperations operations |
| 58 | + :vartype operations_results_location: |
| 59 | + kusto_management_client.operations.OperationsResultsLocationOperations |
64 | 60 | :param credential: Credential needed for the client to connect to Azure. |
65 | 61 | :type credential: ~azure.core.credentials.TokenCredential |
66 | | - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
| 62 | + :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure |
| 63 | + subscription. The subscription ID forms part of the URI for every service call. |
67 | 64 | :type subscription_id: str |
68 | | - :param str base_url: Service URL |
69 | | - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. |
| 65 | + :param base_url: Service URL. Default value is 'https://management.azure.com'. |
| 66 | + :type base_url: str |
| 67 | + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no |
| 68 | + Retry-After header is present. |
70 | 69 | """ |
71 | 70 |
|
72 | 71 | def __init__( |
73 | 72 | self, |
74 | | - credential, # type: "TokenCredential" |
75 | | - subscription_id, # type: str |
76 | | - base_url=None, # type: Optional[str] |
77 | | - **kwargs # type: Any |
78 | | - ): |
79 | | - # type: (...) -> None |
80 | | - if not base_url: |
81 | | - base_url = 'https://management.azure.com' |
82 | | - self._config = KustoManagementClientConfiguration(credential, subscription_id, **kwargs) |
| 73 | + credential: "TokenCredential", |
| 74 | + subscription_id: str, |
| 75 | + base_url: str = "https://management.azure.com", |
| 76 | + **kwargs: Any |
| 77 | + ) -> None: |
| 78 | + self._config = KustoManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) |
83 | 79 | self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) |
84 | 80 |
|
85 | 81 | client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} |
86 | 82 | self._serialize = Serializer(client_models) |
87 | | - self._serialize.client_side_validation = False |
88 | 83 | self._deserialize = Deserializer(client_models) |
89 | | - |
90 | | - self.clusters = ClustersOperations( |
91 | | - self._client, self._config, self._serialize, self._deserialize) |
92 | | - self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations( |
93 | | - self._client, self._config, self._serialize, self._deserialize) |
94 | | - self.databases = DatabasesOperations( |
95 | | - self._client, self._config, self._serialize, self._deserialize) |
96 | | - self.attached_database_configurations = AttachedDatabaseConfigurationsOperations( |
97 | | - self._client, self._config, self._serialize, self._deserialize) |
98 | | - self.managed_private_endpoints = ManagedPrivateEndpointsOperations( |
99 | | - self._client, self._config, self._serialize, self._deserialize) |
100 | | - self.database_principal_assignments = DatabasePrincipalAssignmentsOperations( |
101 | | - self._client, self._config, self._serialize, self._deserialize) |
102 | | - self.scripts = ScriptsOperations( |
103 | | - self._client, self._config, self._serialize, self._deserialize) |
104 | | - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( |
105 | | - self._client, self._config, self._serialize, self._deserialize) |
106 | | - self.private_link_resources = PrivateLinkResourcesOperations( |
107 | | - self._client, self._config, self._serialize, self._deserialize) |
108 | | - self.data_connections = DataConnectionsOperations( |
109 | | - self._client, self._config, self._serialize, self._deserialize) |
110 | | - self.operations = Operations( |
111 | | - self._client, self._config, self._serialize, self._deserialize) |
112 | | - self.operations_results = OperationsResultsOperations( |
113 | | - self._client, self._config, self._serialize, self._deserialize) |
114 | | - |
115 | | - def _send_request(self, http_request, **kwargs): |
116 | | - # type: (HttpRequest, Any) -> HttpResponse |
| 84 | + self._serialize.client_side_validation = False |
| 85 | + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 86 | + self.cluster_principal_assignments = ClusterPrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 87 | + self.databases = DatabasesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 88 | + self.attached_database_configurations = AttachedDatabaseConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 89 | + self.managed_private_endpoints = ManagedPrivateEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self.database_principal_assignments = DatabasePrincipalAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 91 | + self.scripts = ScriptsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 92 | + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 93 | + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) |
| 94 | + self.data_connections = DataConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 95 | + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) |
| 96 | + self.operations_results = OperationsResultsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 97 | + self.operations_results_location = OperationsResultsLocationOperations(self._client, self._config, self._serialize, self._deserialize) |
| 98 | + |
| 99 | + |
| 100 | + def _send_request( |
| 101 | + self, |
| 102 | + request, # type: HttpRequest |
| 103 | + **kwargs: Any |
| 104 | + ) -> HttpResponse: |
117 | 105 | """Runs the network request through the client's chained policies. |
118 | 106 |
|
119 | | - :param http_request: The network request you want to make. Required. |
120 | | - :type http_request: ~azure.core.pipeline.transport.HttpRequest |
121 | | - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. |
| 107 | + >>> from azure.core.rest import HttpRequest |
| 108 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 109 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 110 | + >>> response = client._send_request(request) |
| 111 | + <HttpResponse: 200 OK> |
| 112 | +
|
| 113 | + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart |
| 114 | +
|
| 115 | + :param request: The network request you want to make. Required. |
| 116 | + :type request: ~azure.core.rest.HttpRequest |
| 117 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
122 | 118 | :return: The response of your network call. Does not do error handling on your response. |
123 | | - :rtype: ~azure.core.pipeline.transport.HttpResponse |
| 119 | + :rtype: ~azure.core.rest.HttpResponse |
124 | 120 | """ |
125 | | - path_format_arguments = { |
126 | | - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), |
127 | | - } |
128 | | - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) |
129 | | - stream = kwargs.pop("stream", True) |
130 | | - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) |
131 | | - return pipeline_response.http_response |
| 121 | + |
| 122 | + request_copy = deepcopy(request) |
| 123 | + request_copy.url = self._client.format_url(request_copy.url) |
| 124 | + return self._client.send_request(request_copy, **kwargs) |
132 | 125 |
|
133 | 126 | def close(self): |
134 | 127 | # type: () -> None |
|
0 commit comments