client

package
v0.0.17-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcceptComputeRequest                                = "/compute-requests/{id}/accept"
	DownloadDataAssetByID                               = "/data-assets/{id}/download"
	GetDataAssetsByDataModelID                          = "/data-models/{id}/data-assets"
	CreateAccount                                       = "/accounts"
	RemoveWallet                                        = "/accounts/me/wallets/{address}"
	RefreshToken                                        = "/auth/refresh-token"
	GetComputeRequests                                  = "/compute-requests/me"
	AuthenticateAccount                                 = "/auth"
	GetComputeRequestsReceived                          = "/compute-requests/received"
	GetDataAssetByID                                    = "/data-assets/{id}"
	UpdateDataAssetByID                                 = "/data-assets/{id}"
	DeleteDataAssetByID                                 = "/data-assets/{id}"
	GetDataModelsByUser                                 = "/data-models/me"
	GetComputeRequest                                   = "/compute-requests/{id}"
	GetCreatedDataAssets                                = "/data-assets/created"
	GetDataModelByID                                    = "/data-models/{id}"
	UpdateDataModel                                     = "/data-models/{id}"
	GetMyAccount                                        = "/accounts/me"
	UpdateAccount                                       = "/accounts/me"
	AddWallet                                           = "/accounts/me/wallets"
	DeleteAssignedRoleByACL                             = "/data-assets/{id}/acl/delete"
	GetAllDataAssetsThatTheAuthenticatedUserHasAccessTo = "/data-assets/me"
	GetReceivedDataAssets                               = "/data-assets/received"
	ShareDataAssetByID                                  = "/data-assets/{id}/share"
	GetAccount                                          = "/accounts/{did}"
	GenerateSignMessage                                 = "/auth/message"
	CreateComputeRequest                                = "/compute-requests"
	CreateComputingProcess                              = "/compute-requests/{id}/start"
	CreateANewDataAsset                                 = "/data-assets"
	AssignACLItemsToDataAsset                           = "/data-assets/{id}/acl"
	UpdateACLItemsToDataAsset                           = "/data-assets/{id}/acl"
	GetDataModels                                       = "/data-models"
	CreateDataModel                                     = "/data-models"
)
View Source
const (
	SUI_PRIVATE_KEY_PREFIX = "suiprivkey"
	PRIVATE_KEY_SIZE       = 32
	SUI_ADDRESS_LENGTH     = 20
)
View Source
const SignatureScheme = 3

Variables

View Source
var SIGNATURE_FLAG_TO_SCHEME = map[byte]string{
	0x00: "ED25519",
}

Functions

func AuthMiddleware

func AuthMiddleware(params MiddlewareParams) resty.RequestMiddleware

func CheckJWTTokenExpiration

func CheckJWTTokenExpiration(tokenString string) (bool, error)

func IssueJWT

func IssueJWT(client resty.Client, wallet Wallet) (string, error)

func ValidateEtherumWallet

func ValidateEtherumWallet(wallet string) bool

func ValidateSolanaWallet

func ValidateSolanaWallet(wallet string) bool

func ValidateSuiWallet

func ValidateSuiWallet(walletAddress string) bool

func VerifyEtherumMessage

func VerifyEtherumMessage(signature string, message, walletAddress string) (bool, error)

func VerifySolanaMessage

func VerifySolanaMessage(message, signature, publicKey string) (bool, error)

func VerifySuiMessage

func VerifySuiMessage(signature string, message, walletAddress string) (bool, error)

Types

type ACL

type ACL interface {
	Add(id int64, aclList []ACLRequest) (PublicACL, error)
	Update(id int64, aclList []ACLRequest) (PublicACL, error)
	Delete(id int64, aclList []ACLRequest) (string, error)
}

type ACLImpl

type ACLImpl struct {
	Config Config
}

func NewACLImpl

func NewACLImpl(config Config) *ACLImpl

func (*ACLImpl) Add

func (u *ACLImpl) Add(id int64, aclList []ACLRequest) (PublicACL, error)

func (*ACLImpl) Delete

func (u *ACLImpl) Delete(id int64, aclList []ACLRequest) (string, error)

func (*ACLImpl) Update

func (u *ACLImpl) Update(id int64, aclList []ACLRequest) (PublicACL, error)

type ACLRequest

type ACLRequest struct {
	Address string             `json:"address"`
	Roles   []TypesAccessLevel `json:"roles"`
}

type AcceptedDataAssetResponse

type AcceptedDataAssetResponse struct {
	AcceptedBy  *string `json:"accepted_by"`
	DataAssetId *int    `json:"data_asset_id"`
}

type AccountCreateRequest

type AccountCreateRequest struct {
	Signature     string `json:"signature"`
	Username      string `json:"username"`
	WalletAddress string `json:"wallet_address"`
	Message       string `json:"message"`
}

type AccountUpdateRequest

type AccountUpdateRequest struct {
	ProfilePicture *string `json:"profile_picture"`
	Username       *string `json:"username"`
}

type Accounts

type Accounts interface {
	Create(accountDetails AccountCreateRequest) (string, error)
	GetMe() (MyAccountResponse, error)
	UpdateMe(updateDetails AccountUpdateRequest) (MyAccountResponse, error)
}

type AccountsImpl

type AccountsImpl struct {
	Config Config
	Wallet WalletInterface
}

func NewAccountsImpl

func NewAccountsImpl(config Config) *AccountsImpl

func (*AccountsImpl) Create

func (u *AccountsImpl) Create(accountDetails AccountCreateRequest) (string, error)

func (*AccountsImpl) GetMe

func (u *AccountsImpl) GetMe() (MyAccountResponse, error)

func (*AccountsImpl) UpdateMe

func (u *AccountsImpl) UpdateMe(updateDetails AccountUpdateRequest) (MyAccountResponse, error)

type Auth

type Auth interface {
	Login(message string, signature string, wallet_address string) (string, error)
	GetMessage() (string, error)
	GetRefreshToken() (string, error)
}

type AuthImpl

type AuthImpl struct {
	Config Config
}

func NewAuthImpl

func NewAuthImpl(config Config) *AuthImpl

func (*AuthImpl) GetMessage

func (u *AuthImpl) GetMessage() (string, error)

func (*AuthImpl) GetRefreshToken

func (u *AuthImpl) GetRefreshToken() (string, error)

func (*AuthImpl) Login

func (u *AuthImpl) Login(message string, signature string, wallet_address string) (string, error)

type AuthRequest

type AuthRequest struct {
	Message       string `json:"message"`
	Signature     string `json:"signature"`
	WalletAddress string `json:"wallet_address"`
}

type ComputeRequestAcceptRequest

type ComputeRequestAcceptRequest struct {
	DataAssetId int `json:"data_asset_id"`
}

type ComputeRequestCreateRequest

type ComputeRequestCreateRequest struct {
	Description           string      `json:"description"`
	Title                 string      `json:"title"`
	ComputeFieldName      string      `json:"compute_field_name"`
	ComputeOperation      interface{} `json:"compute_operation"`
	ComputeOperationParam *int        `json:"compute_operation_param"`
	DataModelId           int         `json:"data_model_id"`
}

type ComputeRequestReceivedResponse

type ComputeRequestReceivedResponse struct {
	ComputeOperationParam *int    `json:"compute_operation_param"`
	CreatedAt             *string `json:"created_at"`
	Description           *string `json:"description"`
	Title                 *string `json:"title"`
	ComputeFieldName      *string `json:"compute_field_name"`
	CreatedBy             *string `json:"created_by"`
	DataAssetsIds         *[]int  `json:"data_assets_ids"`
	DataModelId           *int    `json:"data_model_id"`
	Id                    *int    `json:"id"`
	UpdatedAt             *string `json:"updated_at"`
	ComputeOperation      *string `json:"compute_operation"`
}

type ComputeRequestResponse

type ComputeRequestResponse struct {
	Description           *string                      `json:"description"`
	Title                 *string                      `json:"title"`
	ComputeFieldName      *string                      `json:"compute_field_name"`
	CreatedAt             *string                      `json:"created_at"`
	ComputeOperationParam *int                         `json:"compute_operation_param"`
	CreatedBy             *string                      `json:"created_by"`
	DataModelId           *int                         `json:"data_model_id"`
	Id                    *int                         `json:"id"`
	UpdatedAt             *string                      `json:"updated_at"`
	AcceptedDataAssets    *[]AcceptedDataAssetResponse `json:"accepted_data_assets"`
	ComputeOperation      *string                      `json:"compute_operation"`
}

type ComputingProcessResponse

type ComputingProcessResponse struct {
	ComputeRequest *int    `json:"compute_request"`
	ComputeResult  *string `json:"compute_result"`
	ComputeStatus  *string `json:"compute_status"`
	CreatedBy      *string `json:"created_by"`
	Id             *int    `json:"id"`
}

type Config

type Config struct {
	Client *resty.Client
}

type CreateDataAssetRequest

type CreateDataAssetRequest struct {
	Acl            *[]ACLRequest           `json:"acl"`
	Claim          *map[string]interface{} `json:"claim"`
	DataModelId    *int                    `json:"data_model_id"`
	ExpirationDate *string                 `json:"expiration_date"`
	Name           string                  `json:"name"`
	Tags           *[]string               `json:"tags"`
}

type DataAsset

type DataAsset interface {
	Upload(dataAssetInput CreateDataAssetRequest) (DataAssetIDRequestAndResponse, error)
	UploadFile(fileName string, fileContent []byte, aclList *[]ACLRequest, expirationDate *time.Time) (DataAssetIDRequestAndResponse, error)
	GetCreatedByMe(page int, page_size int) (HelperPaginatedResponse[[]PublicDataAsset], error)
	GetReceivedByMe(page int, page_size int) (HelperPaginatedResponse[[]PublicDataAsset], error)
	Get(id int64) (PublicDataAsset, error)
	UpdateAsset(id string, dataAssetInput UpdateDataAssetRequest) (PublicDataAsset, error)
	UpdateFile(id string, fileName string, fileContent []byte, aclList *[]ACLRequest, expirationDate *time.Time) (PublicDataAsset, error)
	DeleteAsset(id int64) (MessageResponse, error)
	Download(id int64) (*FileResponse, error)
	Share(id int64, shareDetails []ShareDataAssetRequest) ([]PublicACL, error)
}

type DataAssetIDRequestAndResponse

type DataAssetIDRequestAndResponse struct {
	Id int `json:"id"`
}

type DataAssetImpl

type DataAssetImpl struct {
	Config Config
}

func NewDataAssetImpl

func NewDataAssetImpl(config Config) *DataAssetImpl

func (*DataAssetImpl) DeleteAsset

func (u *DataAssetImpl) DeleteAsset(id int64) (MessageResponse, error)

func (*DataAssetImpl) Download

func (u *DataAssetImpl) Download(id int64) (*FileResponse, error)

func (*DataAssetImpl) Get

func (u *DataAssetImpl) Get(id int64) (PublicDataAsset, error)

func (*DataAssetImpl) GetCreatedByMe

func (u *DataAssetImpl) GetCreatedByMe(page int, page_size int) (HelperPaginatedResponse[[]PublicDataAsset], error)

func (*DataAssetImpl) GetReceivedByMe

func (u *DataAssetImpl) GetReceivedByMe(page int, page_size int) (HelperPaginatedResponse[[]PublicDataAsset], error)

func (*DataAssetImpl) Share

func (u *DataAssetImpl) Share(id int64, shareDetails []ShareDataAssetRequest) ([]PublicACL, error)

func (*DataAssetImpl) UpdateAsset

func (u *DataAssetImpl) UpdateAsset(id string, dataAssetInput UpdateDataAssetRequest) (PublicDataAsset, error)

func (*DataAssetImpl) UpdateFile

func (u *DataAssetImpl) UpdateFile(id string, fileName string, fileContent []byte, aclList *[]ACLRequest, expirationDate *time.Time) (PublicDataAsset, error)

func (*DataAssetImpl) Upload

func (*DataAssetImpl) UploadFile

func (u *DataAssetImpl) UploadFile(fileName string, fileContent []byte, aclList *[]ACLRequest, expirationDate *time.Time) (DataAssetIDRequestAndResponse, error)

type DataModel

type DataModel interface {
	GetAll(page int, page_size int) (HelperPaginatedResponse[[]DataModelResponse], error)
	Create(dataModelInput DataModelCreateRequest) (DataModelResponse, error)
	GetMy(page int, page_size int) (HelperPaginatedResponse[[]DataModelResponse], error)
	GetById(id int64) (DataModelResponse, error)
	Update(id int64, dataModelInput DataModelUpdateRequest) (DataModelResponse, error)
}

type DataModelCreateRequest

type DataModelCreateRequest struct {
	Description string                 `json:"description"`
	Schema      map[string]interface{} `json:"schema"`
	Tags        *[]string              `json:"tags"`
	Title       string                 `json:"title"`
}

type DataModelImpl

type DataModelImpl struct {
	Config Config
}

func NewDataModelImpl

func NewDataModelImpl(config Config) *DataModelImpl

func (*DataModelImpl) Create

func (u *DataModelImpl) Create(dataModelInput DataModelCreateRequest) (DataModelResponse, error)

func (*DataModelImpl) GetAll

func (u *DataModelImpl) GetAll(page int, page_size int) (HelperPaginatedResponse[[]DataModelResponse], error)

func (*DataModelImpl) GetById

func (u *DataModelImpl) GetById(id int64) (DataModelResponse, error)

func (*DataModelImpl) GetMy

func (u *DataModelImpl) GetMy(page int, page_size int) (HelperPaginatedResponse[[]DataModelResponse], error)

func (*DataModelImpl) Update

func (u *DataModelImpl) Update(id int64, dataModelInput DataModelUpdateRequest) (DataModelResponse, error)

type DataModelResponse

type DataModelResponse struct {
	Schema      map[string]interface{} `json:"schema"`
	Tags        *[]string              `json:"tags"`
	Title       string                 `json:"title"`
	UpdatedAt   string                 `json:"updated_at"`
	CreatedAt   string                 `json:"created_at"`
	Description string                 `json:"description"`
	Id          int                    `json:"id"`
}

type DataModelUpdateRequest

type DataModelUpdateRequest struct {
	Tags        *[]string              `json:"tags"`
	Title       *string                `json:"title"`
	Description *string                `json:"description"`
	Id          int                    `json:"id"`
	Schema      map[string]interface{} `json:"schema"`
}

type DeleteACLRequest

type DeleteACLRequest struct {
	Addresses []string `json:"addresses"`
}

type Error

type Error struct {
	Error string
}

type EtherumService

type EtherumService struct {
	WalletPrivateKey *ecdsa.PrivateKey
	WalletAddress    string
}

func NewEtherumService

func NewEtherumService(walletPrivateKey string) *EtherumService

func (*EtherumService) GetWallet

func (es *EtherumService) GetWallet() string

func (*EtherumService) SignMessage

func (es *EtherumService) SignMessage(message string) (WalletSignMessageType, error)

type FileResponse

type FileResponse struct {
	FileName    string
	FileContent []byte
	FileType    string
}
type HelperLinks struct {
	Last     string `json:"last"`
	Next     string `json:"next"`
	Previous string `json:"previous"`
	First    string `json:"first"`
}

type HelperMeta

type HelperMeta struct {
	CurrentPage  int `json:"current_page"`
	ItemsPerPage int `json:"items_per_page"`
	TotalItems   int `json:"total_items"`
	TotalPages   int `json:"total_pages"`
}

type HelperPaginatedResponse

type HelperPaginatedResponse[T any] struct {
	Data  T           `json:"data"`
	Links HelperLinks `json:"links"`
	Meta  HelperMeta  `json:"meta"`
}

type MessageResponse

type MessageResponse struct {
	Message string `json:"message"`
}

type MiddlewareParams

type MiddlewareParams struct {
	Client *resty.Client
	Wallet WalletService
}

type ModelWalletAddress

type ModelWalletAddress struct {
	AccountId int     `json:"account_id"`
	Address   string  `json:"address"`
	Chain     string  `json:"chain"`
	CreatedAt string  `json:"created_at"`
	Id        int     `json:"id"`
	UpdatedAt *string `json:"updated_at"`
}

type MyAccountResponse

type MyAccountResponse struct {
	Username          string               `json:"username"`
	UsernameUpdatedAt string               `json:"username_updated_at"`
	WalletAddresses   []ModelWalletAddress `json:"wallet_addresses"`
	CreatedAt         string               `json:"created_at"`
	Did               string               `json:"did"`
	ProfilePicture    *string              `json:"profile_picture"`
	StorageSize       int                  `json:"storage_size"`
	UpdatedAt         string               `json:"updated_at"`
}

type ParsedKeypair

type ParsedKeypair struct {
	Schema    string
	SecretKey []byte
}

type PublicACL

type PublicACL struct {
	IsAuthority   *bool    `json:"is_authority"`
	Roles         []string `json:"roles"`
	SolanaAddress string   `json:"solana_address"`
	UpdatedAt     *string  `json:"updated_at"`
	Address       string   `json:"address"`
	CreatedAt     *string  `json:"created_at"`
	Did           *string  `json:"did"`
}

type PublicAccountResponse

type PublicAccountResponse struct {
	Did            string  `json:"did"`
	ProfilePicture *string `json:"profile_picture"`
	Username       string  `json:"username"`
}

type PublicDataAsset

type PublicDataAsset struct {
	Type           string      `json:"type"`
	CreatedAt      *string     `json:"created_at"`
	CreatedBy      string      `json:"created_by"`
	DataModelId    *int        `json:"data_model_id"`
	ExpirationDate *string     `json:"expiration_date"`
	Fid            string      `json:"fid"`
	Name           string      `json:"name"`
	TransactionId  string      `json:"transaction_id"`
	UpdatedAt      *string     `json:"updated_at"`
	Acl            []PublicACL `json:"acl"`
	Id             int         `json:"id"`
	Size           int         `json:"size"`
	Tags           *[]string   `json:"tags"`
}

type ResponsesMessageResponse

type ResponsesMessageResponse struct {
	Message string `json:"message"`
}

type SDK

type SDK struct {
	DataAssets DataAsset
	DataModel  DataModel
	Account    *AccountsImpl
	ACL        ACL
	Auth       Auth
}

func NewSDK

func NewSDK(config SDKConfig) *SDK

func (*SDK) Reinitialize

func (sdk *SDK) Reinitialize(config SDKConfig) *SDK

type SDKConfig

type SDKConfig struct {
	ApiKey        string
	WalletDetails WalletDetails
	URL           string
}

type ShareDataAssetRequest

type ShareDataAssetRequest struct {
	Addresses []string `json:"addresses"`
}

type SigFlag

type SigFlag byte
const (
	SigFlagEd25519 SigFlag = 0x00
)

type SignaturePubkeyPair

type SignaturePubkeyPair struct {
	SignatureScheme string
	Signature       []byte
	PubKey          []byte
}

type SolanaService

type SolanaService struct {
	// contains filtered or unexported fields
}

func NewSolanaService

func NewSolanaService(walletPrivateKey string) *SolanaService

func (*SolanaService) GetWallet

func (ss *SolanaService) GetWallet() string

func (*SolanaService) SignMessage

func (ss *SolanaService) SignMessage(message string) (WalletSignMessageType, error)

type SuiService

type SuiService struct {
	// contains filtered or unexported fields
}

func NewSuiService

func NewSuiService(walletPrivateKey string) *SuiService

Note this is a custom implementation of Sui Wallet in go.

func (*SuiService) GetWallet

func (es *SuiService) GetWallet() string

func (*SuiService) SignMessage

func (es *SuiService) SignMessage(message string) (WalletSignMessageType, error)

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

type TypesAccessLevel

type TypesAccessLevel string
const (
	RoleView   TypesAccessLevel = "view"
	RoleUpdate TypesAccessLevel = "update"
	RoleDelete TypesAccessLevel = "delete"
	RoleShare  TypesAccessLevel = "share"
)

type TypesComputeOperation

type TypesComputeOperation string
const (
	ComputeOperationAdd                TypesComputeOperation = "add"
	ComputeOperationSubtract           TypesComputeOperation = "subtract"
	ComputeOperationMultiply           TypesComputeOperation = "multiply"
	ComputeOperationDivide             TypesComputeOperation = "divide"
	ComputeOperationSum                TypesComputeOperation = "sum"
	ComputeOperationGreaterThan        TypesComputeOperation = "greater_than"
	ComputeOperationGreaterThanOrEqual TypesComputeOperation = "greater_than_or_equal"
	ComputeOperationLessThan           TypesComputeOperation = "less_than"
	ComputeOperationEqual              TypesComputeOperation = "equal"
	ComputeOperationNotEqual           TypesComputeOperation = "not_equal"
	ComputeOperationExponential        TypesComputeOperation = "exponential"
	ComputeOperationRemainder          TypesComputeOperation = "remainder"
)

type UpdateDataAssetRequest

type UpdateDataAssetRequest struct {
	Claim          *map[string]interface{} `json:"claim"`
	ExpirationDate *string                 `json:"expiration_date"`
	Name           *string                 `json:"name"`
}

type Wallet

type Wallet interface {
	SignMessage(message string) (WalletSignMessageType, error)
}

type WalletCreateRequest

type WalletCreateRequest struct {
	Address string `json:"address"`
}

type WalletDetails

type WalletDetails struct {
	PrivateKey string
	WalletType WalletTypeEnum
}

type WalletImpl

type WalletImpl struct {
	Config Config
}

func NewWalletImpl

func NewWalletImpl(config Config) *WalletImpl

func (*WalletImpl) Add

func (u *WalletImpl) Add(address string) (MyAccountResponse, error)

func (*WalletImpl) Remove

func (u *WalletImpl) Remove(address string) (MyAccountResponse, error)

type WalletInterface

type WalletInterface interface {
	Add(address string) (MyAccountResponse, error)
	Remove(address string) (MyAccountResponse, error)
}

type WalletService

type WalletService struct {
	Wallet        Wallet
	WalletType    WalletTypeEnum
	WalletPrivKey string
}

func NewWalletService

func NewWalletService(walletPrivateKey string, walletType WalletTypeEnum) (*WalletService, error)

func (*WalletService) SignMessage

func (ws *WalletService) SignMessage(message string) (WalletSignMessageType, error)

type WalletSignMessageType

type WalletSignMessageType struct {
	Signature  string
	SigningKey string
}

type WalletTypeEnum

type WalletTypeEnum string
const (
	Ethereum WalletTypeEnum = "ethereum"
	Solana   WalletTypeEnum = "solana"
	Sui      WalletTypeEnum = "sui"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL