kvstore

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteRecordsQueryParams

type DeleteRecordsQueryParams struct {
	// Query : Query JSON expression.
	Query string `key:"query"`
}

DeleteRecordsQueryParams represents valid query parameters for the DeleteRecords operation For convenience DeleteRecordsQueryParams can be formed in a single statement, for example:

`v := DeleteRecordsQueryParams{}.SetQuery(...)`

func (DeleteRecordsQueryParams) SetQuery

type ErrorResponse

type ErrorResponse struct {
	// Internal status code of the error.
	Code string `json:"code"`
	// Detailed error message.
	Message string `json:"message"`
}

type IndexDefinition

type IndexDefinition struct {
	Fields []IndexFieldDefinition `json:"fields"`
	// The name of the index.
	Name string `json:"name"`
}

type IndexDescription

type IndexDescription struct {
	// The collection name.
	Collection *string                `json:"collection,omitempty"`
	Fields     []IndexFieldDefinition `json:"fields,omitempty"`
	// The name of the index.
	Name *string `json:"name,omitempty"`
}

type IndexFieldDefinition

type IndexFieldDefinition struct {
	// The sort direction for the indexed field.
	Direction int32 `json:"direction"`
	// The name of the field to index.
	Field string `json:"field"`
}

type InsertRecordsQueryParams added in v1.8.0

type InsertRecordsQueryParams struct {
	// AllowUpdates : Allow records with keys included to update their respective records in the database
	AllowUpdates *bool `key:"allow_updates"`
}

InsertRecordsQueryParams represents valid query parameters for the InsertRecords operation For convenience InsertRecordsQueryParams can be formed in a single statement, for example:

`v := InsertRecordsQueryParams{}.SetAllowUpdates(...)`

func (InsertRecordsQueryParams) SetAllowUpdates added in v1.8.0

type Key

type Key struct {
	// Key of the inserted document.
	Key string `json:"_key"`
}

type ListRecordsQueryParams

type ListRecordsQueryParams struct {
	// Count : Maximum number of records to return.
	Count *int32 `key:"count"`
	// Fields : Comma-separated list of fields to include or exclude.
	Fields  []string               `key:"fields"`
	Filters map[string]interface{} `key:"filters"`
	// Offset : Number of records to skip from the start.
	Offset *int32 `key:"offset"`
	// Orderby : Sort order. Format is `<field>:<sort order>`. Valid sort orders are 1 for ascending, -1 for descending.
	Orderby []string `key:"orderby"`
}

ListRecordsQueryParams represents valid query parameters for the ListRecords operation For convenience ListRecordsQueryParams can be formed in a single statement, for example:

`v := ListRecordsQueryParams{}.SetCount(...).SetFields(...).SetFilters(...).SetOffset(...).SetOrderby(...)`

func (ListRecordsQueryParams) SetCount

func (ListRecordsQueryParams) SetFields

func (ListRecordsQueryParams) SetFilters

func (q ListRecordsQueryParams) SetFilters(v map[string]interface{}) ListRecordsQueryParams

func (ListRecordsQueryParams) SetOffset

func (ListRecordsQueryParams) SetOrderby

type PingResponse

type PingResponse struct {
	// Database status.
	Status PingResponseStatus `json:"status"`
	// If database is not healthy, detailed error message.
	ErrorMessage *string `json:"errorMessage,omitempty"`
}

type PingResponseStatus

type PingResponseStatus string

PingResponseStatus : Database status.

const (
	PingResponseStatusHealthy   PingResponseStatus = "healthy"
	PingResponseStatusUnhealthy PingResponseStatus = "unhealthy"
	PingResponseStatusUnknown   PingResponseStatus = "unknown"
)

List of PingResponseStatus

type QueryRecordsQueryParams

type QueryRecordsQueryParams struct {
	// Count : Maximum number of records to return.
	Count *int32 `key:"count"`
	// Fields : Comma-separated list of fields to include or exclude.
	Fields []string `key:"fields"`
	// Offset : Number of records to skip from the start.
	Offset *int32 `key:"offset"`
	// Orderby : Sort order. Format is `<field>:<sort order>`. Valid sort orders are 1 for ascending, -1 for descending.
	Orderby []string `key:"orderby"`
	// Query : Query JSON expression.
	Query string `key:"query"`
}

QueryRecordsQueryParams represents valid query parameters for the QueryRecords operation For convenience QueryRecordsQueryParams can be formed in a single statement, for example:

`v := QueryRecordsQueryParams{}.SetCount(...).SetFields(...).SetOffset(...).SetOrderby(...).SetQuery(...)`

func (QueryRecordsQueryParams) SetCount

func (QueryRecordsQueryParams) SetFields

func (QueryRecordsQueryParams) SetOffset

func (QueryRecordsQueryParams) SetOrderby

func (QueryRecordsQueryParams) SetQuery

type Service

type Service services.BaseService

func NewService

func NewService(config *services.Config) (*Service, error)

NewService creates a new kvstore service client from the given Config

func (*Service) CreateIndex

func (s *Service) CreateIndex(collection string, indexDefinition IndexDefinition, resp ...*http.Response) (*IndexDescription, error)

CreateIndex - Creates an index on a collection. Parameters:

collection: The name of the collection.
indexDefinition
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) DeleteIndex

func (s *Service) DeleteIndex(collection string, index string, resp ...*http.Response) error

DeleteIndex - Removes an index from a collection. Parameters:

collection: The name of the collection.
index: The name of the index.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) DeleteRecordByKey

func (s *Service) DeleteRecordByKey(collection string, key string, resp ...*http.Response) error

DeleteRecordByKey - Deletes a record with a given key. Parameters:

collection: The name of the collection.
key: The key of the record.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) DeleteRecords

func (s *Service) DeleteRecords(collection string, query *DeleteRecordsQueryParams, resp ...*http.Response) error

DeleteRecords - Removes records in a collection that match the query. Parameters:

collection: The name of the collection.
query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) GetRecordByKey

func (s *Service) GetRecordByKey(collection string, key string, resp ...*http.Response) (*map[string]interface{}, error)

GetRecordByKey - Returns a record with a given key. Parameters:

collection: The name of the collection.
key: The key of the record.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) InsertRecord

func (s *Service) InsertRecord(collection string, body map[string]interface{}, resp ...*http.Response) (*Key, error)

InsertRecord - Inserts a record into a collection. Parameters:

collection: The name of the collection.
body: Record to add to the collection, formatted as a JSON object.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) InsertRecords

func (s *Service) InsertRecords(collection string, requestBody []map[string]interface{}, query *InsertRecordsQueryParams, resp ...*http.Response) ([]string, error)

InsertRecords - Inserts multiple records in a single request. Parameters:

collection: The name of the collection.
requestBody: Array of records to insert.
query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) ListIndexes

func (s *Service) ListIndexes(collection string, resp ...*http.Response) ([]IndexDefinition, error)

ListIndexes - Returns a list of all indexes on a collection. Parameters:

collection: The name of the collection.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) ListRecords

func (s *Service) ListRecords(collection string, query *ListRecordsQueryParams, resp ...*http.Response) ([]map[string]interface{}, error)

ListRecords - Returns a list of records in a collection with basic filtering, sorting, pagination and field projection. Use key-value query parameters to filter fields. Fields are implicitly ANDed and values for the same field are implicitly ORed. Parameters:

collection: The name of the collection.
query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) Ping

func (s *Service) Ping(resp ...*http.Response) (*PingResponse, error)

Ping - Returns the health status from the database. Parameters:

resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) PutRecord

func (s *Service) PutRecord(collection string, key string, body map[string]interface{}, resp ...*http.Response) (*Key, error)

PutRecord - Updates the record with a given key, either by inserting or replacing the record. Parameters:

collection: The name of the collection.
key: The key of the record.
body: Record to add to the collection, formatted as a JSON object.
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

func (*Service) QueryRecords

func (s *Service) QueryRecords(collection string, query *QueryRecordsQueryParams, resp ...*http.Response) ([]map[string]interface{}, error)

QueryRecords - Returns a list of query records in a collection. Parameters:

collection: The name of the collection.
query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided

type Servicer

type Servicer interface {
	/*
		CreateIndex - Creates an index on a collection.
		Parameters:
			collection: The name of the collection.
			indexDefinition
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	CreateIndex(collection string, indexDefinition IndexDefinition, resp ...*http.Response) (*IndexDescription, error)
	/*
		DeleteIndex - Removes an index from a collection.
		Parameters:
			collection: The name of the collection.
			index: The name of the index.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	DeleteIndex(collection string, index string, resp ...*http.Response) error
	/*
		DeleteRecordByKey - Deletes a record with a given key.
		Parameters:
			collection: The name of the collection.
			key: The key of the record.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	DeleteRecordByKey(collection string, key string, resp ...*http.Response) error
	/*
		DeleteRecords - Removes records in a collection that match the query.
		Parameters:
			collection: The name of the collection.
			query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	DeleteRecords(collection string, query *DeleteRecordsQueryParams, resp ...*http.Response) error
	/*
		GetRecordByKey - Returns a record with a given key.
		Parameters:
			collection: The name of the collection.
			key: The key of the record.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	GetRecordByKey(collection string, key string, resp ...*http.Response) (*map[string]interface{}, error)
	/*
		InsertRecord - Inserts a record into a collection.
		Parameters:
			collection: The name of the collection.
			body: Record to add to the collection, formatted as a JSON object.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	InsertRecord(collection string, body map[string]interface{}, resp ...*http.Response) (*Key, error)
	/*
		InsertRecords - Inserts multiple records in a single request.
		Parameters:
			collection: The name of the collection.
			requestBody: Array of records to insert.
			query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	InsertRecords(collection string, requestBody []map[string]interface{}, query *InsertRecordsQueryParams, resp ...*http.Response) ([]string, error)
	/*
		ListIndexes - Returns a list of all indexes on a collection.
		Parameters:
			collection: The name of the collection.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	ListIndexes(collection string, resp ...*http.Response) ([]IndexDefinition, error)
	/*
		ListRecords - Returns a list of records in a collection with basic filtering, sorting, pagination and field projection.
		Use key-value query parameters to filter fields. Fields are implicitly ANDed and values for the same field are implicitly ORed.
		Parameters:
			collection: The name of the collection.
			query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	ListRecords(collection string, query *ListRecordsQueryParams, resp ...*http.Response) ([]map[string]interface{}, error)
	/*
		Ping - Returns the health status from the database.
		Parameters:
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	Ping(resp ...*http.Response) (*PingResponse, error)
	/*
		PutRecord - Updates the record with a given key, either by inserting or replacing the record.
		Parameters:
			collection: The name of the collection.
			key: The key of the record.
			body: Record to add to the collection, formatted as a JSON object.
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	PutRecord(collection string, key string, body map[string]interface{}, resp ...*http.Response) (*Key, error)
	/*
		QueryRecords - Returns a list of query records in a collection.
		Parameters:
			collection: The name of the collection.
			query: a struct pointer of valid query parameters for the endpoint, nil to send no query parameters
			resp: an optional pointer to a http.Response to be populated by this method. NOTE: only the first resp pointer will be used if multiple are provided
	*/
	QueryRecords(collection string, query *QueryRecordsQueryParams, resp ...*http.Response) ([]map[string]interface{}, error)
}

Servicer represents the interface for implementing all endpoints for this service

Jump to

Keyboard shortcuts

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