File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -743,6 +743,35 @@ def create_payment_stream(
743
743
)
744
744
745
745
746
+ @pay .command (name = "info" )
747
+ @click .argument ("cluster_path" , metavar = "CLUSTER" )
748
+ @platform_client ()
749
+ def get_payment_info (platform : "PlatformClient" , cluster_path : str ):
750
+ """Display streaming payment information for the given CLUSTER"""
751
+ from silverback .cluster .types import ResourceStatus
752
+
753
+ if "/" not in cluster_path or len (cluster_path .split ("/" )) > 2 :
754
+ raise click .BadArgumentUsage (f"Invalid cluster path: '{ cluster_path } '" )
755
+
756
+ workspace_name , cluster_name = cluster_path .split ("/" )
757
+ if not (workspace_client := platform .workspaces .get (workspace_name )):
758
+ raise click .BadArgumentUsage (f"Unknown workspace: '{ workspace_name } '" )
759
+
760
+ elif not (cluster := workspace_client .clusters .get (cluster_name )):
761
+ raise click .BadArgumentUsage (
762
+ f"Unknown cluster in workspace '{ workspace_name } ': '{ cluster_name } '"
763
+ )
764
+
765
+ elif cluster .status != ResourceStatus .RUNNING :
766
+ raise click .UsageError (f"Cannot fund '{ cluster .name } ': cluster is not running." )
767
+
768
+ elif stream_info := workspace_client .get_stream_info (cluster ):
769
+ click .echo (f"Cluster is funded via '{ stream_info } '." )
770
+
771
+ else :
772
+ click .echo ("Cluster is not funded via ApePay Stream" )
773
+
774
+
746
775
@pay .command (name = "add-time" , cls = ConnectedProviderCommand )
747
776
@account_option ()
748
777
@click .argument ("cluster_path" , metavar = "CLUSTER" )
Original file line number Diff line number Diff line change @@ -247,6 +247,9 @@ class StreamInfo(BaseModel):
247
247
manager : AddressType
248
248
stream_id : int
249
249
250
+ def __str__ (self ) -> str :
251
+ return f"eip155:{ self .chain_id } :{ self .manager } /{ self .stream_id } "
252
+
250
253
251
254
class ClusterInfo (BaseModel ):
252
255
# NOTE: Raw API object (gets exported)
You can’t perform that action at this time.
0 commit comments