azure-connectors 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: azure-connectors
3
+ Version: 0.1.0
4
+ Summary: Azure Logic Apps Connector SDK for Python
5
+ Author-email: "Azure Logic Apps team at Microsoft Corp." <azurelogicapps@microsoft.com>
6
+ License: MIT
7
+ Project-URL: Documentation, https://github.com/Azure/connectors-python-sdk
8
+ Project-URL: Repository, https://github.com/Azure/connectors-python-sdk
9
+ Project-URL: Changelog, https://github.com/Azure/connectors-python-sdk/blob/main/CHANGELOG.md
10
+ Keywords: azure,connectors,logic-apps,python,serverless
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX
19
+ Classifier: Operating System :: MacOS :: MacOS X
20
+ Classifier: Environment :: Web Environment
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Intended Audience :: Developers
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.10
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: aiohttp
27
+ Requires-Dist: azure-identity[aio]
28
+ Provides-Extra: dev
29
+ Requires-Dist: flake8<8,>=6; extra == "dev"
30
+ Requires-Dist: mypy; extra == "dev"
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-asyncio; extra == "dev"
33
+ Requires-Dist: httpx; extra == "dev"
34
+ Requires-Dist: requests==2.*; extra == "dev"
35
+ Requires-Dist: coverage; extra == "dev"
36
+ Requires-Dist: pytest-sugar; extra == "dev"
37
+ Requires-Dist: pytest-cov; extra == "dev"
38
+ Requires-Dist: pytest-xdist; extra == "dev"
39
+ Requires-Dist: pytest-randomly; extra == "dev"
40
+ Requires-Dist: pytest-instafail; extra == "dev"
41
+ Requires-Dist: pytest-rerunfailures; extra == "dev"
@@ -0,0 +1,64 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+
3
+ """
4
+ Azure Logic Apps Connector SDK for Python.
5
+
6
+ This package provides infrastructure for calling Azure Logic Apps connectors
7
+ from Python applications, including authentication, HTTP clients, and strongly-typed
8
+ generated connector clients.
9
+ """
10
+
11
+ from .sdk.client_base import ConnectorClientBase
12
+ from .sdk.options import ConnectorClientOptions
13
+ from .sdk.authentication import (
14
+ TokenProvider,
15
+ ManagedIdentityTokenProvider,
16
+ ConnectionStringTokenProvider,
17
+ AzureIdentityTokenProvider,
18
+ )
19
+ from .sdk.exceptions import ConnectorException
20
+ from .sdk.trigger_payload import TriggerCallbackPayload, TriggerCallbackBody
21
+
22
+ # Generated connector clients — some may have import errors from incomplete
23
+ # code generation (e.g., undefined type references). Wrap each import so
24
+ # a single broken connector doesn't prevent the SDK core from loading.
25
+ # See: https://github.com/Azure/connectors-python-sdk/issues/13
26
+ try:
27
+ from .kusto import KustoClient
28
+ except (ImportError, NameError):
29
+ KustoClient = None # type: ignore[assignment,misc]
30
+ try:
31
+ from .office365 import Office365Client
32
+ except (ImportError, NameError):
33
+ Office365Client = None # type: ignore[assignment,misc]
34
+ try:
35
+ from .sharepointonline import SharepointonlineClient
36
+ except (ImportError, NameError):
37
+ SharepointonlineClient = None # type: ignore[assignment,misc]
38
+ try:
39
+ from .teams import TeamsClient
40
+ except (ImportError, NameError):
41
+ TeamsClient = None # type: ignore[assignment,misc]
42
+ try:
43
+ from .msgraph import MsgraphgroupsanduserClient
44
+ except (ImportError, NameError):
45
+ MsgraphgroupsanduserClient = None # type: ignore[assignment,misc]
46
+
47
+ __version__ = "0.1.0"
48
+
49
+ __all__ = [
50
+ "ConnectorClientBase",
51
+ "ConnectorClientOptions",
52
+ "TokenProvider",
53
+ "ManagedIdentityTokenProvider",
54
+ "ConnectionStringTokenProvider",
55
+ "AzureIdentityTokenProvider",
56
+ "ConnectorException",
57
+ "TriggerCallbackPayload",
58
+ "TriggerCallbackBody",
59
+ "KustoClient",
60
+ "Office365Client",
61
+ "SharepointonlineClient",
62
+ "TeamsClient",
63
+ "MsgraphgroupsanduserClient",
64
+ ]
@@ -0,0 +1,325 @@
1
+ # Copyright (c) Microsoft Corporation. All rights reserved.
2
+
3
+ # KustoClient.py - Auto-generated DirectClient SDK
4
+ # Do not edit this file directly.
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass, field
9
+ from typing import Optional, List, Any, Dict
10
+ from datetime import datetime
11
+ from urllib.parse import quote
12
+
13
+ from azure.connectors.sdk import (
14
+ ConnectorClientBase,
15
+ ConnectorClientOptions,
16
+ TokenProvider,
17
+ ManagedIdentityTokenProvider,
18
+ ConnectorException,
19
+ )
20
+
21
+
22
+ # Type Definitions
23
+
24
+ @dataclass
25
+ class Table:
26
+ """Response for Run KQL query"""
27
+
28
+ pass
29
+
30
+ @dataclass
31
+ class VisualizeResults:
32
+ """Response for Run KQL query and render a chart"""
33
+
34
+ pass
35
+
36
+ @dataclass
37
+ class AsyncCommandResult:
38
+ """Response for Run async control command"""
39
+
40
+ pass
41
+
42
+ @dataclass
43
+ class MCPQueryResponse:
44
+ """Response for Kusto Query MCP Server"""
45
+
46
+ pass
47
+
48
+ @dataclass
49
+ class ObjectEntity:
50
+ """Definition: Object"""
51
+
52
+ pass
53
+
54
+ @dataclass
55
+ class Row:
56
+ """Definition: Row"""
57
+
58
+ pass
59
+
60
+ @dataclass
61
+ class QueryAndVisualizeSchema:
62
+ """Definition: QueryAndVisualizeSchema"""
63
+
64
+ cluster: Optional[ClusterName] = None
65
+ db: Optional[DatabaseName] = None
66
+ csl: Optional[Query] = None
67
+ chart_type: Optional[ChartType] = None
68
+
69
+ @dataclass
70
+ class CommandAndVisualizeSchema:
71
+ """Definition: CommandAndVisualizeSchema"""
72
+
73
+ cluster: Optional[ClusterName] = None
74
+ db: Optional[DatabaseName] = None
75
+ csl: Optional[str] = None
76
+ """Specify the control command you would like to run"""
77
+ chart_type: Optional[ChartType] = None
78
+
79
+ @dataclass
80
+ class QueryAndListSchema:
81
+ """Definition: QueryAndListSchema"""
82
+
83
+ cluster: Optional[ClusterName] = None
84
+ db: Optional[DatabaseName] = None
85
+ csl: Optional[Query] = None
86
+
87
+ @dataclass
88
+ class ControlCommandAndListSchema:
89
+ """Definition: ControlCommandAndListSchema"""
90
+
91
+ cluster: Optional[ClusterName] = None
92
+ db: Optional[DatabaseName] = None
93
+ csl: Optional[str] = None
94
+ """Specify the show control command you would like to run"""
95
+
96
+ @dataclass
97
+ class ClusterName:
98
+ """Definition: ClusterName"""
99
+
100
+ pass
101
+
102
+ @dataclass
103
+ class DatabaseName:
104
+ """Definition: DatabaseName"""
105
+
106
+ pass
107
+
108
+ @dataclass
109
+ class Query:
110
+ """Definition: Query"""
111
+
112
+ pass
113
+
114
+ @dataclass
115
+ class ChartType:
116
+ """Definition: ChartType"""
117
+
118
+ pass
119
+
120
+ @dataclass
121
+ class MCPQueryRequest:
122
+ """Definition: MCPQueryRequest"""
123
+
124
+ jsonrpc: Optional[str] = None
125
+ id: Optional[str] = None
126
+ method: Optional[str] = None
127
+ params: Optional[Dict[str, Any]] = None
128
+ result: Optional[Dict[str, Any]] = None
129
+ error: Optional[Dict[str, Any]] = None
130
+ callback_endpoint: Optional[str] = None
131
+
132
+
133
+ # Client Class
134
+
135
+ class KustoClient(ConnectorClientBase):
136
+ """Typed client for kusto connector."""
137
+
138
+ def __init__(
139
+ self,
140
+ connection_runtime_url: str,
141
+ token_provider: Optional[TokenProvider] = None,
142
+ options: Optional[ConnectorClientOptions] = None,
143
+ ):
144
+ """
145
+ Initialize a KustoClient.
146
+
147
+ Args:
148
+ connection_runtime_url: The connection runtime URL from Azure Portal.
149
+ token_provider: Optional token provider. Defaults to ManagedIdentityTokenProvider.
150
+ options: Optional connector client options.
151
+ """
152
+ if not connection_runtime_url:
153
+ raise ValueError("connection_runtime_url cannot be None or empty")
154
+
155
+ if token_provider is None:
156
+ token_provider = ManagedIdentityTokenProvider()
157
+
158
+ super().__init__(token_provider, options)
159
+ self._connection_runtime_url = connection_runtime_url.rstrip('/')
160
+
161
+ @property
162
+ def connector_name(self) -> str:
163
+ return "kusto"
164
+
165
+ async def list_kusto_results_async(
166
+ self,
167
+ input: QueryAndListSchema,
168
+ ):
169
+ """
170
+ Run KQL query
171
+
172
+ Runs the KQL query and returns the result as a set of rows which can be iterated over in the following connectors e.g TableName | take 10.
173
+ """
174
+ path = f"{self._connection_runtime_url}/ListKustoResults/false"
175
+
176
+ response = await self.http_client.send_async("POST", path, body=input)
177
+
178
+ if not (200 <= response.status < 300):
179
+ raise ConnectorException(
180
+ f"POST {path}",
181
+ response.status,
182
+ response.text,
183
+ )
184
+
185
+ if not response.text:
186
+ return None
187
+
188
+ import json
189
+ return json.loads(response.text)
190
+
191
+ async def list_kusto_show_command_results_async(
192
+ self,
193
+ input: ControlCommandAndListSchema,
194
+ ):
195
+ """
196
+ Run show control command
197
+
198
+ Runs the show control command and returns the result as a set of rows which can be iterated over in the following connectors e.g .show table TableName policy caching.
199
+ """
200
+ path = f"{self._connection_runtime_url}/ListKustoShowCommandResults"
201
+
202
+ response = await self.http_client.send_async("POST", path, body=input)
203
+
204
+ if not (200 <= response.status < 300):
205
+ raise ConnectorException(
206
+ f"POST {path}",
207
+ response.status,
208
+ response.text,
209
+ )
210
+
211
+ if not response.text:
212
+ return None
213
+
214
+ import json
215
+ return json.loads(response.text)
216
+
217
+ async def run_kusto_query_and_visualize_results_async(
218
+ self,
219
+ input: QueryAndVisualizeSchema,
220
+ ):
221
+ """
222
+ Run KQL query and render a chart
223
+
224
+ Runs the KQL query and returns result as a chart of your choice e.g TableName | where Timestamp > ago(1h) | project timestamp, value.
225
+ """
226
+ path = f"{self._connection_runtime_url}/RunKustoAndVisualizeResults/false"
227
+
228
+ response = await self.http_client.send_async("POST", path, body=input)
229
+
230
+ if not (200 <= response.status < 300):
231
+ raise ConnectorException(
232
+ f"POST {path}",
233
+ response.status,
234
+ response.text,
235
+ )
236
+
237
+ if not response.text:
238
+ return None
239
+
240
+ import json
241
+ return json.loads(response.text)
242
+
243
+ async def run_kusto_command_and_visualize_results_async(
244
+ self,
245
+ input: CommandAndVisualizeSchema,
246
+ ):
247
+ """
248
+ Run control command and render a chart
249
+
250
+ Runs the control command and returns the result as a chart of your choice e.g .clear table TableName data.
251
+ """
252
+ path = f"{self._connection_runtime_url}/RunKustoAndVisualizeResults/true"
253
+
254
+ response = await self.http_client.send_async("POST", path, body=input)
255
+
256
+ if not (200 <= response.status < 300):
257
+ raise ConnectorException(
258
+ f"POST {path}",
259
+ response.status,
260
+ response.text,
261
+ )
262
+
263
+ if not response.text:
264
+ return None
265
+
266
+ import json
267
+ return json.loads(response.text)
268
+
269
+ async def run_async_control_command_and_wait_async(
270
+ self,
271
+ input: ControlCommandAndListSchema,
272
+ ):
273
+ """
274
+ Run async control command
275
+
276
+ Runs control command in async mode and returns its ID, state and status on completion. Command can run for maximum 1 hour. The 'async' keyword is mandatory e.g .set-or-append async TargetTable <| SourceTable.
277
+ """
278
+ path = f"{self._connection_runtime_url}/RunAsyncControlCommandAndWait"
279
+
280
+ response = await self.http_client.send_async("POST", path, body=input)
281
+
282
+ if not (200 <= response.status < 300):
283
+ raise ConnectorException(
284
+ f"POST {path}",
285
+ response.status,
286
+ response.text,
287
+ )
288
+
289
+ if not response.text:
290
+ return None
291
+
292
+ import json
293
+ return json.loads(response.text)
294
+
295
+ async def mcp_kusto_query_management_async(
296
+ self,
297
+ input: MCPQueryRequest,
298
+ session_id: Optional[str] = None,
299
+ ):
300
+ """
301
+ Kusto Query MCP Server
302
+
303
+ This MCP server runs Kusto queries and manages the results.
304
+ """
305
+ path = f"{self._connection_runtime_url}/mcp/KustoQueryManagement"
306
+ query_params = []
307
+ if session_id is not None:
308
+ query_params.append(f"sessionId={quote(str(session_id).lower() if isinstance(session_id, bool) else str(session_id))}")
309
+ if query_params:
310
+ path += '?' + '&'.join(query_params)
311
+
312
+ response = await self.http_client.send_async("POST", path, body=input)
313
+
314
+ if not (200 <= response.status < 300):
315
+ raise ConnectorException(
316
+ f"POST {path}",
317
+ response.status,
318
+ response.text,
319
+ )
320
+
321
+ if not response.text:
322
+ return None
323
+
324
+ import json
325
+ return json.loads(response.text)