bdcontract-client/sdk-go/client/dto.go
2024-11-26 18:54:32 +08:00

120 lines
4.3 KiB
Go

package client
// ClientResponse represents a generic response structure
type ClientResponse[T any] struct {
Data *T `json:"data,omitempty"`
}
// PingResponse is a specific response type for ping operations
type PingResponse struct {
ClientResponse[string] // will contain "pong"
}
// SaveFileRequest represents the request structure for saving files
type SaveFileRequest struct {
Content string `json:"content"`
IsAppend bool `json:"isAppend"`
IsPrivate bool `json:"isPrivate"`
Path string `json:"path"`
}
// ListProjectPermissionRequest represents the request for listing project permissions
type ListProjectPermissionRequest struct {
IsPrivate bool `json:"isPrivate"`
Path string `json:"path"`
}
// ListProjectPermissionResponseData contains permission response data
type ListProjectPermissionResponseData struct {
Permissions []string `json:"permissions"`
YPK string `json:"ypk"`
}
// StartContractByYpkRequest represents the request for starting a contract
type StartContractByYpkRequest struct {
IsPrivate bool `json:"isPrivate"`
Path string `json:"path"`
Script string `json:"script"`
}
// ListAllUsersResponseDataListItem represents a key-value pair
type ListAllUsersResponseDataListItem struct {
Key string `json:"key"`
Value string `json:"value"`
}
// ListAllUsersResponseData contains user listing response data
type ListAllUsersResponseData struct {
KV []ListAllUsersResponseDataListItem `json:"kv"`
Time []ListAllUsersResponseDataListItem `json:"time"`
}
// OnlineContractsItem represents an online contract
type OnlineContractsItem struct {
ContractID string `json:"contractID"`
ContractName string `json:"contractName"`
IsMaster bool `json:"isMaster"`
Type string `json:"type"`
YjsType string `json:"yjsType"`
Extra map[string]interface{} `json:"-"`
}
// OnlineItem represents an online node
type OnlineItem struct {
CIManager string `json:"cimanager"`
ContractVersion int `json:"contractVersion"`
Events int `json:"events"`
IPPort string `json:"ipPort"`
MasterAddress string `json:"masterAddress"`
NodeName string `json:"nodeName"`
PeerID string `json:"peerID"`
PubKey string `json:"pubKey"`
Contracts []OnlineContractsItem `json:"contracts"`
}
// ListNodesResponse represents the response for listing nodes
type ListNodesResponse struct {
Action string `json:"action"`
Offline []string `json:"offline"`
Online []OnlineItem `json:"online"`
}
// DistributeContractResponse represents the response for contract distribution
type DistributeContractResponse struct {
Action string `json:"action"`
Progress string `json:"progress"`
}
// ExecuteContractArgs represents arguments for contract execution
type ExecuteContractArgs struct {
Method string `json:"method,omitempty"`
WithSignature bool `json:"withSignature,omitempty"`
WithDynamicAnalysis bool `json:"withDynamicAnalysis,omitempty"`
}
// ExecuteContractResponse represents the response from contract execution
type ExecuteContractResponse[T any] struct {
Status *bool `json:"status,omitempty"`
Data *T `json:"data,omitempty"`
ExecuteTime *float64 `json:"executeTime,omitempty"`
CID *string `json:"cid,omitempty"`
IsPrivate *bool `json:"isPrivate,omitempty"`
AdditionalData map[string]interface{} `json:"-"`
}
// ConfigNodeArgs represents configuration arguments for a node
type ConfigNodeArgs struct {
NodeName string `json:"nodeName,omitempty"`
DataChain string `json:"dataChain,omitempty"`
MasterAddress string `json:"masterAddress,omitempty"`
NodeCenter string `json:"nodeCenter,omitempty"`
LHSProxyAddress string `json:"LHSProxyAddress,omitempty"`
ExtraConfig map[string]string `json:"-"`
}
// LoadNodeConfigResponseData represents the response data for node configuration
type LoadNodeConfigResponseData struct {
DoipConfig string `json:"doipConfig"`
ExtraData map[string]string `json:"-"`
}