Skip to content

Commit

Permalink
feat(client, resources): adopt latest api spec (#145)
Browse files Browse the repository at this point in the history
Because

- Client code is not up to date with our latest API spec

This commit

- adopt latest api spec in client
- adopt latest api spec in resource wrapper class
- update components schema
- add missing connectors and operators
- refactor start/end to trigger
  • Loading branch information
heiruwu authored May 8, 2024
1 parent 6193be7 commit bafa292
Show file tree
Hide file tree
Showing 41 changed files with 954 additions and 2,904 deletions.
2 changes: 1 addition & 1 deletion bin/specs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Downloading component/schema.json..."
curl https://raw.githubusercontent.com/instill-ai/component/88cf79188084a6f4afd87f715e13f334d3674013/schema.json -L -s -o ./instill/resources/schema/jsons/component.json

connector_schemas=("airbyte" "bigquery" "googlecloudstorage" "stabilityai" "googlesearch" "huggingface" "instill" "numbers" "openai" "pinecone" "redis" "restapi" "website")
connector_schemas=("archetypeai" "airbyte" "bigquery" "googlecloudstorage" "stabilityai" "googlesearch" "huggingface" "instill" "numbers" "openai" "pinecone" "redis" "restapi" "website")

for connector in ${connector_schemas[@]}; do
echo "=====================@@@ Fetching and processing $connector @@@====================="
Expand Down
2 changes: 1 addition & 1 deletion instill/clients/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Client(ABC):
"""Base interface class for creating mgmt/pipeline/connector/model clients.
"""Base interface class for creating mgmt/pipeline/model clients.
Args:
ABC (abc.ABCMeta): std abstract class
Expand Down
79 changes: 19 additions & 60 deletions instill/clients/mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,25 @@ def get_user(
metadata=self.hosts[self.instance].metadata,
).send_sync()

@grpc_handler
def get_remaining_credit(
self,
name: str,
async_enabled: bool = False,
) -> mgmt_interface.GetRemainingCreditResponse:
if async_enabled:
return RequestFactory(
method=self.hosts[self.instance].async_client.GetRemainingCredit,
request=mgmt_interface.GetRemainingCreditRequest(owner=f"users/{name}"),
metadata=self.hosts[self.instance].metadata,
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.GetRemainingCredit,
request=mgmt_interface.GetRemainingCreditRequest(owner=f"users/{name}"),
metadata=self.hosts[self.instance].metadata,
).send_sync()

@grpc_handler
def get_org(
self,
Expand Down Expand Up @@ -637,63 +656,3 @@ def list_pipeline_trigger_chart_records(
request=metric_interface.ListPipelineTriggerChartRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_sync()

@grpc_handler
def list_connector_execute_records(
self,
async_enabled: bool = False,
) -> metric_interface.ListConnectorExecuteRecordsResponse:
if async_enabled:
return RequestFactory(
method=self.hosts[
self.instance
].async_client.ListConnectorExecuteRecords,
request=metric_interface.ListConnectorExecuteRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.ListConnectorExecuteRecords,
request=metric_interface.ListConnectorExecuteRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_sync()

@grpc_handler
def list_connector_execute_table_records(
self,
async_enabled: bool = False,
) -> metric_interface.ListConnectorExecuteTableRecordsResponse:
if async_enabled:
return RequestFactory(
method=self.hosts[
self.instance
].async_client.ListConnectorExecuteTableRecords,
request=metric_interface.ListConnectorExecuteTableRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.ListConnectorExecuteTableRecords,
request=metric_interface.ListConnectorExecuteTableRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_sync()

@grpc_handler
def list_connector_execute_chart_records(
self,
async_enabled: bool = False,
) -> metric_interface.ListConnectorExecuteChartRecordsResponse:
if async_enabled:
return RequestFactory(
method=self.hosts[
self.instance
].async_client.ListConnectorExecuteChartRecords,
request=metric_interface.ListConnectorExecuteChartRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_async()

return RequestFactory(
method=self.hosts[self.instance].client.ListConnectorExecuteChartRecords,
request=metric_interface.ListConnectorExecuteChartRecordsRequest(),
metadata=self.hosts[self.instance].metadata,
).send_sync()
Loading

0 comments on commit bafa292

Please sign in to comment.