bosa-connectors-binary 0.0.9__cp311-cp311-win_amd64.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.
@@ -0,0 +1 @@
1
+ *
Binary file
bosa_connectors.pyi ADDED
@@ -0,0 +1,29 @@
1
+ # This file was generated by Nuitka
2
+
3
+ # Stubs included by default
4
+ from bosa_connectors.helpers.authenticator import BosaAuthenticator
5
+ from module import BosaConnectorModule
6
+ from tool import BOSAConnectorToolGenerator
7
+ from connector import BosaConnector
8
+
9
+
10
+ __name__ = ...
11
+
12
+
13
+
14
+ # Modules used internally, to allow implicit dependencies to be seen:
15
+ import os
16
+ import typing
17
+ import bosa_connectors.auth.BaseAuthenticator
18
+ import abc
19
+ import logging
20
+ import requests
21
+ import requests.exceptions
22
+ import bosa_connectors.auth.ApiKeyAuthenticator
23
+ import pydantic
24
+ import uuid
25
+ import cgi
26
+ import random
27
+ import time
28
+ import inspect
29
+ import gllm_agents
@@ -0,0 +1,385 @@
1
+ Metadata-Version: 2.1
2
+ Name: bosa-connectors-binary
3
+ Version: 0.0.9
4
+ Summary: BOSA Connectors
5
+ Author: Bosa Engineers
6
+ Author-email: bosa-eng@gdplabs.id
7
+ Requires-Python: >=3.11,<3.13
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Provides-Extra: flag-embedding
12
+ Provides-Extra: langchain-huggingface
13
+ Provides-Extra: semantic-router
14
+ Requires-Dist: gllm-agents-binary (==0.0.2)
15
+ Requires-Dist: libmagic (>=1.0,<2.0) ; sys_platform == "win32"
16
+ Requires-Dist: pydantic (>=2.9.2,<3.0.0)
17
+ Requires-Dist: python-magic-bin (>=0.4.14,<0.5.0) ; sys_platform == "win32"
18
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
19
+ Description-Content-Type: text/markdown
20
+
21
+ # BOSA API SDK (Bosa Connector)
22
+
23
+ A Python SDK for seamlessly connecting to APIs that implement BOSA's Plugin Architecture under HTTP Interface. This connector acts as a proxy, simplifying the integration with BOSA-compatible APIs.
24
+
25
+ ## Features
26
+
27
+ - Simple and intuitive API for connecting to BOSA-compatible services
28
+ - Automatic endpoint discovery and schema validation
29
+ - Built-in authentication support (BOSA API Key and User Token)
30
+ - User management and OAuth2 integration flow support
31
+ - Type-safe parameter validation
32
+ - Flexible parameter passing (dictionary or keyword arguments)
33
+ - Retry support for requests that fail (429 or 5xx)
34
+ - Response fields filtering based on action and output
35
+
36
+ ## Installation
37
+
38
+ ### Prerequisites
39
+ - Python 3.11+ - [Install here](https://www.python.org/downloads/)
40
+ - Pip (if using Pip) - [Install here](https://pip.pypa.io/en/stable/installation/)
41
+ - Poetry 1.8.1+ (if using Poetry) - [Install here](https://python-poetry.org/docs/#installation)
42
+ - Git (if using Git) - [Install here](https://git-scm.com/downloads)
43
+ - For git installation:
44
+ - Access to the [GDP Labs SDK github repository](https://github.com/GDP-ADMIN/bosa-sdk)
45
+
46
+ ### 1. Installation from Pypi
47
+ Choose one of the following methods to install the package:
48
+
49
+ #### Using pip
50
+ ```bash
51
+ pip install bosa-connectors-binary
52
+ ```
53
+
54
+ #### Using Poetry
55
+ ```bash
56
+ poetry add bosa-connectors-binary
57
+ ```
58
+
59
+ ### 2. Development Installation (Git)
60
+ For development purposes, you can install directly from the Git repository:
61
+ ```bash
62
+ poetry add "git+ssh://git@github.com/GDP-ADMIN/bosa-sdk.git#subdirectory=python/bosa-connectors"
63
+ ```
64
+
65
+ ## Quick Start
66
+
67
+ Here's a simple example of how to use the BOSA Connector with API key authentication and user token.
68
+
69
+ ### Initialization
70
+
71
+ Before using the connector, you need to initialize it with your BOSA API base URL and API key.
72
+
73
+ ```python
74
+ from bosa_connectors.connector import BosaConnector
75
+
76
+ # Initialize the connector
77
+ bosa = BosaConnector(api_base_url="YOUR_BOSA_API_BASE_URL", api_key="YOUR_API_KEY")
78
+ ```
79
+
80
+ ### Authentication
81
+
82
+ After initializing the connector, you can authenticate with your BOSA API key.
83
+
84
+ ```python
85
+ # User token from authentication
86
+ user_token = "Enter your key here from authentication, or refer to User Authentication section below"
87
+
88
+ # Check if a user has an integration for a connector
89
+ has_integration = bosa.user_has_integration("github", user_token)
90
+
91
+ if not has_integration:
92
+ # Initiate the OAuth2 flow for a connector
93
+ auth_url = bosa.initiate_connector_auth("github", user_token, "https://your-callback-uri.com")
94
+ # Redirect the user to auth_url to complete authentication, we exit here.
95
+ print("Integration with GitHub not found.")
96
+ print(f"Please visit {auth_url} to complete authentication.")
97
+ exit()
98
+ ```
99
+
100
+ Alternatively, you can authenticate the user first and then use their token:
101
+
102
+ ```python
103
+ user = bosa.authenticate_bosa_user("username", "password")
104
+
105
+ # Get user token
106
+ user_token = user.token
107
+ ```
108
+
109
+ ### Basic Example (Direct Execution)
110
+
111
+ It is the basic way to execute actions, where you need to provide the connector name, action name, and user token. The response will contain the data and status:
112
+
113
+ ```python
114
+ # Prepare input parameters
115
+ params = {
116
+ "owner": "gdp-admin",
117
+ "author": "samuellusandi",
118
+ "per_page": 1,
119
+ "sort": "author_date",
120
+ "created_date_start": "2025-02-01",
121
+ "created_date_end": "2025-02-02"
122
+ }
123
+
124
+ # Execute the action with user token
125
+ data, status = bosa.execute("github", "search_commits", token=user_token, max_attempts=1, input_=params)
126
+
127
+ # Print the result
128
+ print(data)
129
+ print(status)
130
+ ```
131
+
132
+ ### Alternative Approach (Fluent Interface)
133
+
134
+ For more complex scenarios or more control over the execution, you can use the fluent interface. We're recommending this approach if you:
135
+
136
+ - Need to execute multiple actions with different parameters
137
+ - Expecting list response
138
+ - Need to execute actions in a loop
139
+
140
+ ```python
141
+ # Prepare input parameters
142
+ params = {
143
+ "owner": "gdp-admin",
144
+ "author": "samuellusandi",
145
+ "per_page": 1,
146
+ "sort": "author_date",
147
+ "created_date_start": "2025-02-01",
148
+ "created_date_end": "2025-02-02"
149
+ }
150
+
151
+ # Create a connector instance to a service
152
+ github = bosa.connect('github')
153
+
154
+ # Execute actions with fluent interface
155
+ response = github.action('list_pull_requests')\
156
+ .params(params)\
157
+ .max_attempts(3)\
158
+ .token('user-token')\
159
+ .run() # Execute and return ActionResponse for advanced data handling
160
+
161
+ # Get initial data
162
+ initial_data = response.get_data()
163
+
164
+ # Iterate the following next pages
165
+ while response.has_next():
166
+ response = response.next_page()
167
+ data = response.get_data()
168
+ # Process data here
169
+ ...
170
+
171
+ # You can also navigate backwards
172
+ while response.has_prev():
173
+ response = response.prev_page()
174
+ data = response.get_data()
175
+ # Process data here
176
+ ...
177
+
178
+ # Execute multiple independent actions using the same connector instance
179
+ commits_response = github.action('list_commits')\
180
+ .params({
181
+ 'owner': 'GDP-ADMIN',
182
+ 'repo': 'bosa',
183
+ 'page': 1,
184
+ 'per_page': 10
185
+ })\
186
+ .token('user-token')\
187
+ .run()
188
+ ```
189
+
190
+ `run` method also available for direct execution from connector instance, without using fluent interface.
191
+
192
+ ```python
193
+ # Prepare input parameters
194
+ params = {
195
+ "owner": "gdp-admin",
196
+ "author": "samuellusandi",
197
+ "per_page": 1,
198
+ "sort": "author_date",
199
+ "created_date_start": "2025-02-01",
200
+ "created_date_end": "2025-02-02"
201
+ }
202
+
203
+ # Execute actions with run method
204
+ response = bosa.run('github', 'list_pull_requests', params)
205
+ print(response.get_data())
206
+ ```
207
+
208
+ ### Working with Files using ConnectorFile
209
+
210
+ When working with APIs that require file uploads or return file downloads, use the `ConnectorFile` model:
211
+
212
+ ```python
213
+ from bosa_connectors.models.file import ConnectorFile
214
+
215
+ # For uploads: Create a ConnectorFile object
216
+ with open("document.pdf", "rb") as f:
217
+ upload_file = ConnectorFile(
218
+ file=f.read(),
219
+ filename="document.pdf",
220
+ content_type="application/pdf"
221
+ )
222
+
223
+ params = {
224
+ "file": upload_file,
225
+ "name": "My Document"
226
+ }
227
+
228
+ # Include in your parameters
229
+ result, status = bosa.execute("google_drive", "upload_file", input_=params)
230
+
231
+ # For downloads: Check response type
232
+ file_result, status = bosa.execute("google_drive", "download_file", input_={"file_id": "123"})
233
+ if isinstance(file_result, ConnectorFile):
234
+ # Save to disk
235
+ with open(file_result.filename or "downloaded_file", "wb") as f:
236
+ f.write(file_result.file)
237
+ ```
238
+
239
+ ## Available Methods
240
+
241
+ ### Connector Instance Methods
242
+
243
+ The connector instance provides several methods for configuring and executing actions:
244
+
245
+ - `connect(name)`: Create a connector instance to a service
246
+ - `action(name)`: Specify the action to execute
247
+ - `params(dict)`: Set request parameters (including pagination parameters like page and per_page). Note that params for each plugin and action could be different
248
+ - `token(str)`: Set the BOSA user token
249
+ - `headers(dict)`: Set custom request headers
250
+ - `max_attempts(number)`: Set the maximum number of retry attempts (default: 1)
251
+ Execution Methods:
252
+
253
+ - `run()`: Execute and return ActionResponse for advanced data handling
254
+ - `execute()`: Execute and return data and status for basic data handling. The data part of the return value can be a ConnectorFile object when the API returns a non-JSON response (such as a file download).
255
+
256
+ ### Response Handling (ActionResponse)
257
+
258
+ The ActionResponse class provides methods for handling the response and pagination:
259
+
260
+ - `get_data()`: Get the current page data (returns the data field from the response). This can return a ConnectorFile object when the API returns a non-JSON response (such as a file download).
261
+ - `get_meta()`: Get the metadata information from the response (e.g., pagination details, total count)
262
+ - `get_status()`: Get the HTTP status code
263
+ - `is_list()`: Check if response is a list
264
+ - `has_next()`: Check if there is a next page
265
+ - `has_prev()`: Check if there is a previous page
266
+ - `next_page()`: Move to and execute next page
267
+ - `prev_page()`: Move to and execute previous page
268
+ - `get_all_items()`: Get all items from all pages (returns a list of objects containing data and meta for each page)
269
+
270
+ ## Data Models
271
+
272
+ The SDK uses the following data models:
273
+
274
+ - `ActionResponseData`: Contains the response data structure with `data` (list, object, or ConnectorFile instance) and `meta` (metadata) fields
275
+ - `InitialExecutorRequest`: Stores the initial request parameters used for pagination and subsequent requests
276
+ - `ConnectorFile`: Represents a file in requests and responses with these properties:
277
+ - `file`: Raw bytes content of the file
278
+ - `filename`: Optional name of the file
279
+ - `content_type`: Optional MIME type of the file
280
+ - `headers`: Optional HTTP headers for the file
281
+
282
+ ## Configuration Parameters
283
+
284
+ - `api_base_url`: The base URL of your BOSA API endpoint (default: "https://api.bosa.id"). This parameter is extremely important as it determines the URL of the BOSA API you are connecting to, and it will be used to populate the available actions/endpoints and their parameters upon initialization.
285
+ - `api_key`: Your BOSA API key for authentication. This is different from plugin-specific API keys, which are managed separately by the BOSA system.
286
+
287
+ ## Execution Parameters
288
+
289
+ - `connector`: The name of the connector to use. This parameter is used to determine the connector's available actions and their parameters.
290
+ - `action`: The name of the action to execute. This parameter is automatically populated by the connector based on the available actions and their parameters. The list of available actions per connector can be found in https://api.bosa.id/docs and are populated through https://api.bosa.id/connectors.
291
+ - `max_attempts`: The maximum number of attempts to make the API request. If the request fails, the connector will retry the request up to this number of times. The default value is 1 if not provided.
292
+ - The retries are handled automatically by the connector, with exponential backoff.
293
+ - The retries are only done for errors that are considered retryable (429 or 5xx).
294
+ - `input_`: The input parameters for the action. This parameter is a dictionary that contains the parameters for the action. The connector will validate the input parameters against the action's schema.
295
+ - To filter response fields, simply add the `response_fields` parameter to the input dictionary. This parameter is a list of field names that will be returned in the response. For nested fields, you can use dot notation, e.g. `user.login` will return the following:
296
+ ```json
297
+ {
298
+ "user": {
299
+ "login": "userlogin"
300
+ }
301
+ }
302
+ ```
303
+ - `token`: Optional BOSA User Token for authenticating requests. When provided, the connector will include this token in the request headers. This is required for user-specific actions or when working with third-party integrations.
304
+
305
+ ## How It Works
306
+
307
+ 1. **Initialization**: When you create a `BosaConnector` instance, and trigger an `execute()`, the connector will first populate and cache the available actions and their parameters. This is done automatically.
308
+
309
+ 2. **Action Discovery**: The connector expects the BOSA API to expose an endpoint that lists all available actions and their parameters. This is handled automatically by BOSA's HTTP Interface.
310
+
311
+ 3. **Execution**: When you call `execute()`, the connector:
312
+ - Validates your input parameters against the action's schema
313
+ - Handles authentication
314
+ - Makes the API request
315
+ - Returns the formatted response
316
+
317
+ ## Compatibility
318
+
319
+ While primarily tested with BOSA's HTTP Interface, this connector should theoretically work with any API that implements BOSA's Plugin Architecture, as long as it:
320
+
321
+ 1. Exposes an endpoint listing available actions and their parameters
322
+ 2. Follows BOSA's standard HTTP Interface specifications (through the Plugin Architecture)
323
+ - All actions must be exposed as `POST` endpoints.
324
+ 3. Implements the required authentication mechanisms
325
+
326
+ ## Error Handling
327
+
328
+ The connector includes built-in error handling for:
329
+
330
+ - Invalid parameters
331
+ - Authentication failures
332
+ - Connection issues
333
+ - API response errors
334
+
335
+ ## User Authentication
336
+
337
+ The BOSA Connector supports user-based authentication which allows for user-specific actions and third-party integrations:
338
+
339
+ ```python
340
+ # Create a new BOSA user
341
+ user_data = bosa.create_bosa_user("username")
342
+ # Save the secret for later use
343
+ user_secret = user_data.secret
344
+
345
+ # Authenticate a user and get their token
346
+ token = bosa.authenticate_bosa_user("username", user_secret)
347
+
348
+ # Get user information
349
+ user_info = bosa.get_user_info(token.token)
350
+ ```
351
+
352
+ ## Integration Management
353
+
354
+ The BOSA Connector provides methods to manage third-party integrations for authenticated users:
355
+
356
+ ```python
357
+ # Check if a user has an integration for a connector
358
+ has_integration = bosa.user_has_integration("github", user_token)
359
+
360
+ # Initiate the OAuth2 flow for a connector
361
+ auth_url = bosa.initiate_connector_auth("github", user_token, "https://your-callback-uri.com")
362
+ # Redirect the user to auth_url to complete authentication
363
+
364
+ # Remove an integration
365
+ remove_result = bosa.remove_integration("github", user_token)
366
+ ```
367
+
368
+ ## References
369
+
370
+ Product Requirements Documents(PRD):
371
+
372
+ - [BOSA Connector - Product Document](https://docs.google.com/document/d/1R6JIGWnKzNg2kRMRSiZ-wwPGe9pOR9rkkEI0Uz-Wtdw/edit?tab=t.y617gs6jfk15#heading=h.uss0d453lcbs)
373
+
374
+ Architecture Documents:
375
+
376
+ - [BOSA Connector - Architecture Document](https://docs.google.com/document/d/1HHUBAkbFAM8sM_Dtx6tmoatR1HeuM6VBfsWEjpgVCtg/edit?tab=t.0#heading=h.bj79ljx9eqg8)
377
+
378
+ Design Documents:
379
+
380
+ - [BOSA Connector - Design Document](https://docs.google.com/document/d/1PghW7uOJcEbT3WNSlZ0FI99o4y24ys0LCyAG8hg3T9o/edit?tab=t.0#heading=h.bj79ljx9eqg8)
381
+
382
+ Implementation Documents:
383
+
384
+ - [BOSA Connector - Implementation Document](https://docs.google.com/document/d/1a8BvggPu5a6PBStgUu2ILse075FjAAgoehUuvxxAajM/edit?tab=t.0#heading=h.bj79ljx9eqg8)
385
+
@@ -0,0 +1,6 @@
1
+ bosa_connectors.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
2
+ bosa_connectors.cp311-win_amd64.pyd,sha256=vRRtz32ut8e65PO1t3ho6fg7YSEJodirM8pzrrsOEhQ,825856
3
+ bosa_connectors.pyi,sha256=DVKPEVM_E3Q_f92puZ_mV4XD7Beo4LYPSEnoYz_BPKE,627
4
+ bosa_connectors_binary-0.0.9.dist-info/METADATA,sha256=f5Q_qxZLVX_0JTmGGHqoELxSCo1ea01wpPQedfy6bl8,14598
5
+ bosa_connectors_binary-0.0.9.dist-info/WHEEL,sha256=-FZBVKyKauScY3vLa8vJR6hBCpAJfFykw2MOwlNKr1g,98
6
+ bosa_connectors_binary-0.0.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.0
3
+ Root-Is-Purelib: false
4
+ Tag: cp311-cp311-win_amd64