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 ¶
- Constants
- Variables
- type AffectedResponse
- type Attribute
- type AttributeDesc
- type AttributeList
- type AttributePermissions
- type AuditLogEntry
- type CPULoad
- type Client
- func (c *Client) AddComponent(project string) (*MessageResponse, error)
- func (c *Client) AddCustomFunctionProject(project string) (*MessageResponse, error)
- func (c *Client) AddNode(name, host string, port int, subscriptions []Subscription) error
- func (c *Client) AddRole(role string, perm Permission) (*Role, error)
- func (c *Client) AddUser(username, password, roleID string, active bool) error
- func (c *Client) AlterRole(id string, role string, perm Permission) (*Role, error)
- func (c *Client) AlterUser(username, password, roleID string, active bool) error
- func (c *Client) CSVDataLoad(schema, table string, update bool, data io.Reader) (string, error)
- func (c *Client) CSVFileLoad(schema, table string, update bool, filePath string) (string, error)
- func (c *Client) CSVURLLoad(schema, table string, update bool, csvURL string) (string, error)
- func (c *Client) ClusterNetwork() (*ClusterNetworkResponse, error)
- func (c *Client) ClusterStatus() (*ClusterStatusResponse, error)
- func (c *Client) ConfigureCluster(connections []ConfigureClusterConnection) (*MessageResponse, error)
- func (c *Client) CreateAttribute(schema, table string, attribute Attribute) error
- func (c *Client) CreateAuthenticationTokens(username, password string) (*CreateAuthenticationTokensResponse, error)
- func (c *Client) CreateDatabase(database string) error
- func (c *Client) CreateSchema(schema string) error
- func (c *Client) CreateTable(schema, table, hashAttribute string) error
- func (c *Client) CustomFunctionStatus() (*CustomFunctionStatusResponse, error)
- func (c *Client) Delete(schema, table string, hashValues AttributeList) (*AffectedResponse, error)
- func (c *Client) DeleteAuditLogsBefore(schema, table string, timestamp time.Time) (*MessageResponse, error)
- func (c *Client) DeleteRecordsBefore(date time.Time, schema, table string) (*DeleteRecordsBeforeResponse, error)
- func (c *Client) DeleteRoutes(routes []Route) (response DeleteRouteResponse, err error)
- func (c *Client) DeleteTransactionLogsBefore(schema, table string, timestamp time.Time) error
- func (c *Client) DeployComponent(project string, options DeployComponentOptions) (*MessageResponse, error)
- func (c *Client) DescribeAll() (*DescribeAllResponse, error)
- func (c *Client) DescribeDatabase(database string) (*MessageResponse, error)
- func (c *Client) DescribeMetric(metric string) (*DescribeMetricResult, error)
- func (c *Client) DescribeSchema(schema string) (DescribeSchemaResponse, error)
- func (c *Client) DescribeTable(schema, table string) (*DescribeTableResponse, error)
- func (c *Client) DropAttribute(schema, table string, attribute Attribute) error
- func (c *Client) DropComponent(project, file string) (*MessageResponse, error)
- func (c *Client) DropCustomFunction(project, type_, file string) (*MessageResponse, error)
- func (c *Client) DropCustomFunctionProject(project string) (*MessageResponse, error)
- func (c *Client) DropDatabase(database string) error
- func (c *Client) DropRole(id string) error
- func (c *Client) DropSchema(schema string) error
- func (c *Client) DropTable(schema, table, hashAttribute string) error
- func (c *Client) DropUser(username string) error
- func (c *Client) ExportLocal(format, path string, searchOperation SearchOperation) error
- func (c *Client) ExportToS3(format string, s3creds S3Credentials, searchOperation SearchOperation) error
- func (c *Client) GetAnalytics(req GetAnalyticsRequest) ([]GetAnalyticsResult, error)
- func (c *Client) GetBackup(database string, options GetBackupOptions) ([]byte, error)
- func (c *Client) GetComponentFile(project, file string) (*MessageResponse, error)
- func (c *Client) GetComponents() (*GetComponentsResponse, error)
- func (c *Client) GetConfiguration() (map[string]interface{}, error)
- func (c *Client) GetCustomFunction(project, type_, file string) (*MessageResponse, error)
- func (c *Client) GetCustomFunctions() (map[string]interface{}, error)
- func (c *Client) GetFingerprint() (*GetFingerprintResponse, error)
- func (c *Client) GetJob(jobID string) (*GetJobResponse, error)
- func (c *Client) GetRoutes() (response GetRouteResponse, err error)
- func (c *Client) Healthcheck() error
- func (c *Client) ImportFromS3(action, database, table string, s3creds S3Credentials) (*ImportFromS3Response, error)
- func (c *Client) Insert(schema, table string, records interface{}) (*AffectedResponse, error)
- func (c *Client) InstallNodeModules(projects []string, dryRun bool) (*MessageResponse, error)
- func (c *Client) ListMetrics(types []MetricType) ([]ListMetricsResult, error)
- func (c *Client) ListRoles() ([]Role, error)
- func (c *Client) ListUsers() ([]User, error)
- func (c *Client) PackageComponent(project string, skipNodeModules bool) (*PackageComponentResponse, error)
- func (c *Client) PackageCustomFunctionProject(project string, skipNodeModules bool) (*PackageCustomFunctionProjectResponse, error)
- func (c *Client) PurgeStream(database, table string, options PurgeStreamOptions) error
- func (c *Client) RawRequest(op Operation, result interface{}) error
- func (c *Client) ReadAuditLog(schema, table string, comparator string, searchValues interface{}) ([]AuditLogEntry, error)
- func (c *Client) ReadLog(limit, start int, from, until time.Time, order string) (*LogResponse, error)
- func (c *Client) ReadTransactionLog(schema, table, comparator string, searchValues interface{}) ([]TxLogEntry, error)
- func (c *Client) RefreshOperationToken(refreshToken string) (*RefreshOperationTokenResponse, error)
- func (c *Client) RegistrationInfo() (*RegistrationInfoResponse, error)
- func (c *Client) RemoveNode(name string) error
- func (c *Client) Restart() (*MessageResponse, error)
- func (c *Client) RestartService(service string) (*MessageResponse, error)
- func (c *Client) SQLExec(stmt string, args ...interface{}) (*AffectedResponse, error)
- func (c *Client) SQLGet(stmt string, args ...interface{}) (interface{}, error)
- func (c *Client) SQLSelect(v interface{}, stmt string, args ...interface{}) error
- func (c *Client) SearchByConditions(database, table string, v interface{}, conditions []SearchCondition, ...) error
- func (c *Client) SearchByHash(schema, table string, v interface{}, hashValues AttributeList, ...) error
- func (c *Client) SearchById(database, table string, v interface{}, ids interface{}, ...) error
- func (c *Client) SearchByValue(schema, table string, v interface{}, attribute Attribute, value interface{}, ...) error
- func (c *Client) SearchJobsByStartDate(fromDate, toDate time.Time) ([]GetJobResponse, error)
- func (c *Client) SetComponentFile(project, file, payload string) (*MessageResponse, error)
- func (c *Client) SetConfiguration(configuration interface{}) (*MessageResponse, error)
- func (c *Client) SetConfigurationRequest(op interface{}, result interface{}) error
- func (c *Client) SetCustomFunction(project, type_, file, functionContent string) (*MessageResponse, error)
- func (c *Client) SetLicense(key, company string) error
- func (c *Client) SetNodeReplication(nodeName string, subscriptions []Subscription) (*MessageResponse, error)
- func (c *Client) SetRoutes(op OpSetRoutes) (response SetRouteResponse, err error)
- func (c *Client) SystemInformation(attrs []string) (*SysInfo, error)
- func (c *Client) SystemInformationAll() (*SysInfo, error)
- func (c *Client) Update(schema, table string, records interface{}) (*AffectedResponse, error)
- func (c *Client) UpdateNode(name, host string, port int, subscriptions []Subscription) error
- func (c *Client) Upsert(database, table string, records interface{}) (*AffectedResponse, error)
- func (c *Client) UserInfo() (User, error)
- type ClusterNetworkResponse
- type ClusterStatusResponse
- type ConfigureClusterConnection
- type Connection
- type Consumer
- type CreateAuthenticationTokensResponse
- type CustomFunctionStatusResponse
- type Database
- type DeleteRecordsBeforeResponse
- type DeleteRouteResponse
- type DeployComponentOptions
- type DescribeAllResponse
- type DescribeMetricResult
- type DescribeSchemaResponse
- type DescribeTableResponse
- type DiskSize
- type ErrorResponse
- type GetAnalyticsRequest
- type GetAnalyticsResult
- type GetBackupOptions
- type GetComponentsResponse
- type GetFingerprintResponse
- type GetJobResponse
- type GetRouteResponse
- type HDBProcess
- type ImportFromS3Response
- type JobResponse
- type ListMetricsResult
- type LogEntry
- type LogResponse
- type MessageResponse
- type MetricType
- type NATSStreamInfo
- type NetworkConnection
- type NetworkInterface
- type NetworkStats
- type Node
- type OpAddNode
- type OpAddRole
- type OpAlterRole
- type OpDeleteRoutes
- type OpDescribeSchema
- type OpGetRoutes
- type OpRemoveNode
- type OpSetRoutes
- type Operation
- type OperationError
- type PackageComponentResponse
- type PackageCustomFunctionProjectResponse
- type Permission
- type ProcessStarted
- type PurgeStreamOptions
- type Record
- type RefreshOperationTokenResponse
- type RegistrationInfoResponse
- type Role
- type Route
- type S3Credentials
- type SchemaPermission
- type SearchByConditionsOptions
- type SearchCondition
- type SearchConditions
- type SearchOperation
- type SetRouteResponse
- type Sort
- type Subscription
- type SysInfo
- type TableAttribute
- type TablePermission
- type TableSize
- type Thread
- type Timestamp
- type TxLogEntry
- type User
Examples ¶
Constants ¶
const ( CSV_ACTION_INSERT = "insert" CSV_ACTION_UPDATE = "update" )
const ( JobStatusCompleted = "COMPLETE" JobStatusInProgress = "IN_PROGRESS" DATE_FORMAT = "2006-01-02" )
const ( LogOrderAsc = "asc" LogOrderDesc = "desc" LogSearchTypeAll = "" LogSearchTypeTimestamp = "timestamp" LogSearchTypeUsername = "username" LogSearchTypeHashValue = "hash_value" )
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" )
const ( SearchBySQL = "sql" SearchByHash = "search_by_hash" SearchByValue = "search_by_value" )
Variables ¶
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") )
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 AttributeDesc ¶
type AttributeList ¶
type AttributeList interface{}
func FromStringSlice ¶
func FromStringSlice(ss []string) AttributeList
type AttributePermissions ¶
type AuditLogEntry ¶
type Client ¶
type Client struct { HttpClient *resty.Client // contains filtered or unexported fields }
func NewClient ¶
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) CSVDataLoad ¶
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 ¶
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 ¶
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 (*Client) CreateAuthenticationTokens ¶
func (c *Client) CreateAuthenticationTokens(username, password string) (*CreateAuthenticationTokensResponse, error)
func (*Client) CreateDatabase ¶
func (*Client) CreateSchema ¶
CreateSchema creates a new schema. Returns "AlreadyExistsError" if schema already existed.
func (*Client) CreateTable ¶
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 (*Client) DeleteRecordsBefore ¶
func (*Client) DeleteRoutes ¶
func (c *Client) DeleteRoutes(routes []Route) (response DeleteRouteResponse, err error)
func (*Client) DeleteTransactionLogsBefore ¶
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 (*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 (*Client) DropSchema ¶
DropSchema drops a schema. Returns "DoesNotExistError" if schema did not exist.
func (*Client) DropUser ¶
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 (*Client) GetCustomFunction ¶
func (c *Client) GetCustomFunction(project, type_, file string) (*MessageResponse, error)
func (*Client) GetCustomFunctions ¶
func (*Client) GetFingerprint ¶
func (c *Client) GetFingerprint() (*GetFingerprintResponse, error)
func (*Client) GetRoutes ¶
func (c *Client) GetRoutes() (response GetRouteResponse, err error)
func (*Client) Healthcheck ¶
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) 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 ¶
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) 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 (*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 ¶
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 ¶
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 (*Client) SetCustomFunction ¶
func (c *Client) SetCustomFunction(project, type_, file, functionContent string) (*MessageResponse, error)
func (*Client) SetLicense ¶
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 (*Client) SystemInformationAll ¶
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
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 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 DeleteRecordsBeforeResponse ¶
type DeleteRecordsBeforeResponse struct { MessageResponse JobId string `json:"job_id"` }
type DeleteRouteResponse ¶
type DeployComponentOptions ¶
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 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 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 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 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 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 OpAddNode ¶
type OpAddNode struct { NodeName string `json:"node_name"` Host string `json:"host"` Port int `json:"port"` Subscriptions []Subscription `json:"subscriptions"` }
Add Node
type OpAddRole ¶
type OpAddRole struct { Permission Permission `json:"permission"` Role string `json:"role"` }
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 OperationError ¶
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 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 ¶
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 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 Role ¶
type Role struct { Record Role string `json:"role"` ID string `json:"id"` Permission Permission `json:"permission"` }
type S3Credentials ¶
type SchemaPermission ¶
type SchemaPermission struct {
Tables map[string]TablePermission `json:"tables"`
}
func (SchemaPermission) AddTablePermission ¶
func (p SchemaPermission) AddTablePermission(table string, tp TablePermission)
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 SetRouteResponse ¶
type Subscription ¶
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"` }