Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions robosystems_client/extensions/file_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,22 @@ def upload(
table_name=table_name,
)

from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
"body": upload_request,
}

Expand Down Expand Up @@ -195,7 +208,7 @@ def upload(
update_kwargs = {
"graph_id": graph_id,
"file_id": file_id,
"client": self.config.get("client"),
"client": client,
"body": status_update,
}

Expand Down Expand Up @@ -261,9 +274,22 @@ def list(
List of FileInfo objects
"""
try:
from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
}

if table_name:
Expand Down Expand Up @@ -311,10 +337,23 @@ def get(self, graph_id: str, file_id: str) -> Optional[FileInfo]:
FileInfo with multi-layer status tracking, or None if not found
"""
try:
from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"file_id": file_id,
"client": self.config.get("client"),
"client": client,
}

response = get_file(**kwargs)
Expand Down Expand Up @@ -355,10 +394,23 @@ def delete(self, graph_id: str, file_id: str, cascade: bool = False) -> bool:
True if deletion succeeded, False otherwise
"""
try:
from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"file_id": file_id,
"client": self.config.get("client"),
"client": client,
"cascade": cascade,
}

Expand Down
30 changes: 28 additions & 2 deletions robosystems_client/extensions/materialization_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,22 @@ def materialize(
force=options.force,
)

from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
"body": request,
}

Expand Down Expand Up @@ -182,9 +195,22 @@ def status(self, graph_id: str) -> Optional[MaterializationStatus]:
MaterializationStatus with staleness and timing information
"""
try:
from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
}

response = get_materialization_status(**kwargs)
Expand Down
30 changes: 28 additions & 2 deletions robosystems_client/extensions/table_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,22 @@ def list(self, graph_id: str) -> list[TableInfo]:
List of TableInfo objects with metadata
"""
try:
from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
}

response = list_tables(**kwargs)
Expand Down Expand Up @@ -120,9 +133,22 @@ def query(

request = TableQueryRequest(sql=final_query)

from ..client import AuthenticatedClient

if not self.token:
raise Exception("No API key provided. Set X-API-Key in headers.")

client = AuthenticatedClient(
base_url=self.base_url,
token=self.token,
prefix="",
auth_header_name="X-API-Key",
headers=self.headers,
)

kwargs = {
"graph_id": graph_id,
"client": self.config.get("client"),
"client": client,
"body": request,
}

Expand Down