robosystems-client 0.1.9__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.
Potentially problematic release.
This version of robosystems-client might be problematic. Click here for more details.
- robosystems_client/__init__.py +14 -0
- robosystems_client/api/__init__.py +1 -0
- robosystems_client/api/agent/__init__.py +1 -0
- robosystems_client/api/agent/query_financial_agent.py +423 -0
- robosystems_client/api/auth/__init__.py +1 -0
- robosystems_client/api/auth/check_password_strength.py +172 -0
- robosystems_client/api/auth/complete_sso_auth.py +177 -0
- robosystems_client/api/auth/generate_sso_token.py +174 -0
- robosystems_client/api/auth/get_captcha_config.py +87 -0
- robosystems_client/api/auth/get_current_auth_user.py +220 -0
- robosystems_client/api/auth/get_password_policy.py +134 -0
- robosystems_client/api/auth/login_user.py +181 -0
- robosystems_client/api/auth/logout_user.py +169 -0
- robosystems_client/api/auth/refresh_session.py +174 -0
- robosystems_client/api/auth/register_user.py +189 -0
- robosystems_client/api/auth/sso_login.py +177 -0
- robosystems_client/api/auth/sso_token_exchange.py +181 -0
- robosystems_client/api/backup/__init__.py +1 -0
- robosystems_client/api/backup/create_backup.py +401 -0
- robosystems_client/api/backup/export_backup.py +225 -0
- robosystems_client/api/backup/get_backup_download_url.py +258 -0
- robosystems_client/api/backup/get_backup_stats.py +182 -0
- robosystems_client/api/backup/kuzu_backup_health.py +202 -0
- robosystems_client/api/backup/list_backups.py +217 -0
- robosystems_client/api/backup/restore_backup.py +401 -0
- robosystems_client/api/billing/__init__.py +1 -0
- robosystems_client/api/billing/get_available_subscription_plans_v1_graph_id_billing_available_plans_get.py +198 -0
- robosystems_client/api/billing/get_credit_billing_info_v1_graph_id_billing_credits_get.py +210 -0
- robosystems_client/api/billing/get_current_graph_bill.py +285 -0
- robosystems_client/api/billing/get_graph_billing_history.py +329 -0
- robosystems_client/api/billing/get_graph_monthly_bill.py +315 -0
- robosystems_client/api/billing/get_graph_pricing_info_v1_graph_id_billing_pricing_get.py +198 -0
- robosystems_client/api/billing/get_graph_subscription_v1_graph_id_billing_subscription_get.py +198 -0
- robosystems_client/api/billing/get_graph_usage_details.py +350 -0
- robosystems_client/api/billing/upgrade_graph_subscription_v1_graph_id_billing_subscription_upgrade_post.py +216 -0
- robosystems_client/api/connections/__init__.py +1 -0
- robosystems_client/api/connections/create_connection.py +327 -0
- robosystems_client/api/connections/create_link_token.py +281 -0
- robosystems_client/api/connections/delete_connection.py +278 -0
- robosystems_client/api/connections/exchange_link_token.py +301 -0
- robosystems_client/api/connections/get_connection.py +262 -0
- robosystems_client/api/connections/get_connection_options.py +285 -0
- robosystems_client/api/connections/init_o_auth.py +230 -0
- robosystems_client/api/connections/list_connections.py +314 -0
- robosystems_client/api/connections/oauth_callback.py +318 -0
- robosystems_client/api/connections/sync_connection.py +362 -0
- robosystems_client/api/create/__init__.py +1 -0
- robosystems_client/api/create/create_graph.py +375 -0
- robosystems_client/api/create/get_available_extensions.py +134 -0
- robosystems_client/api/credits_/__init__.py +1 -0
- robosystems_client/api/credits_/check_credit_balance.py +299 -0
- robosystems_client/api/credits_/check_storage_limits.py +249 -0
- robosystems_client/api/credits_/get_credit_summary.py +245 -0
- robosystems_client/api/credits_/get_storage_usage.py +279 -0
- robosystems_client/api/credits_/list_credit_transactions.py +392 -0
- robosystems_client/api/graph_analytics/__init__.py +1 -0
- robosystems_client/api/graph_analytics/get_graph_metrics.py +285 -0
- robosystems_client/api/graph_analytics/get_graph_usage_stats.py +329 -0
- robosystems_client/api/graph_status/__init__.py +1 -0
- robosystems_client/api/graph_status/get_database_health.py +273 -0
- robosystems_client/api/graph_status/get_database_info.py +277 -0
- robosystems_client/api/mcp/__init__.py +1 -0
- robosystems_client/api/mcp/call_mcp_tool.py +432 -0
- robosystems_client/api/mcp/list_mcp_tools.py +265 -0
- robosystems_client/api/operations/__init__.py +1 -0
- robosystems_client/api/operations/cancel_operation.py +246 -0
- robosystems_client/api/operations/get_operation_status.py +273 -0
- robosystems_client/api/operations/stream_operation_events.py +415 -0
- robosystems_client/api/query/__init__.py +1 -0
- robosystems_client/api/query/execute_cypher_query.py +482 -0
- robosystems_client/api/schema/__init__.py +1 -0
- robosystems_client/api/schema/export_graph_schema.py +239 -0
- robosystems_client/api/schema/get_graph_schema_info.py +277 -0
- robosystems_client/api/schema/list_schema_extensions.py +216 -0
- robosystems_client/api/schema/validate_schema.py +326 -0
- robosystems_client/api/service_offerings/__init__.py +1 -0
- robosystems_client/api/service_offerings/get_service_offerings.py +197 -0
- robosystems_client/api/status/__init__.py +1 -0
- robosystems_client/api/status/get_mcp_health.py +136 -0
- robosystems_client/api/status/get_service_status.py +134 -0
- robosystems_client/api/user/__init__.py +1 -0
- robosystems_client/api/user/create_user_api_key.py +205 -0
- robosystems_client/api/user/get_all_credit_summaries.py +256 -0
- robosystems_client/api/user/get_current_user.py +187 -0
- robosystems_client/api/user/get_user_graphs.py +187 -0
- robosystems_client/api/user/list_user_api_keys.py +187 -0
- robosystems_client/api/user/revoke_user_api_key.py +209 -0
- robosystems_client/api/user/select_user_graph.py +213 -0
- robosystems_client/api/user/update_user.py +205 -0
- robosystems_client/api/user/update_user_api_key.py +218 -0
- robosystems_client/api/user/update_user_password.py +218 -0
- robosystems_client/api/user_analytics/__init__.py +1 -0
- robosystems_client/api/user_analytics/get_detailed_user_analytics.py +222 -0
- robosystems_client/api/user_analytics/get_user_usage_overview.py +187 -0
- robosystems_client/api/user_limits/__init__.py +1 -0
- robosystems_client/api/user_limits/get_user_limits.py +190 -0
- robosystems_client/api/user_limits/get_user_usage.py +187 -0
- robosystems_client/api/user_subscriptions/__init__.py +1 -0
- robosystems_client/api/user_subscriptions/cancel_shared_repository_subscription.py +209 -0
- robosystems_client/api/user_subscriptions/get_repository_credits.py +206 -0
- robosystems_client/api/user_subscriptions/get_shared_repository_credits.py +193 -0
- robosystems_client/api/user_subscriptions/get_user_shared_subscriptions.py +213 -0
- robosystems_client/api/user_subscriptions/subscribe_to_shared_repository.py +214 -0
- robosystems_client/api/user_subscriptions/upgrade_shared_repository_subscription.py +228 -0
- robosystems_client/client.py +278 -0
- robosystems_client/errors.py +16 -0
- robosystems_client/extensions/README.md +611 -0
- robosystems_client/extensions/__init__.py +108 -0
- robosystems_client/extensions/auth_integration.py +210 -0
- robosystems_client/extensions/extensions.py +170 -0
- robosystems_client/extensions/operation_client.py +368 -0
- robosystems_client/extensions/query_client.py +375 -0
- robosystems_client/extensions/sse_client.py +520 -0
- robosystems_client/extensions/tests/__init__.py +1 -0
- robosystems_client/extensions/tests/test_integration.py +490 -0
- robosystems_client/extensions/tests/test_unit.py +560 -0
- robosystems_client/extensions/utils.py +526 -0
- robosystems_client/models/__init__.py +379 -0
- robosystems_client/models/account_info.py +79 -0
- robosystems_client/models/add_on_credit_info.py +119 -0
- robosystems_client/models/agent_message.py +68 -0
- robosystems_client/models/agent_request.py +132 -0
- robosystems_client/models/agent_request_context_type_0.py +44 -0
- robosystems_client/models/agent_response.py +132 -0
- robosystems_client/models/agent_response_metadata_type_0.py +44 -0
- robosystems_client/models/api_key_info.py +134 -0
- robosystems_client/models/api_keys_response.py +74 -0
- robosystems_client/models/auth_response.py +82 -0
- robosystems_client/models/auth_response_user.py +44 -0
- robosystems_client/models/available_extension.py +78 -0
- robosystems_client/models/available_extensions_response.py +73 -0
- robosystems_client/models/backup_create_request.py +117 -0
- robosystems_client/models/backup_export_request.py +72 -0
- robosystems_client/models/backup_list_response.py +90 -0
- robosystems_client/models/backup_response.py +200 -0
- robosystems_client/models/backup_restore_request.py +81 -0
- robosystems_client/models/backup_stats_response.py +156 -0
- robosystems_client/models/backup_stats_response_backup_formats.py +44 -0
- robosystems_client/models/cancel_operation_response_canceloperation.py +44 -0
- robosystems_client/models/cancellation_response.py +76 -0
- robosystems_client/models/check_credit_balance_response_checkcreditbalance.py +44 -0
- robosystems_client/models/connection_options_response.py +82 -0
- robosystems_client/models/connection_provider_info.py +203 -0
- robosystems_client/models/connection_provider_info_auth_type.py +11 -0
- robosystems_client/models/connection_provider_info_provider.py +10 -0
- robosystems_client/models/connection_response.py +149 -0
- robosystems_client/models/connection_response_metadata.py +44 -0
- robosystems_client/models/connection_response_provider.py +10 -0
- robosystems_client/models/create_api_key_request.py +82 -0
- robosystems_client/models/create_api_key_response.py +74 -0
- robosystems_client/models/create_connection_request.py +179 -0
- robosystems_client/models/create_connection_request_provider.py +10 -0
- robosystems_client/models/create_graph_request.py +183 -0
- robosystems_client/models/credit_check_request.py +82 -0
- robosystems_client/models/credit_summary.py +128 -0
- robosystems_client/models/credit_summary_response.py +140 -0
- robosystems_client/models/credits_summary_response.py +122 -0
- robosystems_client/models/credits_summary_response_credits_by_addon_item.py +44 -0
- robosystems_client/models/custom_schema_definition.py +194 -0
- robosystems_client/models/custom_schema_definition_metadata.py +49 -0
- robosystems_client/models/custom_schema_definition_nodes_item.py +44 -0
- robosystems_client/models/custom_schema_definition_relationships_item.py +44 -0
- robosystems_client/models/cypher_query_request.py +128 -0
- robosystems_client/models/cypher_query_request_parameters_type_0.py +44 -0
- robosystems_client/models/database_health_response.py +181 -0
- robosystems_client/models/database_info_response.py +191 -0
- robosystems_client/models/detailed_transactions_response.py +124 -0
- robosystems_client/models/detailed_transactions_response_date_range.py +44 -0
- robosystems_client/models/detailed_transactions_response_summary.py +59 -0
- robosystems_client/models/enhanced_credit_transaction_response.py +192 -0
- robosystems_client/models/enhanced_credit_transaction_response_metadata.py +44 -0
- robosystems_client/models/error_response.py +145 -0
- robosystems_client/models/exchange_token_request.py +116 -0
- robosystems_client/models/exchange_token_request_metadata_type_0.py +44 -0
- robosystems_client/models/get_all_credit_summaries_response_getallcreditsummaries.py +44 -0
- robosystems_client/models/get_backup_download_url_response_getbackupdownloadurl.py +44 -0
- robosystems_client/models/get_current_auth_user_response_getcurrentauthuser.py +44 -0
- robosystems_client/models/get_current_graph_bill_response_getcurrentgraphbill.py +44 -0
- robosystems_client/models/get_graph_billing_history_response_getgraphbillinghistory.py +44 -0
- robosystems_client/models/get_graph_monthly_bill_response_getgraphmonthlybill.py +44 -0
- robosystems_client/models/get_graph_schema_info_response_getgraphschemainfo.py +44 -0
- robosystems_client/models/get_graph_usage_details_response_getgraphusagedetails.py +44 -0
- robosystems_client/models/get_mcp_health_response_getmcphealth.py +44 -0
- robosystems_client/models/get_operation_status_response_getoperationstatus.py +44 -0
- robosystems_client/models/get_storage_usage_response_getstorageusage.py +44 -0
- robosystems_client/models/graph_info.py +92 -0
- robosystems_client/models/graph_metadata.py +105 -0
- robosystems_client/models/graph_metrics_response.py +188 -0
- robosystems_client/models/graph_metrics_response_estimated_size.py +44 -0
- robosystems_client/models/graph_metrics_response_health_status.py +44 -0
- robosystems_client/models/graph_metrics_response_node_counts.py +44 -0
- robosystems_client/models/graph_metrics_response_relationship_counts.py +44 -0
- robosystems_client/models/graph_usage_response.py +116 -0
- robosystems_client/models/graph_usage_response_query_statistics.py +44 -0
- robosystems_client/models/graph_usage_response_recent_activity.py +44 -0
- robosystems_client/models/graph_usage_response_storage_usage.py +44 -0
- robosystems_client/models/health_status.py +110 -0
- robosystems_client/models/health_status_details_type_0.py +44 -0
- robosystems_client/models/http_validation_error.py +75 -0
- robosystems_client/models/initial_entity_data.py +212 -0
- robosystems_client/models/kuzu_backup_health_response_kuzubackuphealth.py +44 -0
- robosystems_client/models/link_token_request.py +174 -0
- robosystems_client/models/link_token_request_options_type_0.py +44 -0
- robosystems_client/models/link_token_request_provider_type_0.py +10 -0
- robosystems_client/models/list_connections_provider_type_0.py +10 -0
- robosystems_client/models/list_schema_extensions_response_listschemaextensions.py +44 -0
- robosystems_client/models/login_request.py +68 -0
- robosystems_client/models/logout_user_response_logoutuser.py +44 -0
- robosystems_client/models/mcp_tool_call.py +84 -0
- robosystems_client/models/mcp_tool_call_arguments.py +44 -0
- robosystems_client/models/mcp_tools_response.py +74 -0
- robosystems_client/models/mcp_tools_response_tools_item.py +44 -0
- robosystems_client/models/o_auth_callback_request.py +130 -0
- robosystems_client/models/o_auth_init_request.py +128 -0
- robosystems_client/models/o_auth_init_request_additional_params_type_0.py +44 -0
- robosystems_client/models/o_auth_init_response.py +78 -0
- robosystems_client/models/password_check_request.py +82 -0
- robosystems_client/models/password_check_response.py +112 -0
- robosystems_client/models/password_check_response_character_types.py +44 -0
- robosystems_client/models/password_policy_response.py +66 -0
- robosystems_client/models/password_policy_response_policy.py +44 -0
- robosystems_client/models/plaid_connection_config.py +209 -0
- robosystems_client/models/plaid_connection_config_accounts_type_0_item.py +44 -0
- robosystems_client/models/plaid_connection_config_institution_type_0.py +44 -0
- robosystems_client/models/quick_books_connection_config.py +92 -0
- robosystems_client/models/register_request.py +98 -0
- robosystems_client/models/repository_credits_response.py +101 -0
- robosystems_client/models/repository_plan.py +10 -0
- robosystems_client/models/repository_type.py +10 -0
- robosystems_client/models/response_mode.py +11 -0
- robosystems_client/models/schema_export_response.py +163 -0
- robosystems_client/models/schema_export_response_data_stats_type_0.py +44 -0
- robosystems_client/models/schema_export_response_schema_definition_type_0.py +44 -0
- robosystems_client/models/schema_validation_request.py +142 -0
- robosystems_client/models/schema_validation_request_schema_definition_type_0.py +44 -0
- robosystems_client/models/schema_validation_response.py +227 -0
- robosystems_client/models/schema_validation_response_compatibility_type_0.py +44 -0
- robosystems_client/models/schema_validation_response_stats_type_0.py +44 -0
- robosystems_client/models/sec_connection_config.py +82 -0
- robosystems_client/models/sso_complete_request.py +60 -0
- robosystems_client/models/sso_exchange_request.py +90 -0
- robosystems_client/models/sso_exchange_response.py +78 -0
- robosystems_client/models/sso_login_request.py +60 -0
- robosystems_client/models/sso_token_response.py +78 -0
- robosystems_client/models/storage_limit_response.py +149 -0
- robosystems_client/models/subscription_info.py +180 -0
- robosystems_client/models/subscription_info_metadata.py +44 -0
- robosystems_client/models/subscription_request.py +89 -0
- robosystems_client/models/subscription_response.py +82 -0
- robosystems_client/models/success_response.py +112 -0
- robosystems_client/models/success_response_data_type_0.py +44 -0
- robosystems_client/models/sync_connection_request.py +106 -0
- robosystems_client/models/sync_connection_request_sync_options_type_0.py +44 -0
- robosystems_client/models/sync_connection_response_syncconnection.py +44 -0
- robosystems_client/models/tier_upgrade_request.py +62 -0
- robosystems_client/models/transaction_summary_response.py +126 -0
- robosystems_client/models/update_api_key_request.py +92 -0
- robosystems_client/models/update_password_request.py +76 -0
- robosystems_client/models/update_user_request.py +92 -0
- robosystems_client/models/upgrade_subscription_request.py +82 -0
- robosystems_client/models/user_analytics_response.py +132 -0
- robosystems_client/models/user_analytics_response_api_usage.py +44 -0
- robosystems_client/models/user_analytics_response_graph_usage.py +44 -0
- robosystems_client/models/user_analytics_response_limits.py +44 -0
- robosystems_client/models/user_analytics_response_recent_activity_item.py +44 -0
- robosystems_client/models/user_analytics_response_user_info.py +44 -0
- robosystems_client/models/user_graph_summary.py +134 -0
- robosystems_client/models/user_graphs_response.py +96 -0
- robosystems_client/models/user_limits_response.py +95 -0
- robosystems_client/models/user_response.py +132 -0
- robosystems_client/models/user_subscriptions_response.py +90 -0
- robosystems_client/models/user_usage_response.py +90 -0
- robosystems_client/models/user_usage_response_graphs.py +44 -0
- robosystems_client/models/user_usage_summary_response.py +130 -0
- robosystems_client/models/user_usage_summary_response_usage_vs_limits.py +44 -0
- robosystems_client/models/validation_error.py +88 -0
- robosystems_client/py.typed +1 -0
- robosystems_client/sdk-config.yaml +5 -0
- robosystems_client/types.py +54 -0
- robosystems_client-0.1.9.dist-info/METADATA +302 -0
- robosystems_client-0.1.9.dist-info/RECORD +282 -0
- robosystems_client-0.1.9.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Authentication Integration for RoboSystems SDK Extensions
|
|
2
|
+
|
|
3
|
+
Provides proper integration with the generated SDK authentication system.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Dict, Any
|
|
7
|
+
from ..client import Client, AuthenticatedClient
|
|
8
|
+
from .extensions import RoboSystemsExtensions, RoboSystemsExtensionConfig
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AuthenticatedExtensions(RoboSystemsExtensions):
|
|
12
|
+
"""Extensions with proper authentication integration"""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self, api_key: str, config: RoboSystemsExtensionConfig = None, base_url: str = None
|
|
16
|
+
):
|
|
17
|
+
"""Initialize extensions with API key authentication
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
api_key: RoboSystems API key
|
|
21
|
+
config: Extension configuration
|
|
22
|
+
base_url: API base URL (defaults to production)
|
|
23
|
+
"""
|
|
24
|
+
if config is None:
|
|
25
|
+
config = RoboSystemsExtensionConfig()
|
|
26
|
+
|
|
27
|
+
# Set base URL
|
|
28
|
+
if base_url:
|
|
29
|
+
config.base_url = base_url
|
|
30
|
+
elif not config.base_url:
|
|
31
|
+
config.base_url = "https://api.robosystems.ai"
|
|
32
|
+
|
|
33
|
+
# Add authentication headers
|
|
34
|
+
if not config.headers:
|
|
35
|
+
config.headers = {}
|
|
36
|
+
config.headers["X-API-Key"] = api_key
|
|
37
|
+
config.headers["Authorization"] = f"Bearer {api_key}"
|
|
38
|
+
|
|
39
|
+
super().__init__(config)
|
|
40
|
+
|
|
41
|
+
# Store authenticated client for SDK operations
|
|
42
|
+
self._authenticated_client = AuthenticatedClient(
|
|
43
|
+
base_url=config.base_url, token=api_key, headers=config.headers
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def authenticated_client(self) -> AuthenticatedClient:
|
|
48
|
+
"""Get the authenticated client for direct SDK operations"""
|
|
49
|
+
return self._authenticated_client
|
|
50
|
+
|
|
51
|
+
def execute_cypher_query(
|
|
52
|
+
self, graph_id: str, query: str, parameters: Dict[str, Any] = None
|
|
53
|
+
):
|
|
54
|
+
"""Execute Cypher query using authenticated SDK client"""
|
|
55
|
+
from ..api.query.execute_cypher_query import sync_detailed
|
|
56
|
+
from ..models.cypher_query_request import CypherQueryRequest
|
|
57
|
+
|
|
58
|
+
request = CypherQueryRequest(query=query, parameters=parameters or {})
|
|
59
|
+
|
|
60
|
+
response = sync_detailed(
|
|
61
|
+
graph_id=graph_id, client=self._authenticated_client, body=request
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if response.parsed:
|
|
65
|
+
return {
|
|
66
|
+
"data": getattr(response.parsed, "data", []),
|
|
67
|
+
"columns": getattr(response.parsed, "columns", []),
|
|
68
|
+
"row_count": getattr(response.parsed, "row_count", 0),
|
|
69
|
+
"execution_time_ms": getattr(response.parsed, "execution_time_ms", 0),
|
|
70
|
+
}
|
|
71
|
+
else:
|
|
72
|
+
raise Exception(f"Query failed: {response.status_code}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class CookieAuthExtensions(RoboSystemsExtensions):
|
|
76
|
+
"""Extensions with cookie-based authentication"""
|
|
77
|
+
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
cookies: Dict[str, str],
|
|
81
|
+
config: RoboSystemsExtensionConfig = None,
|
|
82
|
+
base_url: str = None,
|
|
83
|
+
):
|
|
84
|
+
"""Initialize extensions with cookie authentication
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
cookies: Authentication cookies (e.g., {'auth-token': 'token_value'})
|
|
88
|
+
config: Extension configuration
|
|
89
|
+
base_url: API base URL
|
|
90
|
+
"""
|
|
91
|
+
if config is None:
|
|
92
|
+
config = RoboSystemsExtensionConfig()
|
|
93
|
+
|
|
94
|
+
if base_url:
|
|
95
|
+
config.base_url = base_url
|
|
96
|
+
elif not config.base_url:
|
|
97
|
+
config.base_url = "https://api.robosystems.ai"
|
|
98
|
+
|
|
99
|
+
super().__init__(config)
|
|
100
|
+
|
|
101
|
+
# Store cookies for requests
|
|
102
|
+
self._cookies = cookies
|
|
103
|
+
|
|
104
|
+
# Create client with cookies
|
|
105
|
+
self._client = Client(
|
|
106
|
+
base_url=config.base_url, cookies=cookies, headers=config.headers or {}
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def client(self) -> Client:
|
|
111
|
+
"""Get the client for cookie-based operations"""
|
|
112
|
+
return self._client
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class TokenExtensions(RoboSystemsExtensions):
|
|
116
|
+
"""Extensions with JWT/Bearer token authentication"""
|
|
117
|
+
|
|
118
|
+
def __init__(
|
|
119
|
+
self, token: str, config: RoboSystemsExtensionConfig = None, base_url: str = None
|
|
120
|
+
):
|
|
121
|
+
"""Initialize extensions with JWT token
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
token: JWT or Bearer token
|
|
125
|
+
config: Extension configuration
|
|
126
|
+
base_url: API base URL
|
|
127
|
+
"""
|
|
128
|
+
if config is None:
|
|
129
|
+
config = RoboSystemsExtensionConfig()
|
|
130
|
+
|
|
131
|
+
if base_url:
|
|
132
|
+
config.base_url = base_url
|
|
133
|
+
elif not config.base_url:
|
|
134
|
+
config.base_url = "https://api.robosystems.ai"
|
|
135
|
+
|
|
136
|
+
# Add authentication headers
|
|
137
|
+
if not config.headers:
|
|
138
|
+
config.headers = {}
|
|
139
|
+
config.headers["Authorization"] = f"Bearer {token}"
|
|
140
|
+
|
|
141
|
+
super().__init__(config)
|
|
142
|
+
|
|
143
|
+
# Store authenticated client
|
|
144
|
+
self._authenticated_client = AuthenticatedClient(
|
|
145
|
+
base_url=config.base_url, token=token, headers=config.headers
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def authenticated_client(self) -> AuthenticatedClient:
|
|
150
|
+
"""Get the authenticated client"""
|
|
151
|
+
return self._authenticated_client
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def create_extensions(auth_method: str, **kwargs) -> RoboSystemsExtensions:
|
|
155
|
+
"""Factory function to create extensions with proper authentication
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
auth_method: 'api_key', 'cookie', or 'token'
|
|
159
|
+
**kwargs: Authentication parameters
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Configured extensions instance
|
|
163
|
+
|
|
164
|
+
Examples:
|
|
165
|
+
# API Key authentication
|
|
166
|
+
ext = create_extensions('api_key', api_key='your-key', base_url='https://api.robosystems.ai')
|
|
167
|
+
|
|
168
|
+
# Cookie authentication
|
|
169
|
+
ext = create_extensions('cookie', cookies={'auth-token': 'token'})
|
|
170
|
+
|
|
171
|
+
# JWT Token authentication
|
|
172
|
+
ext = create_extensions('token', token='jwt-token')
|
|
173
|
+
"""
|
|
174
|
+
if auth_method == "api_key":
|
|
175
|
+
api_key = kwargs.pop("api_key")
|
|
176
|
+
return AuthenticatedExtensions(api_key, **kwargs)
|
|
177
|
+
|
|
178
|
+
elif auth_method == "cookie":
|
|
179
|
+
cookies = kwargs.pop("cookies")
|
|
180
|
+
return CookieAuthExtensions(cookies, **kwargs)
|
|
181
|
+
|
|
182
|
+
elif auth_method == "token":
|
|
183
|
+
token = kwargs.pop("token")
|
|
184
|
+
return TokenExtensions(token, **kwargs)
|
|
185
|
+
|
|
186
|
+
else:
|
|
187
|
+
raise ValueError(
|
|
188
|
+
f"Unknown auth method: {auth_method}. Use 'api_key', 'cookie', or 'token'"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
# Example usage functions
|
|
193
|
+
def create_production_extensions(api_key: str) -> AuthenticatedExtensions:
|
|
194
|
+
"""Create extensions for production environment"""
|
|
195
|
+
return AuthenticatedExtensions(
|
|
196
|
+
api_key=api_key,
|
|
197
|
+
config=RoboSystemsExtensionConfig(
|
|
198
|
+
base_url="https://api.robosystems.ai", max_retries=3, retry_delay=2000, timeout=60
|
|
199
|
+
),
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def create_development_extensions(api_key: str) -> AuthenticatedExtensions:
|
|
204
|
+
"""Create extensions for development environment"""
|
|
205
|
+
return AuthenticatedExtensions(
|
|
206
|
+
api_key=api_key,
|
|
207
|
+
config=RoboSystemsExtensionConfig(
|
|
208
|
+
base_url="http://localhost:8000", max_retries=5, retry_delay=1000, timeout=30
|
|
209
|
+
),
|
|
210
|
+
)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""RoboSystems SDK Extensions - Main entry point
|
|
2
|
+
|
|
3
|
+
Enhanced clients with SSE support for the RoboSystems API.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Dict, Any, Optional, Callable
|
|
8
|
+
|
|
9
|
+
from .query_client import QueryClient
|
|
10
|
+
from .operation_client import OperationClient
|
|
11
|
+
from .sse_client import SSEClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass
|
|
15
|
+
class RoboSystemsExtensionConfig:
|
|
16
|
+
"""Configuration for RoboSystems extensions"""
|
|
17
|
+
|
|
18
|
+
base_url: Optional[str] = None
|
|
19
|
+
headers: Optional[Dict[str, str]] = None
|
|
20
|
+
max_retries: int = 5
|
|
21
|
+
retry_delay: int = 1000
|
|
22
|
+
timeout: int = 30
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RoboSystemsExtensions:
|
|
26
|
+
"""Main extensions class providing enhanced RoboSystems API functionality"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, config: RoboSystemsExtensionConfig = None):
|
|
29
|
+
if config is None:
|
|
30
|
+
config = RoboSystemsExtensionConfig()
|
|
31
|
+
|
|
32
|
+
# Get base URL from config or use default
|
|
33
|
+
self.config = {
|
|
34
|
+
"base_url": config.base_url or "http://localhost:8000",
|
|
35
|
+
"headers": config.headers or {},
|
|
36
|
+
"max_retries": config.max_retries,
|
|
37
|
+
"retry_delay": config.retry_delay,
|
|
38
|
+
"timeout": config.timeout,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# Initialize clients
|
|
42
|
+
self.query = QueryClient(self.config)
|
|
43
|
+
self.operations = OperationClient(self.config)
|
|
44
|
+
|
|
45
|
+
def monitor_operation(
|
|
46
|
+
self, operation_id: str, on_progress: Optional[Callable] = None
|
|
47
|
+
) -> Any:
|
|
48
|
+
"""Convenience method to monitor any operation"""
|
|
49
|
+
from .operation_client import MonitorOptions
|
|
50
|
+
|
|
51
|
+
options = MonitorOptions(on_progress=on_progress)
|
|
52
|
+
return self.operations.monitor_operation(operation_id, options)
|
|
53
|
+
|
|
54
|
+
def create_sse_client(self) -> SSEClient:
|
|
55
|
+
"""Create custom SSE client for advanced use cases"""
|
|
56
|
+
from .sse_client import SSEConfig
|
|
57
|
+
|
|
58
|
+
sse_config = SSEConfig(
|
|
59
|
+
base_url=self.config["base_url"],
|
|
60
|
+
headers=self.config["headers"],
|
|
61
|
+
max_retries=self.config["max_retries"],
|
|
62
|
+
retry_delay=self.config["retry_delay"],
|
|
63
|
+
timeout=self.config["timeout"],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return SSEClient(sse_config)
|
|
67
|
+
|
|
68
|
+
def close(self):
|
|
69
|
+
"""Clean up all active connections"""
|
|
70
|
+
self.query.close()
|
|
71
|
+
self.operations.close_all()
|
|
72
|
+
|
|
73
|
+
# Convenience methods that delegate to the appropriate clients
|
|
74
|
+
def execute_query(self, graph_id: str, query: str, parameters: Dict[str, Any] = None):
|
|
75
|
+
"""Execute a query using the query client"""
|
|
76
|
+
return self.query.query(graph_id, query, parameters)
|
|
77
|
+
|
|
78
|
+
def stream_query(
|
|
79
|
+
self,
|
|
80
|
+
graph_id: str,
|
|
81
|
+
query: str,
|
|
82
|
+
parameters: Dict[str, Any] = None,
|
|
83
|
+
chunk_size: int = 1000,
|
|
84
|
+
):
|
|
85
|
+
"""Stream a query using the query client"""
|
|
86
|
+
return self.query.stream_query(graph_id, query, parameters, chunk_size)
|
|
87
|
+
|
|
88
|
+
def get_operation_status(self, operation_id: str):
|
|
89
|
+
"""Get operation status using the operation client"""
|
|
90
|
+
return self.operations.get_operation_status(operation_id)
|
|
91
|
+
|
|
92
|
+
def cancel_operation(self, operation_id: str):
|
|
93
|
+
"""Cancel an operation using the operation client"""
|
|
94
|
+
return self.operations.cancel_operation(operation_id)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class AsyncRoboSystemsExtensions:
|
|
98
|
+
"""Async version of the extensions class"""
|
|
99
|
+
|
|
100
|
+
def __init__(self, config: RoboSystemsExtensionConfig = None):
|
|
101
|
+
if config is None:
|
|
102
|
+
config = RoboSystemsExtensionConfig()
|
|
103
|
+
|
|
104
|
+
self.config = {
|
|
105
|
+
"base_url": config.base_url or "http://localhost:8000",
|
|
106
|
+
"headers": config.headers or {},
|
|
107
|
+
"max_retries": config.max_retries,
|
|
108
|
+
"retry_delay": config.retry_delay,
|
|
109
|
+
"timeout": config.timeout,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Initialize async clients
|
|
113
|
+
from .query_client import AsyncQueryClient
|
|
114
|
+
from .operation_client import AsyncOperationClient
|
|
115
|
+
|
|
116
|
+
self.query = AsyncQueryClient(self.config)
|
|
117
|
+
self.operations = AsyncOperationClient(self.config)
|
|
118
|
+
|
|
119
|
+
async def monitor_operation(
|
|
120
|
+
self, operation_id: str, on_progress: Optional[Callable] = None
|
|
121
|
+
) -> Any:
|
|
122
|
+
"""Convenience method to monitor any operation (async)"""
|
|
123
|
+
from .operation_client import MonitorOptions
|
|
124
|
+
|
|
125
|
+
options = MonitorOptions(on_progress=on_progress)
|
|
126
|
+
return await self.operations.monitor_operation(operation_id, options)
|
|
127
|
+
|
|
128
|
+
def create_sse_client(self):
|
|
129
|
+
"""Create custom async SSE client for advanced use cases"""
|
|
130
|
+
from .sse_client import AsyncSSEClient, SSEConfig
|
|
131
|
+
|
|
132
|
+
sse_config = SSEConfig(
|
|
133
|
+
base_url=self.config["base_url"],
|
|
134
|
+
headers=self.config["headers"],
|
|
135
|
+
max_retries=self.config["max_retries"],
|
|
136
|
+
retry_delay=self.config["retry_delay"],
|
|
137
|
+
timeout=self.config["timeout"],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
return AsyncSSEClient(sse_config)
|
|
141
|
+
|
|
142
|
+
async def close(self):
|
|
143
|
+
"""Clean up all active connections (async)"""
|
|
144
|
+
await self.query.close()
|
|
145
|
+
await self.operations.close_all()
|
|
146
|
+
|
|
147
|
+
async def execute_query(
|
|
148
|
+
self, graph_id: str, query: str, parameters: Dict[str, Any] = None
|
|
149
|
+
):
|
|
150
|
+
"""Execute a query using the async query client"""
|
|
151
|
+
return await self.query.query(graph_id, query, parameters)
|
|
152
|
+
|
|
153
|
+
async def stream_query(
|
|
154
|
+
self,
|
|
155
|
+
graph_id: str,
|
|
156
|
+
query: str,
|
|
157
|
+
parameters: Dict[str, Any] = None,
|
|
158
|
+
chunk_size: int = 1000,
|
|
159
|
+
):
|
|
160
|
+
"""Stream a query using the async query client"""
|
|
161
|
+
async for item in self.query.stream_query(graph_id, query, parameters, chunk_size):
|
|
162
|
+
yield item
|
|
163
|
+
|
|
164
|
+
async def get_operation_status(self, operation_id: str):
|
|
165
|
+
"""Get operation status using the async operation client"""
|
|
166
|
+
return await self.operations.get_operation_status(operation_id)
|
|
167
|
+
|
|
168
|
+
async def cancel_operation(self, operation_id: str):
|
|
169
|
+
"""Cancel an operation using the async operation client"""
|
|
170
|
+
return await self.operations.cancel_operation(operation_id)
|