harper

package module
v0.0.0-...-08caf0a Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 9 Imported by: 0

README

Harper SDK for Go

PkgGoDev

This is the Go SDK for Harper.

Requirements

  • = Go 1.18

Installation

go get github.com/HarperDB/sdk-go

Quickstart

client := harper.NewClient("http://localhost:9925", "HDB_ADMIN", "password")
client.CreateSchema("dog")

Documentation

Overview

This is a client for the Harper application platform. It mirrors the HTTP API as of version 4.x and makes it very easy to get up and running with Harper and your Go application.

For more information see: https://docs.harperdb.io/

Basics

Instantiate a new client:

client := harper.NewClient("http://localhost:9925", "username", "password")

Index

Examples

Constants

View Source
const (
	CSV_ACTION_INSERT = "insert"
	CSV_ACTION_UPDATE = "update"
)
View Source
const (
	JobStatusCompleted  = "COMPLETE"
	JobStatusInProgress = "IN_PROGRESS"

	DATE_FORMAT = "2006-01-02"
)
View Source
const (
	LogOrderAsc  = "asc"
	LogOrderDesc = "desc"

	LogSearchTypeAll       = ""
	LogSearchTypeTimestamp = "timestamp"
	LogSearchTypeUsername  = "username"
	LogSearchTypeHashValue = "hash_value"
)
View Source
const (
	OP_ADD_COMPONENT                   = "add_component"
	OP_ADD_CUSTOM_FUNCTION_PROJECT     = "add_custom_function_project"
	OP_ADD_NODE                        = "add_node"
	OP_ADD_ROLE                        = "add_role"
	OP_ADD_USER                        = "add_user"
	OP_ALTER_ROLE                      = "alter_role"
	OP_ALTER_USER                      = "alter_user"
	OP_CLUSTER_SET_ROUTES              = "cluster_set_routes"
	OP_CLUSTER_GET_ROUTES              = "cluster_get_routes"
	OP_CLUSTER_DELETE_ROUTES           = "cluster_delete_routes"
	OP_CLUSTER_NETWORK                 = "cluster_network"
	OP_CLUSTER_STATUS                  = "cluster_status"
	OP_CONFIGURE_CLUSTER               = "configure_cluster"
	OP_CREATE_ATTRIBUTE                = "create_attribute"
	OP_CREATE_AUTHENTICATION_TOKENS    = "create_authentication_tokens"
	OP_CREATE_DATABASE                 = "create_database"
	OP_CREATE_SCHEMA                   = "create_schema"
	OP_CREATE_TABLE                    = "create_table"
	OP_CSV_DATA_LOAD                   = "csv_data_load"
	OP_CSV_FILE_LOAD                   = "csv_file_load"
	OP_CSV_URL_LOAD                    = "csv_url_load"
	OP_CUSTOM_FUNCTIONS_STATUS         = "custom_functions_status"
	OP_DELETE_FILES_BEFORE             = "delete_files_before"
	OP_DELETE_TRANSACTION_LOG          = "delete_transaction_logs_before"
	OP_DEPLOY_COMPONENT                = "deploy_component"
	OP_DESCRIBE_ALL                    = "describe_all"
	OP_DESCRIBE_SCHEMA                 = "describe_schema"
	OP_DESCRIBE_DATABASE               = "describe_database"
	OP_DESCRIBE_TABLE                  = "describe_table"
	OP_DESCRIBE_METRIC                 = "describe_metric"
	OP_DELETE                          = "delete"
	OP_DELETE_AUDIT_LOGS_BEFORE        = "delete_audit_logs_before"
	OP_DELETE_RECORDS_BEFORE           = "delete_records_before"
	OP_DROP_ATTRIBUTE                  = "drop_attribute"
	OP_DROP_COMPONENT                  = "drop_component"
	OP_DROP_CUSTOM_FUNCTION            = "drop_custom_function"
	OP_DROP_CUSTOM_FUNCTION_PROJECT    = "drop_custom_function_project"
	OP_DROP_DATABASE                   = "drop_database"
	OP_DROP_ROLE                       = "drop_role"
	OP_DROP_SCHEMA                     = "drop_schema"
	OP_DROP_TABLE                      = "drop_table"
	OP_DROP_USER                       = "drop_user"
	OP_EXPORT_LOCAL                    = "export_local"
	OP_EXPORT_TO_S3                    = "export_to_s3"
	OP_GET_ANALYTICS                   = "get_analytics"
	OP_GET_BACKUP                      = "get_backup"
	OP_GET_CONFIGURATION               = "get_configuration"
	OP_GET_COMPONENT_FILE              = "get_component_file"
	OP_GET_COMPONENTS                  = "get_components"
	OP_GET_CUSTOM_FUNCTION             = "get_custom_function"
	OP_GET_CUSTOM_FUNCTIONS            = "get_custom_functions"
	OP_GET_FINGERPRINT                 = "get_fingerprint"
	OP_GET_JOB                         = "get_job"
	OP_IMPORT_FROM_S3                  = "import_from_s3"
	OP_INSERT                          = "insert"
	OP_INSTALL_NODE_MODULES            = "install_node_modules"
	OP_LIST_METRICS                    = "list_metrics"
	OP_LIST_ROLES                      = "list_roles"
	OP_LIST_USERS                      = "list_users"
	OP_PACKAGE_COMPONENT               = "package_component"
	OP_PACKAGE_CUSTOM_FUNCTION_PROJECT = "package_custom_function_project"
	OP_PURGE_STREAM                    = "purge_stream"
	OP_READ_AUDIT_LOG                  = "read_audit_log"
	OP_READ_LOG                        = "read_log"
	OP_READ_TRANSACTION_LOG            = "read_transaction_log"
	OP_REFRESH_OPERATION_TOKEN         = "refresh_operation_token"
	OP_REGISTRATION_INFO               = "registration_info"
	OP_REMOVE_NODE                     = "remove_node"
	OP_RESTART                         = "restart"
	OP_RESTART_SERVICE                 = "restart_service"
	OP_SEARCH_BY_CONDITIONS            = "search_by_conditions"
	OP_SEARCH_BY_HASH                  = "search_by_hash"
	OP_SEARCH_BY_ID                    = "search_by_id"
	OP_SEARCH_BY_VALUE                 = "search_by_value"
	OP_SEARCH_JOBS                     = "search_jobs_by_start_date"
	OP_SET_CONFIGURATION               = "set_configuration"
	OP_SET_COMPONENT_FILE              = "set_component_file"
	OP_SET_CUSTOM_FUNCTION             = "set_custom_function"
	OP_SET_LICENSE                     = "set_license"
	OP_SET_NODE_REPLICATION            = "set_node_replication"
	OP_SQL                             = "sql"
	OP_SYSTEM_INFORMATION              = "system_information"
	OP_UPDATE                          = "update"
	OP_UPDATE_NODE                     = "update_node"
	OP_UPSERT                          = "upsert"
	OP_USER_INFO                       = "user_info"
)
View Source
const (
	SearchBySQL   = "sql"
	SearchByHash  = "search_by_hash"
	SearchByValue = "search_by_value"
)

Variables

View Source
var (
	ErrJobStatusUnknown = errors.New("unknown job status")
	ErrJobNotFound      = errors.New("job not found")
	ErrNoRows           = errors.New("did not return any rows")
	ErrTooManyRows      = errors.New("did return more than one row")
	ErrNotSingleColumn  = errors.New("expected a single column return")
)
View Source
var AllAttributes = FromStringSlice([]string{"*"})

Functions

This section is empty.

Types

type AffectedResponse

type AffectedResponse struct {
	MessageResponse
	SkippedHashes  []interface{} `json:"skipped_hashes"`
	InsertedHashes []interface{} `json:"inserted_hashes"`
	UpdatedHashes  []interface{} `json:"update_hashes"` // (sic) not updated_hashes
	DeletedHashes  []interface{} `json:"deleted_hashes"`
	UpsertedHashes []interface{} `json:"upserted_hashes"`
}

type Attribute

type Attribute string

type AttributeDesc

type AttributeDesc struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type AttributeList

type AttributeList interface{}

func FromStringSlice

func FromStringSlice(ss []string) AttributeList

type AttributePermissions

type AttributePermissions struct {
	AttributeName string `json:"attribute_name"`
	Read          bool   `json:"read"`
	Insert        bool   `json:"insert"`
	Update        bool   `json:"update"`
}

type AuditLogEntry

type AuditLogEntry struct {
	Operation  string        `json:"operation"`
	UserName   string        `json:"user_name"`
	Timestamp  Timestamp     `json:"timestamp"`
	HashValues []interface{} `json:"hash_values"`
	Records    []map[string]interface{}
}

type CPULoad

type CPULoad struct {
	Load       float64 `json:"load,omitempty"`
	LoadUser   float64 `json:"load_user,omitempty"`
	LoadSystem float64 `json:"load_system,omitempty"`
	LoadNice   float64 `json:"load_nice,omitempty"`
	LoadIdle   float64 `json:"load_idle,omitempty"`
	LoadIRQ    float64 `json:"load_irq,omitempty"`
}

type Client

type Client struct {
	HttpClient *resty.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, username string, password string) *Client
Example
// Connecting to a Harper instance
c := NewClient("http://localhost:9925", "HDB_ADMIN", "password")

// (optional) set some proxy
c.HttpClient.SetProxy("http://localhost:8888")
Example (Https)
// Connecting to a Harper instance
c := NewClient("https://localhost:31283", "HDB_ADMIN", "password")

// with a self-signed certificate
// will most likely fail so disable security check (https)
c.HttpClient.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})

func (*Client) AddComponent

func (c *Client) AddComponent(project string) (*MessageResponse, error)

func (*Client) AddCustomFunctionProject

func (c *Client) AddCustomFunctionProject(project string) (*MessageResponse, error)

func (*Client) AddNode

func (c *Client) AddNode(name, host string, port int, subscriptions []Subscription) error

func (*Client) AddRole

func (c *Client) AddRole(role string, perm Permission) (*Role, error)

func (*Client) AddUser

func (c *Client) AddUser(username, password, roleID string, active bool) error

func (*Client) AlterRole

func (c *Client) AlterRole(id string, role string, perm Permission) (*Role, error)

func (*Client) AlterUser

func (c *Client) AlterUser(username, password, roleID string, active bool) error

func (*Client) CSVDataLoad

func (c *Client) CSVDataLoad(schema, table string, update bool, data io.Reader) (string, error)

CSVDataLoad takes a Reader and executes the CSV Load Data operation if "update" is true, it will not insert but update existing records If successful, returns the Job ID

func (*Client) CSVFileLoad

func (c *Client) CSVFileLoad(schema, table string, update bool, filePath string) (string, error)

CSVFileLoad takes a path of a file which must exist on the server and executes the CSV Load Data operation if "update" is true, it will not insert but update existing records If successful, returns the Job ID

func (*Client) CSVURLLoad

func (c *Client) CSVURLLoad(schema, table string, update bool, csvURL string) (string, error)

CSVURLLoad takes a public URL and executes the CSV Load Data operation if "update" is true, it will not insert but update existing records If successful, returns the Job ID

func (*Client) ClusterNetwork

func (c *Client) ClusterNetwork() (*ClusterNetworkResponse, error)

func (*Client) ClusterStatus

func (c *Client) ClusterStatus() (*ClusterStatusResponse, error)

func (*Client) ConfigureCluster

func (c *Client) ConfigureCluster(connections []ConfigureClusterConnection) (*MessageResponse, error)

func (*Client) CreateAttribute

func (c *Client) CreateAttribute(schema, table string, attribute Attribute) error

func (*Client) CreateAuthenticationTokens

func (c *Client) CreateAuthenticationTokens(username, password string) (*CreateAuthenticationTokensResponse, error)

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(database string) error

func (*Client) CreateSchema

func (c *Client) CreateSchema(schema string) error

CreateSchema creates a new schema. Returns "AlreadyExistsError" if schema already existed.

func (*Client) CreateTable

func (c *Client) CreateTable(schema, table, hashAttribute string) error

func (*Client) CustomFunctionStatus

func (c *Client) CustomFunctionStatus() (*CustomFunctionStatusResponse, error)

func (*Client) Delete

func (c *Client) Delete(schema, table string, hashValues AttributeList) (*AffectedResponse, error)

Delete delete one or more JSON objects from a table. hashValues must be an array of slice

func (*Client) DeleteAuditLogsBefore

func (c *Client) DeleteAuditLogsBefore(schema, table string, timestamp time.Time) (*MessageResponse, error)

func (*Client) DeleteRecordsBefore

func (c *Client) DeleteRecordsBefore(date time.Time, schema, table string) (*DeleteRecordsBeforeResponse, error)

func (*Client) DeleteRoutes

func (c *Client) DeleteRoutes(routes []Route) (response DeleteRouteResponse, err error)

func (*Client) DeleteTransactionLogsBefore

func (c *Client) DeleteTransactionLogsBefore(schema, table string, timestamp time.Time) error

func (*Client) DeployComponent

func (c *Client) DeployComponent(project string, options DeployComponentOptions) (*MessageResponse, error)

func (*Client) DescribeAll

func (c *Client) DescribeAll() (*DescribeAllResponse, error)

func (*Client) DescribeDatabase

func (c *Client) DescribeDatabase(database string) (*MessageResponse, error)

func (*Client) DescribeMetric

func (c *Client) DescribeMetric(metric string) (*DescribeMetricResult, error)

func (*Client) DescribeSchema

func (c *Client) DescribeSchema(schema string) (DescribeSchemaResponse, error)

DescribeSchema returns metadata about a schema.

func (*Client) DescribeTable

func (c *Client) DescribeTable(schema, table string) (*DescribeTableResponse, error)

func (*Client) DropAttribute

func (c *Client) DropAttribute(schema, table string, attribute Attribute) error

func (*Client) DropComponent

func (c *Client) DropComponent(project, file string) (*MessageResponse, error)

func (*Client) DropCustomFunction

func (c *Client) DropCustomFunction(project, type_, file string) (*MessageResponse, error)

func (*Client) DropCustomFunctionProject

func (c *Client) DropCustomFunctionProject(project string) (*MessageResponse, error)

func (*Client) DropDatabase

func (c *Client) DropDatabase(database string) error

func (*Client) DropRole

func (c *Client) DropRole(id string) error

func (*Client) DropSchema

func (c *Client) DropSchema(schema string) error

DropSchema drops a schema. Returns "DoesNotExistError" if schema did not exist.

func (*Client) DropTable

func (c *Client) DropTable(schema, table, hashAttribute string) error

func (*Client) DropUser

func (c *Client) DropUser(username string) error

DropUser deletes a user. Note: this operation is idempotent, it will not throw an error if the user doesn't exist

func (*Client) ExportLocal

func (c *Client) ExportLocal(format, path string, searchOperation SearchOperation) error

func (*Client) ExportToS3

func (c *Client) ExportToS3(format string, s3creds S3Credentials, searchOperation SearchOperation) error

func (*Client) GetAnalytics

func (c *Client) GetAnalytics(req GetAnalyticsRequest) ([]GetAnalyticsResult, error)

func (*Client) GetBackup

func (c *Client) GetBackup(database string, options GetBackupOptions) ([]byte, error)

func (*Client) GetComponentFile

func (c *Client) GetComponentFile(project, file string) (*MessageResponse, error)

func (*Client) GetComponents

func (c *Client) GetComponents() (*GetComponentsResponse, error)

func (*Client) GetConfiguration

func (c *Client) GetConfiguration() (map[string]interface{}, error)

func (*Client) GetCustomFunction

func (c *Client) GetCustomFunction(project, type_, file string) (*MessageResponse, error)

func (*Client) GetCustomFunctions

func (c *Client) GetCustomFunctions() (map[string]interface{}, error)

func (*Client) GetFingerprint

func (c *Client) GetFingerprint() (*GetFingerprintResponse, error)

func (*Client) GetJob

func (c *Client) GetJob(jobID string) (*GetJobResponse, error)

func (*Client) GetRoutes

func (c *Client) GetRoutes() (response GetRouteResponse, err error)

func (*Client) Healthcheck

func (c *Client) Healthcheck() error

Healthcheck does a GET request against the /health endpoint of the configured Harper server and returns an error if it gets a non-200 status, nil otherwise.

func (*Client) ImportFromS3

func (c *Client) ImportFromS3(action, database, table string, s3creds S3Credentials) (*ImportFromS3Response, error)

func (*Client) Insert

func (c *Client) Insert(schema, table string, records interface{}) (*AffectedResponse, error)

Insert inserts one or more JSON objects into a table Hash value of the inserted JSON record MUST be present.

func (*Client) InstallNodeModules

func (c *Client) InstallNodeModules(projects []string, dryRun bool) (*MessageResponse, error)

func (*Client) ListMetrics

func (c *Client) ListMetrics(types []MetricType) ([]ListMetricsResult, error)

func (*Client) ListRoles

func (c *Client) ListRoles() ([]Role, error)

TODO Correct JSON modelling needs to be verified

func (*Client) ListUsers

func (c *Client) ListUsers() ([]User, error)

func (*Client) PackageComponent

func (c *Client) PackageComponent(project string, skipNodeModules bool) (*PackageComponentResponse, error)

func (*Client) PackageCustomFunctionProject

func (c *Client) PackageCustomFunctionProject(project string, skipNodeModules bool) (*PackageCustomFunctionProjectResponse, error)

func (*Client) PurgeStream

func (c *Client) PurgeStream(database, table string, options PurgeStreamOptions) error

func (*Client) RawRequest

func (c *Client) RawRequest(op Operation, result interface{}) error

RawRequest allows raw requests to be made against the client. The recommended route for making calls is via the specific function endpoints.

func (*Client) ReadAuditLog

func (c *Client) ReadAuditLog(schema, table string, comparator string, searchValues interface{}) ([]AuditLogEntry, error)

Leave searchType empty (LogSearchTypeAll) to get all entries.

func (*Client) ReadLog

func (c *Client) ReadLog(limit, start int, from, until time.Time, order string) (*LogResponse, error)

func (*Client) ReadTransactionLog

func (c *Client) ReadTransactionLog(schema, table, comparator string, searchValues interface{}) ([]TxLogEntry, error)

ReadTransactionLog requests the transaction log for a table. Use LogSearchType* constants to filter the log entries by searchValues, which should be an array/slice of searchType. Leave searchType empty (LogSearchTypeAll) to get all entries.

func (*Client) RefreshOperationToken

func (c *Client) RefreshOperationToken(refreshToken string) (*RefreshOperationTokenResponse, error)

func (*Client) RegistrationInfo

func (c *Client) RegistrationInfo() (*RegistrationInfoResponse, error)

func (*Client) RemoveNode

func (c *Client) RemoveNode(name string) error

func (*Client) Restart

func (c *Client) Restart() (*MessageResponse, error)

func (*Client) RestartService

func (c *Client) RestartService(service string) (*MessageResponse, error)

func (*Client) SQLExec

func (c *Client) SQLExec(stmt string, args ...interface{}) (*AffectedResponse, error)

SQLExec executes UPDATE/INSERT/DELETE statements and returns a struct with the affected row hash values. You can use format verbs (%s, %d) in the stmt and an pass the arguments at the end of the function, like in fmt.Printf

func (*Client) SQLGet

func (c *Client) SQLGet(stmt string, args ...interface{}) (interface{}, error)

SQLGet is to query a scalar value from the database. This function is not part of the official Harper API. It executes a SQL statement and expects exactly one object with one key. I.e. SELECT CURRENT_TIMESTAMP Will return the following errors: - ErrNoRows - ErrTooManyRows - ErrNotSingleColumn

func (*Client) SQLSelect

func (c *Client) SQLSelect(v interface{}, stmt string, args ...interface{}) error

SQLSelect executes SELECT statements and returns a record set. You can use format verbs (%s, %d) in the stmt and an pass the arguments at the end of the function, like in fmt.Printf

func (*Client) SearchByConditions

func (c *Client) SearchByConditions(database, table string, v interface{}, conditions []SearchCondition, getAttributes AttributeList, options SearchByConditionsOptions) error

func (*Client) SearchByHash

func (c *Client) SearchByHash(schema, table string, v interface{}, hashValues AttributeList, getAttributes AttributeList) error

SearchByHash fetches records based on the table's hash field (i.e. primary key).

func (*Client) SearchById

func (c *Client) SearchById(database, table string, v interface{}, ids interface{}, getAttributes AttributeList) error

func (*Client) SearchByValue

func (c *Client) SearchByValue(schema, table string, v interface{}, attribute Attribute, value interface{}, getAttributes AttributeList) error

SearchByValue fetches records based on the value of an attribute Wilcards are allowed in `searchValue`

func (*Client) SearchJobsByStartDate

func (c *Client) SearchJobsByStartDate(fromDate, toDate time.Time) ([]GetJobResponse, error)

func (*Client) SetComponentFile

func (c *Client) SetComponentFile(project, file, payload string) (*MessageResponse, error)

func (*Client) SetConfiguration

func (c *Client) SetConfiguration(configuration interface{}) (*MessageResponse, error)

func (*Client) SetConfigurationRequest

func (c *Client) SetConfigurationRequest(op interface{}, result interface{}) error

func (*Client) SetCustomFunction

func (c *Client) SetCustomFunction(project, type_, file, functionContent string) (*MessageResponse, error)

func (*Client) SetLicense

func (c *Client) SetLicense(key, company string) error

func (*Client) SetNodeReplication

func (c *Client) SetNodeReplication(nodeName string, subscriptions []Subscription) (*MessageResponse, error)

func (*Client) SetRoutes

func (c *Client) SetRoutes(op OpSetRoutes) (response SetRouteResponse, err error)

func (*Client) SystemInformation

func (c *Client) SystemInformation(attrs []string) (*SysInfo, error)

func (*Client) SystemInformationAll

func (c *Client) SystemInformationAll() (*SysInfo, error)

func (*Client) Update

func (c *Client) Update(schema, table string, records interface{}) (*AffectedResponse, error)

Update updates one or more JSON objects in a table. Hash value of the inserted JSON record MUST be present.

func (*Client) UpdateNode

func (c *Client) UpdateNode(name, host string, port int, subscriptions []Subscription) error

func (*Client) Upsert

func (c *Client) Upsert(database, table string, records interface{}) (*AffectedResponse, error)

Update updates one or more JSON objects in a table. Hash value of the inserted JSON record MUST be present.

func (*Client) UserInfo

func (c *Client) UserInfo() (User, error)

UserInfo returns the current user executing this operation

type ClusterNetworkResponse

type ClusterNetworkResponse struct {
	Nodes []Node `json:"nodes"`
}

type ClusterStatusResponse

type ClusterStatusResponse struct {
	IsEnabled bool        `json:"is_enabled"`
	NodeName  interface{} `json:"node_name"` // (sic) this is an int if cluster is not enabled
	Status    struct {
		ID                  string       `json:"id"`
		Type                string       `json:"type"`
		OutboundConnections []Connection `json:"outbound_connections"`
		InboundConnections  []Connection `json:"inbound_connections"`
	} `json:"status"`
}

type ConfigureClusterConnection

type ConfigureClusterConnection struct {
	NodeName      string         `json:"node_name"`
	Subscriptions []Subscription `json:"subscriptions"`
}

type Connection

type Connection struct {
	ID            string         `json:"id"`
	HostAddress   string         `json:"host_address"`
	HostPort      int            `json:"host_port"`
	State         string         `json:"state"`
	NodeName      string         `json:"node_name"`
	Subscriptions []Subscription `json:"subscriptions"`
}

type Consumer

type Consumer struct {
	Name           string    `json:"name,omitempty"`
	Created        time.Time `json:"created,omitempty"`
	NumAckPending  int64     `json:"num_ack_pending,omitempty"`
	NumRedelivered int64     `json:"num_redelivered,omitempty"`
	NumWaiting     int64     `json:"num_waiting,omitempty"`
	NumPending     int64     `json:"num_pending,omitempty"`
}

type CreateAuthenticationTokensResponse

type CreateAuthenticationTokensResponse struct {
	OperationToken string `json:"operation_token"`
	RefreshToken   string `json:"refresh_token"`
}

type CustomFunctionStatusResponse

type CustomFunctionStatusResponse struct {
	IsEnabled bool   `json:"is_enabled"`
	Port      int    `json:"port"`
	Directory string `json:"directory"`
}

type Database

type Database struct {
	Record
	Schema string `json:"schema"`
}

type DeleteRecordsBeforeResponse

type DeleteRecordsBeforeResponse struct {
	MessageResponse
	JobId string `json:"job_id"`
}

type DeleteRouteResponse

type DeleteRouteResponse struct {
	Message string  `json:"string"`
	Deleted []Route `json:"deleted"`
	Skipped []Route `json:"skipped"`
}

type DeployComponentOptions

type DeployComponentOptions struct {
	Payload string
	Package string
}

type DescribeAllResponse

type DescribeAllResponse map[string]map[string]DescribeTableResponse

type DescribeMetricResult

type DescribeMetricResult struct {
	Attributes []AttributeDesc `json:"attributes"`
}

type DescribeSchemaResponse

type DescribeSchemaResponse map[string]interface{}

DescribeSchemaResponse is a temporary type until it is defined more accurately.

type DescribeTableResponse

type DescribeTableResponse struct {
	Record
	HashAttribute string           `json:"hash_attribute"`
	ID            string           `json:"id"`
	Name          string           `json:"name"`
	Residence     string           `json:"residence"` // TODO Not verified
	Schema        string           `json:"schema"`
	Attributes    []TableAttribute `json:"attributes"`
	RecordCount   int              `json:"record_count"`
}

type DiskSize

type DiskSize struct {
	FS    string  `json:"fs,omitempty"`
	Type  string  `json:"overlay,omitempty"`
	Size  int64   `json:"size,omitempty"`
	Used  int64   `json:"used,omitempty"`
	Use   float64 `json:"use,omitempty"`
	Mount string  `json:"mount,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type GetAnalyticsRequest

type GetAnalyticsRequest struct {
	Metric        string           `json:"metric"`
	GetAttributes AttributeList    `json:"get_attributes"`
	StartTime     int64            `json:"start_time"`
	EndTime       int64            `json:"end_time"`
	Conditions    SearchConditions `json:"conditions"`
}

type GetAnalyticsResult

type GetAnalyticsResult map[string]interface{}

type GetBackupOptions

type GetBackupOptions struct {
	Table  string   `json:"table,omitempty"`
	Tables []string `json:"tables,omitempty"`
}

type GetComponentsResponse

type GetComponentsResponse struct {
	Name    string        `json:"name"`
	Entries []interface{} `json:"entries"`
}

type GetFingerprintResponse

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

type GetJobResponse

type GetJobResponse struct {
	Record
	MessageResponse
	CreatedDateTime        Timestamp `json:"created_datetime"`
	EndDateTime            Timestamp `json:"end_datetime"`
	StartDateTime          Timestamp `json:"start_datetime"`
	ID                     string    `json:"id"`
	JobBody                string    `json:"job_body"` // TODO Not verified
	Status                 string    `json:"status"`
	Type                   string    `json:"type"`
	User                   string    `json:"user"`
	StartDateTimeConverted time.Time `json:"start_datetime_converted"`
	EndDateTimeConverted   time.Time `json:"end_datetime_converted"`
}

type GetRouteResponse

type GetRouteResponse struct {
	Hub  []Route `json:"hub"`
	Leaf []Route `json:"route"`
}

type HDBProcess

type HDBProcess struct {
	PID       int64          `json:"pid,omitempty"`
	ParentPID int64          `json:"parentPid,omitempty"`
	Name      string         `json:"name,omitempty"`
	CPU       float64        `json:"cpu,omitempty"`
	CPUUser   float64        `json:"cpuu,omitempty"`
	CPUSystem float64        `json:"cpus,omitempty"`
	Memory    float64        `json:"mem,omitempty"`
	Priority  int64          `json:"priority,omitempty"`
	MemVsz    int64          `json:"memVsz,omitempty"`
	MemRSS    int64          `json:"memRss,omitempty"`
	Nice      int64          `json:"nice,omitempty"`
	Started   ProcessStarted `json:"started,omitempty"`
	State     string         `json:"state,omitempty"`
	TTY       string         `json:"tty,omitempty"`
	User      string         `json:"user,omitempty"`
	Command   string         `json:"command,omitempty"`
	Params    string         `json:"params,omitempty"`
	Path      string         `json:"path,omitempty"`
}

type ImportFromS3Response

type ImportFromS3Response struct {
	MessageResponse
	JobId string `json:"job_id"`
}

type JobResponse

type JobResponse struct {
	JobID string
}

type ListMetricsResult

type ListMetricsResult string

type LogEntry

type LogEntry struct {
	Level     string    `json:"level"`
	Message   string    `json:"message"`
	Timestamp time.Time `json:"timestamp"`
}

type LogResponse

type LogResponse struct {
	File []LogEntry `json:"file"`
}

type MessageResponse

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

type MetricType

type MetricType int
const (
	MetricTypeCustom MetricType = iota
	MetricTypeBuiltin
)

type NATSStreamInfo

type NATSStreamInfo struct {
	StreamName string     `json:"stream_name,omitempty"`
	Database   string     `json:"database,omitempty"`
	Table      string     `json:"table,omitempty"`
	State      string     `json:"state,omitempty"`
	Consumers  []Consumer `json:"consumers,omitempty"`
}

type NetworkConnection

type NetworkConnection struct {
	Protocol     string `json:"protocol,omitempty"`
	LocalAddress string `json:"localaddress,omitempty"`
	LocalPort    string `json:"localport,omitempty"`
	PeerAddress  string `json:"peeraddress,omitempty"`
	PeerPort     string `json:"peerport,omitempty"`
	State        string `json:"state,omitempty"`
	PID          int64  `json:"pid,omitempty"`
	Process      string `json:"node,omitempty"`
}

type NetworkInterface

type NetworkInterface struct {
	Iface          string  `json:"iface,omitempty"`
	IfaceName      string  `json:"ifaceName,omitempty"`
	IP4            string  `json:"ip4,omitempty"`
	IP6            string  `json:"ip6,omitempty"`
	Mac            string  `json:"mac,omitempty"`
	OperState      string  `json:"operstate,omitempty"`
	Type           string  `json:"virtual,omitempty"`
	Duplex         string  `json:"duplex,omitempty"`
	Speed          float64 `json:"speed,omitempty"`
	CarrierChanges int64   `json:"carrierChanges,omitempty"`
}

type NetworkStats

type NetworkStats struct {
	Iface     string `json:"iface,omitempty"`
	OperState string `json:"operstate,omitempty"`
	RxBytes   int64  `json:"rx_bytes,omitempty"`
	RxDropped int64  `json:"rx_dropped,omitempty"`
	RxErrors  int64  `json:"rx_errors,omitempty"`
	TxBytes   int64  `json:"tx_bytes,omitempty"`
	TxDropped int64  `json:"tx_dropped,omitempty"`
	TxErrors  int64  `json:"tx_errors,omitempty"`
}

type Node

type Node struct {
	Name          string   `json:"name"`
	ResponseTime  int      `json:"response_time"`
	ConnectedNoes []string `json:"connected_nodes"`
	Routes        []Route  `json:"routes"`
}

type OpAddNode

type OpAddNode struct {
	NodeName      string         `json:"node_name"`
	Host          string         `json:"host"`
	Port          int            `json:"port"`
	Subscriptions []Subscription `json:"subscriptions"`
}

Add Node

func (OpAddNode) Prepare

func (o OpAddNode) Prepare() interface{}

type OpAddRole

type OpAddRole struct {
	Permission Permission `json:"permission"`
	Role       string     `json:"role"`
}

func (OpAddRole) Prepare

func (o OpAddRole) Prepare() interface{}

type OpAlterRole

type OpAlterRole struct {
	ID         string     `json:"id"`
	Role       string     `json:"role"`
	Permission Permission `json:"permission"`
}

func (OpAlterRole) Prepare

func (o OpAlterRole) Prepare() interface{}

type OpDeleteRoutes

type OpDeleteRoutes struct {
	Routes []Route `json:"routes"`
}

Delete Routes

func (OpDeleteRoutes) Prepare

func (o OpDeleteRoutes) Prepare() interface{}

type OpDescribeSchema

type OpDescribeSchema struct {
	Schema string `json:"schema"`
}

Describe Schema

func (OpDescribeSchema) Prepare

func (o OpDescribeSchema) Prepare() interface{}

type OpGetRoutes

type OpGetRoutes struct{}

Get Routes

func (OpGetRoutes) Prepare

func (o OpGetRoutes) Prepare() interface{}

type OpRemoveNode

type OpRemoveNode struct {
	NodeName string `json:"node_name"`
}

Remove Node

func (OpRemoveNode) Prepare

func (o OpRemoveNode) Prepare() interface{}

type OpSetRoutes

type OpSetRoutes struct {
	Server string  `json:"server"` // Must be either "hub" or "leaf"
	Routes []Route `json:"routes"`
}

Set Routes

func (OpSetRoutes) Prepare

func (o OpSetRoutes) Prepare() interface{}

type Operation

type Operation interface {
	Prepare() interface{}
}

type OperationError

type OperationError struct {
	StatusCode int
	Message    string
}

func (*OperationError) Error

func (e *OperationError) Error() string

func (*OperationError) IsAlreadyExistsError

func (e *OperationError) IsAlreadyExistsError() bool

func (*OperationError) IsDoesNotExistError

func (e *OperationError) IsDoesNotExistError() bool

func (*OperationError) IsNotAuthorizedError

func (e *OperationError) IsNotAuthorizedError() bool

type PackageComponentResponse

type PackageComponentResponse struct {
	Project string `json:"project"`
	Payload string `json:"payload"`
}

type PackageCustomFunctionProjectResponse

type PackageCustomFunctionProjectResponse struct {
	Project string `json:"project"`
	Payload string `json:"payload"`
	File    string `json:"file"`
}

type Permission

type Permission map[string]interface{}

func (Permission) AddSchemaPermission

func (p Permission) AddSchemaPermission(schema string, sp SchemaPermission)

func (Permission) SetClusterUser

func (p Permission) SetClusterUser(su bool)

func (Permission) SetSuperUser

func (p Permission) SetSuperUser(su bool)

type ProcessStarted

type ProcessStarted time.Time

func (*ProcessStarted) UnmarshalJSON

func (ps *ProcessStarted) UnmarshalJSON(b []byte) error

UnmarshalJSON for ProcessStarted values parses date-times that look like "YYYY-MM-DD HH:mm:ss" into time.Time values

type PurgeStreamOptions

type PurgeStreamOptions struct {
	Keep string `json:"keep,omitempty"`
	Seq  string `json:"seq,omitempty"`
}

type Record

type Record struct {
	CreatedTime Timestamp `json:"__createdtime__"`
	UpdatedTime Timestamp `json:"__updatedtime__"`
}

Record type gives you convenient access to Harper's meta data fields which are automatically added to every record. Currently these are "__createdtime__" and "__updatedtime__".

Meta data fields are read-only. Overwriting .CreatedTime and .UpdatedTime will have no effect.

Example
return Player{
	Name: "Jane",
	Record: Record{
		UpdatedTime: 123123.23324,
	},
}

type RefreshOperationTokenResponse

type RefreshOperationTokenResponse struct {
	OperationToken string `json:"operation_token"`
}

type RegistrationInfoResponse

type RegistrationInfoResponse struct {
	Registered            bool   `json:"registered"`
	Version               string `json:"version"`
	StorageType           string `json:"storage_type"`
	RAMAllocation         int    `json:"ram_allocation"`
	LicenseExpirationDate string `json:"license_expiration_date"`
}

type Role

type Role struct {
	Record
	Role       string     `json:"role"`
	ID         string     `json:"id"`
	Permission Permission `json:"permission"`
}

type Route

type Route struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

type S3Credentials

type S3Credentials struct {
	AWSAccessKeyID     string `json:"aws_access_key_id,omitempty"`
	AWSSecretAccessKey string `json:"aws_secret_access_key,omitempty"`
	Bucket             string `json:"bucket,omitempty"`
	Key                string `json:"filename,omitempty"`
	Region             string `json:"region,omitempty"`
}

type SchemaPermission

type SchemaPermission struct {
	Tables map[string]TablePermission `json:"tables"`
}

func (SchemaPermission) AddTablePermission

func (p SchemaPermission) AddTablePermission(table string, tp TablePermission)

type SearchByConditionsOptions

type SearchByConditionsOptions struct {
	Operator string `json:"operator,omitempty"`
	Offset   int    `json:"offset,omitempty"`
	Limit    int    `json:"limit,omitempty"`
	Sort     Sort   `json:"sort,omitempty"`
}

type SearchCondition

type SearchCondition struct {
	Attribute  string             `json:"attribute,omitempty"`
	Comparator string             `json:"comparator,omitempty"`
	Value      interface{}        `json:"value,omitempty"`
	Operator   string             `json:"operator,omitempty"`
	Conditions []*SearchCondition `json:"conditions,omitempty"`
}

type SearchConditions

type SearchConditions []SearchCondition

type SearchOperation

type SearchOperation struct {
	Operation string `json:"operation,omitempty"`
	SQL       string `json:"sql,omitempty"`
}

type SetRouteResponse

type SetRouteResponse struct {
	Message string  `json:"message"`
	Set     []Route `json:"set"`
	Skipped []Route `json:"skipped"`
}

type Sort

type Sort struct {
	Attribute  string `json:"attribute,omitempty"`
	Descending bool   `json:"descending,omitempty"`
	Next       *Sort  `json:"next,omitempty"`
}

type Subscription

type Subscription struct {
	Channel   string `json:"channel,omitempty"`
	Subscribe bool   `json:"subscribe"`
	Publish   bool   `json:"publish"`
	Schema    string `json:"schema,omitempty"`
	Table     string `json:"table"`
	Database  string `json:"database,omitempty"`
}

type SysInfo

type SysInfo struct {
	System struct {
		Platform    string `json:"platform,omitempty"`
		Distro      string `json:"distro,omitempty"`
		Release     string `json:"release,omitempty"`
		Codename    string `json:"codename,omitempty"`
		Kernel      string `json:"kernel,omitempty"`
		Arch        string `json:"arch,omitempty"`
		Hostname    string `json:"hostname,omitempty"`
		NodeVersion string `json:"node_version,omitempty"`
		NPMVersion  string `json:"npm_version,omitempty"`
	} `json:"system,omitempty"`
	Time struct {
		Current      Timestamp `json:"current,omitempty"`
		Uptime       float64   `json:"uptime,omitempty"`
		Timezone     string    `json:"timezone,omitempty"`
		TimezoneName string    `json:"timezoneName,omitempty"`
	} `json:"time,omitempty"`
	CPU struct {
		Manufacturer  string  `json:"manufacturer,omitempty"`
		Brand         string  `json:"brand,omitempty"`
		Vendor        string  `json:"vendor,omitempty"`
		Speed         float64 `json:"speed,omitempty"`
		Cores         int     `json:"cores,omitempty"`
		PhysicalCores int     `json:"physicalCores,omitempty"`
		Processors    int     `json:"processors,omitempty"`
		CPUSpeed      struct {
			Min   float64   `json:"min,omitempty"`
			Max   float64   `json:"max,omitempty"`
			Avg   float64   `json:"avg,omitempty"`
			Cores []float64 `json:"cores,omitempty"`
		} `json:"cpu_speed,omitempty"`
		CurrentLoad struct {
			AvgLoad           float64 `json:"avgload,omitempty"`
			CurrentLoad       float64 `json:"currentload,omitempty"`
			CurrentLoadUser   float64 `json:"currentload_user,omitempty"`
			CurrentLoadSystem float64 `json:"currentload_system,omitempty"`
			CurrentLoadNice   float64 `json:"currentload_nice,omitempty"`
			CurrentLoadIdle   float64 `json:"currentload_idle,omitempty"`
			CurrentLoadIRQ    float64 `json:"currentload_irq,omitempty"`
		} `json:"current_load,omitempty"`
		CPUs []CPULoad `json:"cpus,omitempty"`
	} `json:"cpu,omitempty"`
	Memory struct {
		Total     int64 `json:"total,omitempty"`
		Free      int64 `json:"free,omitempty"`
		Used      int64 `json:"used,omitempty"`
		Active    int64 `json:"active,omitempty"`
		Available int64 `json:"available,omitempty"`
		SwapTotal int64 `json:"swaptotal,omitempty"`
		SwapUsed  int64 `json:"swapused,omitempty"`
		SwapFree  int64 `json:"swapfree,omitempty"`
	} `json:"memory,omitempty"`
	Disk struct {
		IO struct {
			RIO int64 `json:"rIO,omitempty"`
			WIO int64 `json:"wIO,omitempty"`
			TIO int64 `json:"tIO,omitempty"`
		} `json:"io,omitempty"`
		ReadWrite struct {
			RX int64 `json:"rx,omitempty"`
			WX int64 `json:"wx,omitempty"`
			TX int64 `json:"tx,omitempty"`
			MS int64 `json:"ms,omitempty"`
		} `json:"read_write,omitempty"`
		Size []DiskSize `json:"size,omitempty"`
	} `json:"disk,omitempty"`
	Network struct {
		DefaultInterface string `json:"default_interface,omitempty"`
		Latency          struct {
			URL    string `json:"url,omitempty"`
			Ok     bool   `json:"ok,omitempty"`
			Status int64  `json:"status,omitempty"`
			MS     int64  `json:"ms,omitempty"`
		} `json:"latency,omitempty"`
		Interfaces  []NetworkInterface  `json:"interfaces,omitempty"`
		Stats       []NetworkStats      `json:"stats,omitempty"`
		Connections []NetworkConnection `json:"connections,omitempty"`
	} `json:"network,omitempty"`
	HarperDBProcesses struct {
		Core       []HDBProcess `json:"core,omitempty"`
		Clustering []HDBProcess `json:"clustering,omitempty"`
	} `json:"harperdb_processes,omitempty"`
	TableSize   []TableSize      `json:"table_size,omitempty"`
	Replication []NATSStreamInfo `json:"replication,omitempty"`
	Threads     []Thread         `json:"threads,omitempty"`
}

type TableAttribute

type TableAttribute struct {
	Attribute string `json:"attribute"`
}

type TablePermission

type TablePermission struct {
	Read                 bool                   `json:"read"`
	Insert               bool                   `json:"insert"`
	Update               bool                   `json:"update"`
	Delete               bool                   `json:"delete"`
	AttributePermissions []AttributePermissions `json:"attribute_permissions"`
}

type TableSize

type TableSize struct {
	Schema                    string `json:"schema,omitempty"`
	Table                     string `json:"table,omitempty"`
	TableSize                 int64  `json:"table_size,omitempty"`
	RecordCount               int64  `json:"record_count,omitempty"`
	TransactionLogSize        int64  `json:"transaction_log_size,omitempty"`
	TransactionLogRecordCount int64  `json:"transaction_log_record_count,omitempty"`
}

type Thread

type Thread struct {
	ThreadID        int64   `json:"threadId,omitempty"`
	Name            string  `json:"name,omitempty"`
	HeapTotal       int64   `json:"heapTotal,omitempty"`
	HeapUsed        int64   `json:"heapUsed,omitempty"`
	ExternalMemory  int64   `json:"externalMemory,omitempty"`
	ArrayBuffers    int64   `json:"arrayBuffers,omitempty"`
	SinceLastUpdate int64   `json:"sinceLastUpdate,omitempty"`
	Idle            float64 `json:"idle,omitempty"`
	Active          float64 `json:"active,omitempty"`
	Utilization     float64 `json:"utilization,omitempty"`
}

type Timestamp

type Timestamp float64

func (Timestamp) ToTime

func (t Timestamp) ToTime() time.Time

type TxLogEntry

type TxLogEntry struct {
	Operation  string                   `json:"operation"`
	UserName   string                   `json:"user_name"`
	Timestamp  Timestamp                `json:"timestamp"` // this is a float
	HashValues []interface{}            `json:"hash_values"`
	Records    []map[string]interface{} `json:"records"`
}

type User

type User struct {
	Record
	Active   bool   `json:"active"`
	Role     Role   `json:"role"`
	Username string `json:"username"`
}

Jump to

Keyboard shortcuts

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