ui

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelTerminateAction = "terminate"
	ChannelPauseAction     = "pause"
	ChannelResumeAction    = "resume"
	ChannelCloseAction     = "close" // Client only.
)

Actions that change a status of a channel.

View Source
const (
	// CRC16("github.com/privatix/dappctrl/ui") = 0x2F5D
	ErrAccessDenied errors.Error = 0x2F5D<<8 + iota
	ErrInternal
	ErrObjectNotFound
	ErrAccountNotFound
	ErrChannelNotFound
	ErrTemplateNotFound
	ErrDefaultGasPriceNotFound
	ErrEmptyPassword
	ErrMinConfirmationsNotFound
	ErrOfferingNotFound
	ErrPasswordExists
	ErrProductNotFound
	ErrInvalidTemplateType
	ErrMalformedTemplate
	ErrDepositTooSmall
	ErrBadUnitPriceRange
	ErrBadUnitType
	ErrBillingType
	ErrBadOfferingStatusAction
	ErrBadObjectType
	ErrFailedToDecodePrivateKey
	ErrFailedToDecryptPKey
	ErrPrivateKeyNotFound
	ErrTokenAmountTooSmall
	ErrBadDestination
	ErrBadAction
	ErrNotAllowedForAgent
	ErrJobNotFound
	ErrBadServiceEndpointAddress
	ErrInvalidValueForSetting
	ErrInconsistentSOMCSwitch
	ErrSOMCIsNotAvailable
)

Errors.

View Source
const (
	TypeAccount  = "account"
	TypeUser     = "user"
	TypeTemplate = "template"
	TypeProduct  = "product"
	TypeOffering = "offering"
	TypeChannel  = "channel"
	TypeSession  = "session"
	TypeContract = "contract"
	TypeEndpoint = "endpoint"
	TypeJob      = "job"
	TypeEthTx    = "ethTx"
)

Objects types.

View Source
const (
	PublishOffering    = "publish"
	PopupOffering      = "popup"
	DeactivateOffering = "deactivate"
)

Actions for Agent that change offerings state.

View Source
const AccountAggregatedType = "accountAggregated"

AccountAggregatedType is related type to aggregate transactions for a specific account.

Variables

OfferingChangeActions associates an action with a job type.

View Source
var PermissionsToString = map[int]string{
	data.ReadOnly:  "readOnly",
	data.ReadWrite: "readWrite",
}

PermissionsToString associates a setting permissions with a title.

Functions

This section is empty.

Types

type AccountParams

type AccountParams struct {
	Name      string `json:"name"`
	IsDefault bool   `json:"isDefault"`
	InUse     bool   `json:"inUse"`
}

AccountParams is format of input to create an account.

type AccountParamsWithHexKey

type AccountParamsWithHexKey struct {
	AccountParams
	PrivateKeyHex data.HexString `json:"privateKeyHex"`
}

AccountParamsWithHexKey is format of input to create account with given key.

type ClientChannelInfo

type ClientChannelInfo struct {
	ID           string         `json:"id"`
	Agent        string         `json:"agent"`
	Client       string         `json:"client"`
	Offering     string         `json:"offering"`
	OfferingHash data.HexString `json:"offeringHash"`
	Deposit      uint64         `json:"deposit"`

	ChStat chanStatusBlock `json:"channelStatus"`
	Job    jobBlock        `json:"job"`
	Usage  *Usage          `json:"usage"`
}

ClientChannelInfo is information of client channel.

type GetAgentChannelsResult

type GetAgentChannelsResult struct {
	Items      []data.Channel `json:"items"`
	TotalItems int            `json:"totalItems"`
}

GetAgentChannelsResult is result of GetAgentChannels method.

type GetAgentOfferingsResult

type GetAgentOfferingsResult struct {
	Items      []data.Offering `json:"items"`
	TotalItems int             `json:"totalItems"`
}

GetAgentOfferingsResult is result of GetAgentOfferings method.

type GetClientChannelsResult

type GetClientChannelsResult struct {
	Items      []ClientChannelInfo `json:"items"`
	TotalItems int                 `json:"totalItems"`
}

GetClientChannelsResult is result of GetClientChannels method.

type GetClientOfferingsFilterParamsResult

type GetClientOfferingsFilterParamsResult struct {
	Countries []string `json:"countries"`
	MinPrice  uint64   `json:"minPrice"`
	MaxPrice  uint64   `json:"maxPrice"`
}

GetClientOfferingsFilterParamsResult is result of GetClientOfferingsFilterParams method.

type GetClientOfferingsResult

type GetClientOfferingsResult struct {
	Items      []data.Offering `json:"items"`
	TotalItems int             `json:"totalItems"`
}

GetClientOfferingsResult is result of GetClientOfferings method.

type GetEthTransactionsResult

type GetEthTransactionsResult struct {
	Items      []data.EthTx `json:"items"`
	TotalItems int          `json:"totalItems"`
}

GetEthTransactionsResult is result of GetEthTransactions method.

type GetLogsResult

type GetLogsResult struct {
	Items      []data.LogEvent `json:"items"`
	TotalItems int             `json:"totalItems"`
}

GetLogsResult is result of GetLogs method.

type Handler

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

Handler is an UI RPC handler.

func NewHandler

func NewHandler(logger log.Logger, db *reform.DB,
	queue job.Queue, pwdStorage data.PWDGetSetter,
	encryptKeyFunc data.EncryptedKeyFunc,
	decryptKeyFunc data.ToPrivateKeyFunc, userRole string,
	processor *proc.Processor,
	somcClientBuilder somc.ClientBuilderInterface,
	token TokenMakeChecker) *Handler

NewHandler creates a new handler.

func (*Handler) AcceptOffering

func (h *Handler) AcceptOffering(tkn string, account data.HexString,
	offering string, deposit, gasPrice uint64) (*string, error)

AcceptOffering initiates JobClientPreChannelCreate job.

func (*Handler) ChangeChannelStatus

func (h *Handler) ChangeChannelStatus(tkn, channel, action string) error

ChangeChannelStatus updates channel state.

func (*Handler) ChangeOfferingStatus

func (h *Handler) ChangeOfferingStatus(
	tkn, offering, action string, gasPrice uint64) error

ChangeOfferingStatus initiates JobAgentPreOfferingMsgBCPublish, JobAgentPreOfferingPopUp or JobAgentPreOfferingDelete job, depending on a selected action.

func (*Handler) CreateOffering

func (h *Handler) CreateOffering(tkn string,
	offering *data.Offering) (*string, error)

CreateOffering creates an offering.

func (*Handler) CreateProduct

func (h *Handler) CreateProduct(tkn string,
	product data.Product) (*string, error)

CreateProduct creates new product.

func (*Handler) CreateTemplate

func (h *Handler) CreateTemplate(
	tkn string, template *data.Template) (*string, error)

CreateTemplate creates template.

func (*Handler) ExportPrivateKey

func (h *Handler) ExportPrivateKey(tkn, account string) ([]byte, error)

ExportPrivateKey returns a private key in base64 encoding by account id.

func (*Handler) GenerateAccount

func (h *Handler) GenerateAccount(
	tkn string, params *AccountParams) (*string, error)

GenerateAccount generates new private key and creates new account.

func (*Handler) GetAccounts

func (h *Handler) GetAccounts(tkn string) ([]data.Account, error)

GetAccounts returns accounts.

func (*Handler) GetAgentChannels

func (h *Handler) GetAgentChannels(tkn string,
	channelStatus, serviceStatus []string,
	offset, limit uint) (*GetAgentChannelsResult, error)

GetAgentChannels gets channels for agent.

func (*Handler) GetAgentOfferings

func (h *Handler) GetAgentOfferings(tkn, product string, statuses []string,
	offset, limit uint) (*GetAgentOfferingsResult, error)

GetAgentOfferings returns active offerings available for a agent.

func (*Handler) GetChannelsUsage

func (h *Handler) GetChannelsUsage(tkn string, ids []string) (map[string]Usage, error)

GetChannelsUsage returns detailed usage on channels.

func (*Handler) GetClientChannels

func (h *Handler) GetClientChannels(tkn string, channelStatus,
	serviceStatus []string, offset,
	limit uint) (*GetClientChannelsResult, error)

GetClientChannels gets client channel information.

func (*Handler) GetClientOfferings

func (h *Handler) GetClientOfferings(tkn string, agent data.HexString,
	minUnitPrice, maxUnitPrice uint64, countries []string,
	offset, limit uint) (*GetClientOfferingsResult, error)

GetClientOfferings returns active offerings available for a client.

func (*Handler) GetClientOfferingsFilterParams

func (h *Handler) GetClientOfferingsFilterParams(
	tkn string) (*GetClientOfferingsFilterParamsResult, error)

GetClientOfferingsFilterParams returns offerings filter parameters for client.

func (*Handler) GetEndpoints

func (h *Handler) GetEndpoints(
	tkn, channel, template string) ([]data.Endpoint, error)

GetEndpoints returns endpoints.

func (*Handler) GetEthTransactions

func (h *Handler) GetEthTransactions(tkn, relType, relID string,
	offset, limit uint) (*GetEthTransactionsResult, error)

GetEthTransactions returns transactions by related object.

func (*Handler) GetGUISettings

func (h *Handler) GetGUISettings(tkn string) (map[string]interface{}, error)

GetGUISettings returns gui settings.

func (*Handler) GetLastBlockNumber

func (h *Handler) GetLastBlockNumber(tkn string) (*uint64, error)

GetLastBlockNumber returns last known block number.

func (*Handler) GetLogs

func (h *Handler) GetLogs(tkn string, levels []string, searchText,
	dateFrom, dateTo string, offset, limit uint) (*GetLogsResult, error)

GetLogs returns back end log, paginated.

func (*Handler) GetObject

func (h *Handler) GetObject(
	tkn, objectType, id string) (json.RawMessage, error)

GetObject finds object in a database by id, then returns an object on raw JSON format.

func (*Handler) GetObjectByHash

func (h *Handler) GetObjectByHash(
	tkn, objectType, hash string) (json.RawMessage, error)

GetObjectByHash finds object in a database by hash, then returns an object on raw JSON format.

func (*Handler) GetOfferingIncome

func (h *Handler) GetOfferingIncome(
	tkn, offeringID string) (*uint, error)

GetOfferingIncome returns total receipt balance from all channels of offering with given id.

func (*Handler) GetOfferingUsage

func (h *Handler) GetOfferingUsage(password, offeringID string) (*uint, error)

GetOfferingUsage returns total units used for all channels with a given offering.

func (*Handler) GetProductIncome

func (h *Handler) GetProductIncome(
	tkn, productID string) (*uint, error)

GetProductIncome returns total receipt balance from all channels of all offerings with given product id.

func (*Handler) GetProductUsage

func (h *Handler) GetProductUsage(password, productID string) (*uint, error)

GetProductUsage returns total units used in all channel of all offerings with given product.

func (*Handler) GetProducts

func (h *Handler) GetProducts(tkn string) ([]data.Product, error)

GetProducts returns all products available to the agent.

func (*Handler) GetSessions

func (h *Handler) GetSessions(tkn, channel string) ([]data.Session, error)

GetSessions returns sessions.

func (*Handler) GetSettings

func (h *Handler) GetSettings(tkn string) (map[string]SettingUI, error)

GetSettings returns settings.

func (*Handler) GetTemplates

func (h *Handler) GetTemplates(tkn, tplType string) ([]data.Template, error)

GetTemplates returns templates.

func (*Handler) GetToken

func (h *Handler) GetToken(password string) (*string, error)

GetToken returns token if password is correct.

func (*Handler) GetTotalIncome

func (h *Handler) GetTotalIncome(tkn string) (*uint, error)

GetTotalIncome returns total receipt balance from all channels.

func (*Handler) GetUserRole

func (h *Handler) GetUserRole(tkn string) (*string, error)

GetUserRole returns user role.

func (*Handler) ImportAccountFromHex

func (h *Handler) ImportAccountFromHex(
	tkn string, params *AccountParamsWithHexKey) (*string, error)

ImportAccountFromHex imports private key from hex, creates account and initiates JobAccountUpdateBalances job.

func (*Handler) ImportAccountFromJSON

func (h *Handler) ImportAccountFromJSON(
	tkn string, params *AccountParams, jsonBlob json.RawMessage,
	jsonKeyStorePassword string) (*string, error)

ImportAccountFromJSON imports private key from JSON blob with password, creates account and initiates JobAccountUpdateBalances job.

func (*Handler) ObjectChange

func (h *Handler) ObjectChange(ctx context.Context, tkn, objectType string,
	objectIDs []string) (*rpc.Subscription, error)

ObjectChange subscribes to changes for objects of a given type.

func (*Handler) PingOfferings

func (h *Handler) PingOfferings(tkn string, ids []string) (map[string]bool, error)

PingOfferings given offerings ids pings each of them and returns result of the test.

func (*Handler) SetGUISettings

func (h *Handler) SetGUISettings(tkn string, v map[string]interface{}) error

SetGUISettings sets gui settings.

func (*Handler) SetPassword

func (h *Handler) SetPassword(password string) error

SetPassword sets the password only on the first call. Returns error if password already exists.

func (*Handler) TopUpChannel

func (h *Handler) TopUpChannel(
	tkn, channel string, deposit, gasPrice uint64) error

TopUpChannel initiates JobClientPreChannelTopUp job.

func (*Handler) TransferTokens

func (h *Handler) TransferTokens(
	tkn, account, destination string, amount, gasPrice uint64) error

TransferTokens initiates JobPreAccountAddBalanceApprove or JobPreAccountReturnBalance job depending on the direction of the transfer.

func (*Handler) UpdateAccount

func (h *Handler) UpdateAccount(tkn, account, name string,
	isDefault, inUse bool) error

UpdateAccount updates an account.

func (*Handler) UpdateBalance

func (h *Handler) UpdateBalance(tkn, account string) error

UpdateBalance initiates JobAccountUpdateBalances job.

func (*Handler) UpdateOffering

func (h *Handler) UpdateOffering(tkn string, offering *data.Offering) error

UpdateOffering updates an offering.

func (*Handler) UpdatePassword

func (h *Handler) UpdatePassword(current, new string) error

UpdatePassword updates the password.

func (*Handler) UpdateProduct

func (h *Handler) UpdateProduct(tkn string, product data.Product) error

UpdateProduct updates a product.

func (*Handler) UpdateSettings

func (h *Handler) UpdateSettings(tkn string, items map[string]string) error

UpdateSettings updates settings.

type ObjectChangeResult

type ObjectChangeResult struct {
	Object json.RawMessage `json:"object,omitempty"`
	Job    *data.Job       `json:"job"`
	Error  *rpcsrv.Error   `json:"error,omitempty"`
}

ObjectChangeResult is an ObjectChange notification result.

type SettingUI

type SettingUI struct {
	Value       string `json:"value"`
	Permissions string `json:"permissions"`
}

SettingUI is setting information.

type SimpleToken

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

SimpleToken is a in memory random token.

func NewSimpleToken

func NewSimpleToken() *SimpleToken

NewSimpleToken return simple token.

func (*SimpleToken) Check

func (t *SimpleToken) Check(s string) bool

Check returns true if given string matches stored.

func (*SimpleToken) Make

func (t *SimpleToken) Make() (string, error)

Make makes new random token.

type TokenMakeChecker

type TokenMakeChecker interface {
	Check(string) bool
	Make() (string, error)
}

TokenMakeChecker is token maker and checker.

type Usage

type Usage struct {
	Current  uint64 `json:"current"`
	MaxUsage uint64 `json:"maxUsage"`
	UnitName string `json:"unitName"`
	UnitType string `json:"unitType"`
	Cost     uint64 `json:"cost"`
}

Usage accamulated usage from sessions.

Jump to

Keyboard shortcuts

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