diff --git a/instill/clients/artifact.py b/instill/clients/artifact.py index 055171f..a5fa3cc 100644 --- a/instill/clients/artifact.py +++ b/instill/clients/artifact.py @@ -1,14 +1,17 @@ # pylint: disable=no-member,wrong-import-position,too-many-lines,no-name-in-module +from datetime import datetime from typing import Callable, List, Optional +# common +from google.protobuf import timestamp_pb2 + # artifact import instill.protogen.artifact.artifact.v1alpha.artifact_pb2 as artifact_interface import instill.protogen.artifact.artifact.v1alpha.artifact_public_service_pb2_grpc as artifact_service import instill.protogen.artifact.artifact.v1alpha.chunk_pb2 as chunk_interface import instill.protogen.artifact.artifact.v1alpha.file_catalog_pb2 as file_catalog_interface +import instill.protogen.artifact.artifact.v1alpha.object_pb2 as object_interface import instill.protogen.artifact.artifact.v1alpha.qa_pb2 as qa_interface - -# common import instill.protogen.common.healthcheck.v1beta.healthcheck_pb2 as healthcheck from instill.clients.base import Client, RequestFactory from instill.clients.instance import InstillInstance @@ -520,3 +523,73 @@ def get_file_catalog( ), metadata=self.host.metadata + self.metadata, ).send_sync() + + @grpc_handler + def get_object_upload_url( + self, + namespace_id: str, + object_name: str, + url_expire_days: int, + last_modified_time: datetime, + object_expire_days: int, + async_enabled: bool = False, + ) -> object_interface.GetObjectUploadURLResponse: + timestamp = timestamp_pb2.Timestamp() + timestamp.FromDatetime(last_modified_time) + + if async_enabled: + return RequestFactory( + method=self.host.async_client.GetObjectUploadURL, + request=object_interface.GetObjectUploadURLRequest( + namespace_id=namespace_id, + object_name=object_name, + url_expire_days=url_expire_days, + last_modified_time=timestamp, + object_expire_days=object_expire_days, + ), + metadata=self.host.metadata + self.metadata, + ).send_async() + + return RequestFactory( + method=self.host.client.GetObjectUploadURL, + request=object_interface.GetObjectUploadURLRequest( + namespace_id=namespace_id, + object_name=object_name, + url_expire_days=url_expire_days, + last_modified_time=timestamp, + object_expire_days=object_expire_days, + ), + metadata=self.host.metadata + self.metadata, + ).send_sync() + + @grpc_handler + def get_object_download_url( + self, + namespace_id: str, + object_uid: str, + object_name: str, + url_expire_days: int, + async_enabled: bool = False, + ) -> object_interface.GetObjectDownloadURLResponse: + if async_enabled: + return RequestFactory( + method=self.host.async_client.GetObjectDownloadURL, + request=object_interface.GetObjectDownloadURLRequest( + namespace_id=namespace_id, + object_uid=object_uid, + object_name=object_name, + url_expire_days=url_expire_days, + ), + metadata=self.host.metadata + self.metadata, + ).send_async() + + return RequestFactory( + method=self.host.client.GetObjectDownloadURL, + request=object_interface.GetObjectDownloadURLRequest( + namespace_id=namespace_id, + object_uid=object_uid, + object_name=object_name, + url_expire_days=url_expire_days, + ), + metadata=self.host.metadata + self.metadata, + ).send_sync() diff --git a/instill/clients/model.py b/instill/clients/model.py index a355a1c..120d435 100644 --- a/instill/clients/model.py +++ b/instill/clients/model.py @@ -1,7 +1,8 @@ # pylint: disable=no-member,wrong-import-position,too-many-lines,no-name-in-module +from datetime import datetime from typing import Callable, List, Optional -from google.protobuf import field_mask_pb2 +from google.protobuf import field_mask_pb2, timestamp_pb2 from google.protobuf.struct_pb2 import Struct # common @@ -952,7 +953,6 @@ def list_model_runs( return RequestFactory( method=self.host.async_client.ListModelRuns, request=model_interface.ListModelRunsRequest( - view=model_definition_interface.VIEW_FULL, namespace_id=namespace_id, model_id=model_id, page_size=page_size, @@ -966,7 +966,6 @@ def list_model_runs( return RequestFactory( method=self.host.client.ListModelRuns, request=model_interface.ListModelRunsRequest( - view=model_definition_interface.VIEW_FULL, namespace_id=namespace_id, model_id=model_id, page_size=page_size, @@ -976,3 +975,46 @@ def list_model_runs( ), metadata=self.host.metadata + self.metadata, ).send_sync() + + @grpc_handler + def list_model_runs_by_credit_owner( + self, + start: datetime, + stop: datetime, + page_size: int = 10, + page: int = 0, + order_by: str = "", + filter_str: str = "", + async_enabled: bool = False, + ) -> model_interface.ListModelRunsByCreditOwnerResponse: + start_timestamp = timestamp_pb2.Timestamp() + start_timestamp.FromDatetime(start) + stop_timestamp = timestamp_pb2.Timestamp() + stop_timestamp.FromDatetime(stop) + + if async_enabled: + return RequestFactory( + method=self.host.async_client.ListModelRunsByCreditOwner, + request=model_interface.ListModelRunsByCreditOwnerRequest( + start=start_timestamp, + stop=stop_timestamp, + page_size=page_size, + page=page, + order_by=order_by, + filter=filter_str, + ), + metadata=self.host.metadata + self.metadata, + ).send_async() + + return RequestFactory( + method=self.host.client.ListModelRunsByCreditOwner, + request=model_interface.ListModelRunsByCreditOwnerRequest( + start=start_timestamp, + stop=stop_timestamp, + page_size=page_size, + page=page, + order_by=order_by, + filter=filter_str, + ), + metadata=self.host.metadata + self.metadata, + ).send_sync() diff --git a/instill/clients/pipeline.py b/instill/clients/pipeline.py index b772b9d..de61009 100644 --- a/instill/clients/pipeline.py +++ b/instill/clients/pipeline.py @@ -1,7 +1,8 @@ # pylint: disable=no-member,wrong-import-position,too-many-lines,no-name-in-module +from datetime import datetime from typing import Callable, List, Optional -from google.protobuf import field_mask_pb2 +from google.protobuf import field_mask_pb2, timestamp_pb2 from google.protobuf.struct_pb2 import Struct # common @@ -1329,7 +1330,6 @@ def list_pipeline_runs( request=pipeline_interface.ListPipelineRunsRequest( namespace_id=namespace_id, pipeline_id=pipeline_id, - view=pipeline_interface.Pipeline.VIEW_RECIPE, page=page, page_size=total_size, filter=filter_str, @@ -1343,7 +1343,6 @@ def list_pipeline_runs( request=pipeline_interface.ListPipelineRunsRequest( namespace_id=namespace_id, pipeline_id=pipeline_id, - view=pipeline_interface.Pipeline.VIEW_RECIPE, page=page, page_size=total_size, filter=filter_str, @@ -1389,6 +1388,49 @@ def list_component_runs( metadata=self.host.metadata + self.metadata, ).send_sync() + @grpc_handler + def list_pipeline_runs_by_credit_owner( + self, + start: datetime, + stop: datetime, + page: int = 0, + total_size: int = 10, + filter_str: str = "", + order_by: str = "", + async_enabled: bool = False, + ) -> pipeline_interface.ListPipelineRunsByCreditOwnerResponse: + start_timestamp = timestamp_pb2.Timestamp() + start_timestamp.FromDatetime(start) + stop_timestamp = timestamp_pb2.Timestamp() + stop_timestamp.FromDatetime(stop) + + if async_enabled: + return RequestFactory( + method=self.host.async_client.ListPipelineRunsByCreditOwner, + request=pipeline_interface.ListPipelineRunsByCreditOwnerRequest( + start=start_timestamp, + stop=stop_timestamp, + page=page, + page_size=total_size, + filter=filter_str, + order_by=order_by, + ), + metadata=self.host.metadata + self.metadata, + ).send_async() + + return RequestFactory( + method=self.host.client.ListPipelineRunsByCreditOwner, + request=pipeline_interface.ListPipelineRunsByCreditOwnerRequest( + start=start_timestamp, + stop=stop_timestamp, + page=page, + page_size=total_size, + filter=filter_str, + order_by=order_by, + ), + metadata=self.host.metadata + self.metadata, + ).send_sync() + @grpc_handler def list_connections( self, diff --git a/instill/protogen b/instill/protogen index ce882bf..e7dd3e0 160000 --- a/instill/protogen +++ b/instill/protogen @@ -1 +1 @@ -Subproject commit ce882bf0b2a4587e4b56c803c0fa3d6a8776a247 +Subproject commit e7dd3e08ed5d9872c299da205d2216d365d4ea94