azure-connectors 0.1.0.dev1__py3-none-any.whl
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.
- azure/connectors/__init__.py +39 -0
- azure/connectors/kusto.py +323 -0
- azure/connectors/msgraph.py +397 -0
- azure/connectors/office365.py +3640 -0
- azure/connectors/sdk/__init__.py +34 -0
- azure/connectors/sdk/authentication.py +119 -0
- azure/connectors/sdk/client_base.py +64 -0
- azure/connectors/sdk/exceptions.py +33 -0
- azure/connectors/sdk/http_client.py +253 -0
- azure/connectors/sdk/options.py +26 -0
- azure/connectors/sdk/trigger_payload.py +38 -0
- azure/connectors/sharepointonline.py +2575 -0
- azure/connectors/teams.py +2212 -0
- azure_connectors-0.1.0.dev1.dist-info/METADATA +35 -0
- azure_connectors-0.1.0.dev1.dist-info/RECORD +17 -0
- azure_connectors-0.1.0.dev1.dist-info/WHEEL +5 -0
- azure_connectors-0.1.0.dev1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,39 @@
|
|
|
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 TokenProvider, ManagedIdentityTokenProvider, ConnectionStringTokenProvider, AzureIdentityTokenProvider
|
|
14
|
+
from .sdk.exceptions import ConnectorException
|
|
15
|
+
from .sdk.trigger_payload import TriggerCallbackPayload, TriggerCallbackBody
|
|
16
|
+
from .kusto import KustoClient
|
|
17
|
+
from .office365 import Office365Client
|
|
18
|
+
from .sharepointonline import SharepointonlineClient
|
|
19
|
+
from .teams import TeamsClient
|
|
20
|
+
from .msgraph import MsgraphgroupsanduserClient
|
|
21
|
+
|
|
22
|
+
__version__ = "0.1.0"
|
|
23
|
+
|
|
24
|
+
__all__ = [
|
|
25
|
+
"ConnectorClientBase",
|
|
26
|
+
"ConnectorClientOptions",
|
|
27
|
+
"TokenProvider",
|
|
28
|
+
"ManagedIdentityTokenProvider",
|
|
29
|
+
"ConnectionStringTokenProvider",
|
|
30
|
+
"AzureIdentityTokenProvider",
|
|
31
|
+
"ConnectorException",
|
|
32
|
+
"TriggerCallbackPayload",
|
|
33
|
+
"TriggerCallbackBody",
|
|
34
|
+
"KustoClient",
|
|
35
|
+
"Office365Client",
|
|
36
|
+
"SharepointonlineClient",
|
|
37
|
+
"TeamsClient",
|
|
38
|
+
"MsgraphgroupsanduserClient",
|
|
39
|
+
]
|
|
@@ -0,0 +1,323 @@
|
|
|
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 dataclasses import dataclass, field
|
|
7
|
+
from typing import Optional, List, Any, Dict
|
|
8
|
+
from datetime import datetime
|
|
9
|
+
from urllib.parse import quote
|
|
10
|
+
|
|
11
|
+
from azure.connectors.sdk import (
|
|
12
|
+
ConnectorClientBase,
|
|
13
|
+
ConnectorClientOptions,
|
|
14
|
+
TokenProvider,
|
|
15
|
+
ManagedIdentityTokenProvider,
|
|
16
|
+
ConnectorException,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Type Definitions
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class Table:
|
|
24
|
+
"""Response for Run KQL query"""
|
|
25
|
+
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class VisualizeResults:
|
|
30
|
+
"""Response for Run KQL query and render a chart"""
|
|
31
|
+
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class AsyncCommandResult:
|
|
36
|
+
"""Response for Run async control command"""
|
|
37
|
+
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class MCPQueryResponse:
|
|
42
|
+
"""Response for Kusto Query MCP Server"""
|
|
43
|
+
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class ObjectEntity:
|
|
48
|
+
"""Definition: Object"""
|
|
49
|
+
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
@dataclass
|
|
53
|
+
class Row:
|
|
54
|
+
"""Definition: Row"""
|
|
55
|
+
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class QueryAndVisualizeSchema:
|
|
60
|
+
"""Definition: QueryAndVisualizeSchema"""
|
|
61
|
+
|
|
62
|
+
cluster: Optional[ClusterName] = None
|
|
63
|
+
db: Optional[DatabaseName] = None
|
|
64
|
+
csl: Optional[Query] = None
|
|
65
|
+
chart_type: Optional[ChartType] = None
|
|
66
|
+
|
|
67
|
+
@dataclass
|
|
68
|
+
class CommandAndVisualizeSchema:
|
|
69
|
+
"""Definition: CommandAndVisualizeSchema"""
|
|
70
|
+
|
|
71
|
+
cluster: Optional[ClusterName] = None
|
|
72
|
+
db: Optional[DatabaseName] = None
|
|
73
|
+
csl: Optional[str] = None
|
|
74
|
+
"""Specify the control command you would like to run"""
|
|
75
|
+
chart_type: Optional[ChartType] = None
|
|
76
|
+
|
|
77
|
+
@dataclass
|
|
78
|
+
class QueryAndListSchema:
|
|
79
|
+
"""Definition: QueryAndListSchema"""
|
|
80
|
+
|
|
81
|
+
cluster: Optional[ClusterName] = None
|
|
82
|
+
db: Optional[DatabaseName] = None
|
|
83
|
+
csl: Optional[Query] = None
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class ControlCommandAndListSchema:
|
|
87
|
+
"""Definition: ControlCommandAndListSchema"""
|
|
88
|
+
|
|
89
|
+
cluster: Optional[ClusterName] = None
|
|
90
|
+
db: Optional[DatabaseName] = None
|
|
91
|
+
csl: Optional[str] = None
|
|
92
|
+
"""Specify the show control command you would like to run"""
|
|
93
|
+
|
|
94
|
+
@dataclass
|
|
95
|
+
class ClusterName:
|
|
96
|
+
"""Definition: ClusterName"""
|
|
97
|
+
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class DatabaseName:
|
|
102
|
+
"""Definition: DatabaseName"""
|
|
103
|
+
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
@dataclass
|
|
107
|
+
class Query:
|
|
108
|
+
"""Definition: Query"""
|
|
109
|
+
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
@dataclass
|
|
113
|
+
class ChartType:
|
|
114
|
+
"""Definition: ChartType"""
|
|
115
|
+
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
@dataclass
|
|
119
|
+
class MCPQueryRequest:
|
|
120
|
+
"""Definition: MCPQueryRequest"""
|
|
121
|
+
|
|
122
|
+
jsonrpc: Optional[str] = None
|
|
123
|
+
id: Optional[str] = None
|
|
124
|
+
method: Optional[str] = None
|
|
125
|
+
params: Optional[Dict[str, Any]] = None
|
|
126
|
+
result: Optional[Dict[str, Any]] = None
|
|
127
|
+
error: Optional[Dict[str, Any]] = None
|
|
128
|
+
callback_endpoint: Optional[str] = None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Client Class
|
|
132
|
+
|
|
133
|
+
class KustoClient(ConnectorClientBase):
|
|
134
|
+
"""Typed client for kusto connector."""
|
|
135
|
+
|
|
136
|
+
def __init__(
|
|
137
|
+
self,
|
|
138
|
+
connection_runtime_url: str,
|
|
139
|
+
token_provider: Optional[TokenProvider] = None,
|
|
140
|
+
options: Optional[ConnectorClientOptions] = None,
|
|
141
|
+
):
|
|
142
|
+
"""
|
|
143
|
+
Initialize a KustoClient.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
connection_runtime_url: The connection runtime URL from Azure Portal.
|
|
147
|
+
token_provider: Optional token provider. Defaults to ManagedIdentityTokenProvider.
|
|
148
|
+
options: Optional connector client options.
|
|
149
|
+
"""
|
|
150
|
+
if not connection_runtime_url:
|
|
151
|
+
raise ValueError("connection_runtime_url cannot be None or empty")
|
|
152
|
+
|
|
153
|
+
if token_provider is None:
|
|
154
|
+
token_provider = ManagedIdentityTokenProvider()
|
|
155
|
+
|
|
156
|
+
super().__init__(token_provider, options)
|
|
157
|
+
self._connection_runtime_url = connection_runtime_url.rstrip('/')
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def connector_name(self) -> str:
|
|
161
|
+
return "kusto"
|
|
162
|
+
|
|
163
|
+
async def list_kusto_results_async(
|
|
164
|
+
self,
|
|
165
|
+
input: QueryAndListSchema,
|
|
166
|
+
):
|
|
167
|
+
"""
|
|
168
|
+
Run KQL query
|
|
169
|
+
|
|
170
|
+
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.
|
|
171
|
+
"""
|
|
172
|
+
path = f"{self._connection_runtime_url}/ListKustoResults/false"
|
|
173
|
+
|
|
174
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
175
|
+
|
|
176
|
+
if not (200 <= response.status < 300):
|
|
177
|
+
raise ConnectorException(
|
|
178
|
+
f"POST {path}",
|
|
179
|
+
response.status,
|
|
180
|
+
response.text,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
if not response.text:
|
|
184
|
+
return None
|
|
185
|
+
|
|
186
|
+
import json
|
|
187
|
+
return json.loads(response.text)
|
|
188
|
+
|
|
189
|
+
async def list_kusto_show_command_results_async(
|
|
190
|
+
self,
|
|
191
|
+
input: ControlCommandAndListSchema,
|
|
192
|
+
):
|
|
193
|
+
"""
|
|
194
|
+
Run show control command
|
|
195
|
+
|
|
196
|
+
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.
|
|
197
|
+
"""
|
|
198
|
+
path = f"{self._connection_runtime_url}/ListKustoShowCommandResults"
|
|
199
|
+
|
|
200
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
201
|
+
|
|
202
|
+
if not (200 <= response.status < 300):
|
|
203
|
+
raise ConnectorException(
|
|
204
|
+
f"POST {path}",
|
|
205
|
+
response.status,
|
|
206
|
+
response.text,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if not response.text:
|
|
210
|
+
return None
|
|
211
|
+
|
|
212
|
+
import json
|
|
213
|
+
return json.loads(response.text)
|
|
214
|
+
|
|
215
|
+
async def run_kusto_query_and_visualize_results_async(
|
|
216
|
+
self,
|
|
217
|
+
input: QueryAndVisualizeSchema,
|
|
218
|
+
):
|
|
219
|
+
"""
|
|
220
|
+
Run KQL query and render a chart
|
|
221
|
+
|
|
222
|
+
Runs the KQL query and returns result as a chart of your choice e.g TableName | where Timestamp > ago(1h) | project timestamp, value.
|
|
223
|
+
"""
|
|
224
|
+
path = f"{self._connection_runtime_url}/RunKustoAndVisualizeResults/false"
|
|
225
|
+
|
|
226
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
227
|
+
|
|
228
|
+
if not (200 <= response.status < 300):
|
|
229
|
+
raise ConnectorException(
|
|
230
|
+
f"POST {path}",
|
|
231
|
+
response.status,
|
|
232
|
+
response.text,
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
if not response.text:
|
|
236
|
+
return None
|
|
237
|
+
|
|
238
|
+
import json
|
|
239
|
+
return json.loads(response.text)
|
|
240
|
+
|
|
241
|
+
async def run_kusto_command_and_visualize_results_async(
|
|
242
|
+
self,
|
|
243
|
+
input: CommandAndVisualizeSchema,
|
|
244
|
+
):
|
|
245
|
+
"""
|
|
246
|
+
Run control command and render a chart
|
|
247
|
+
|
|
248
|
+
Runs the control command and returns the result as a chart of your choice e.g .clear table TableName data.
|
|
249
|
+
"""
|
|
250
|
+
path = f"{self._connection_runtime_url}/RunKustoAndVisualizeResults/true"
|
|
251
|
+
|
|
252
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
253
|
+
|
|
254
|
+
if not (200 <= response.status < 300):
|
|
255
|
+
raise ConnectorException(
|
|
256
|
+
f"POST {path}",
|
|
257
|
+
response.status,
|
|
258
|
+
response.text,
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
if not response.text:
|
|
262
|
+
return None
|
|
263
|
+
|
|
264
|
+
import json
|
|
265
|
+
return json.loads(response.text)
|
|
266
|
+
|
|
267
|
+
async def run_async_control_command_and_wait_async(
|
|
268
|
+
self,
|
|
269
|
+
input: ControlCommandAndListSchema,
|
|
270
|
+
):
|
|
271
|
+
"""
|
|
272
|
+
Run async control command
|
|
273
|
+
|
|
274
|
+
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.
|
|
275
|
+
"""
|
|
276
|
+
path = f"{self._connection_runtime_url}/RunAsyncControlCommandAndWait"
|
|
277
|
+
|
|
278
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
279
|
+
|
|
280
|
+
if not (200 <= response.status < 300):
|
|
281
|
+
raise ConnectorException(
|
|
282
|
+
f"POST {path}",
|
|
283
|
+
response.status,
|
|
284
|
+
response.text,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
if not response.text:
|
|
288
|
+
return None
|
|
289
|
+
|
|
290
|
+
import json
|
|
291
|
+
return json.loads(response.text)
|
|
292
|
+
|
|
293
|
+
async def mcp_kusto_query_management_async(
|
|
294
|
+
self,
|
|
295
|
+
input: MCPQueryRequest,
|
|
296
|
+
session_id: Optional[str] = None,
|
|
297
|
+
):
|
|
298
|
+
"""
|
|
299
|
+
Kusto Query MCP Server
|
|
300
|
+
|
|
301
|
+
This MCP server runs Kusto queries and manages the results.
|
|
302
|
+
"""
|
|
303
|
+
path = f"{self._connection_runtime_url}/mcp/KustoQueryManagement"
|
|
304
|
+
query_params = []
|
|
305
|
+
if session_id is not None:
|
|
306
|
+
query_params.append(f"sessionId={quote(str(session_id).lower() if isinstance(session_id, bool) else str(session_id))}")
|
|
307
|
+
if query_params:
|
|
308
|
+
path += '?' + '&'.join(query_params)
|
|
309
|
+
|
|
310
|
+
response = await self.http_client.send_async("POST", path, body=input)
|
|
311
|
+
|
|
312
|
+
if not (200 <= response.status < 300):
|
|
313
|
+
raise ConnectorException(
|
|
314
|
+
f"POST {path}",
|
|
315
|
+
response.status,
|
|
316
|
+
response.text,
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
if not response.text:
|
|
320
|
+
return None
|
|
321
|
+
|
|
322
|
+
import json
|
|
323
|
+
return json.loads(response.text)
|