util

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDatabaseParam

func AddDatabaseParam(params string, client *clients.Client) string

AddDatabaseParam is a utility function for adding the database parameter

func AddTransactionParam

func AddTransactionParam(params string, transaction *Transaction) string

AddTransactionParam is a utility function for adding a transaction parameter

func BuildRequestFromHandle

func BuildRequestFromHandle(c clients.RESTClient, method string, uri string, reqHandle handle.Handle) (*http.Request, error)

BuildRequestFromHandle builds a *http.Request based off a handle.Handle

func Execute

func Execute(c clients.RESTClient, req *http.Request, responseHandle handle.ResponseHandle) error

Execute uses a client to run a request and places the results in the response Handle

func GetClientsByHost

func GetClientsByHost(client *clients.Client, forestInfo []ForestInfo) map[string]*clients.Client

GetClientsByHost provides the forest information about the database

func GetURIs

func GetURIs(
	c *clients.Client,
	query handle.Handle,
	forestName string,
	transaction *Transaction,
	start uint64,
	after string,
	pageLength uint,
	respHandle handle.ResponseHandle) error

GetURIs retrieves URIs from the internal API for the Data Movement SDK

func MappedParameters

func MappedParameters(params string, prefix string, values map[string]string) string

MappedParameters is a utility function for putting map[string]string to parameters

func PostForm

func PostForm(c clients.RESTClient, endpoint string, atomicParams map[string][]string, unatomicParams map[string][]*handle.Handle, responseHandle handle.ResponseHandle, isDataService bool) error

PostForm submits a URL encoded form

func RepeatingParameters

func RepeatingParameters(params string, valueLabel string, values []string) string

RepeatingParameters is a utility function for putting slices to parameters

Types

type Database

type Database struct {
	ID   string `json:"database-id"`
	Name string `json:"database-name"`
}

Database represents a database in the MarkLogic cluster

type ForestInfo

type ForestInfo struct {
	ID              string `json:"id,omitempty"`
	Name            string `json:"name,omitempty"`
	UpdatesAllowed  string `json:"updatesAllowed,omitempty"`
	Database        string `json:"database,omitempty"`
	Host            string `json:"host,omitempty"`
	RequestHost     string `json:"requestHost,omitempty"`
	AlternateHost   string `json:"alternateHost,omitempty"`
	OpenReplicaHost string `json:"openReplicaHost,omitempty"`
}

ForestInfo describes a forest with associated host info

func GetForestInfo

func GetForestInfo(c *clients.Client) []ForestInfo

GetForestInfo provides the forest information about the database

func (*ForestInfo) PreferredHost

func (fi *ForestInfo) PreferredHost() string

PreferredHost for the forest

type ForestInfoHandle

type ForestInfoHandle struct {
	*bytes.Buffer
	Format     int
	ForestInfo []ForestInfo
	// contains filtered or unexported fields
}

ForestInfoHandle is a handle that places the results into a ForestInfo struct

func (*ForestInfoHandle) AcceptResponse

func (fih *ForestInfoHandle) AcceptResponse(resp *http.Response) error

AcceptResponse handles an *http.Response

func (*ForestInfoHandle) Deserialize

func (fih *ForestInfoHandle) Deserialize(bytes []byte)

Deserialize returns Query struct that represents XML or JSON

func (*ForestInfoHandle) Deserialized

func (fih *ForestInfoHandle) Deserialized() interface{}

Deserialized returns *[]ForestInfo as interface{}

func (*ForestInfoHandle) Get

func (fih *ForestInfoHandle) Get() *[]ForestInfo

Get returns string of XML or JSON

func (*ForestInfoHandle) GetFormat

func (fih *ForestInfoHandle) GetFormat() int

GetFormat returns int that represents XML or JSON

func (*ForestInfoHandle) Read

func (fih *ForestInfoHandle) Read(bytes []byte) (n int, err error)

Read bytes

func (*ForestInfoHandle) Serialize

func (fih *ForestInfoHandle) Serialize(forestInfo interface{})

Serialize returns []byte of XML or JSON that represents the Query struct

func (*ForestInfoHandle) Serialized

func (fih *ForestInfoHandle) Serialized() string

Serialized returns string of XML or JSON

func (*ForestInfoHandle) SetTimestamp

func (fih *ForestInfoHandle) SetTimestamp(timestamp string)

SetTimestamp sets the timestamp

func (*ForestInfoHandle) Timestamp

func (fih *ForestInfoHandle) Timestamp() string

Timestamp retieves a timestamp

type Host

type Host struct {
	ID   string `json:"host-id"`
	Name string `json:"host-name"`
}

Host represents a host in the MarkLogic cluster

type SerializableStringMap

type SerializableStringMap map[string]string

SerializableStringMap is a map[string]string which can be converted to XML.

func (SerializableStringMap) MarshalXML

func (s SerializableStringMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals map[string]string into XML.

type Server

type Server struct {
	ID   string `json:"server-id"`
	Name string `json:"server-name"`
}

Server represents a server in the MarkLogic cluster

type Transaction

type Transaction struct {
	Name      string
	ID        string
	TimeLimit int
	Database  string
	// contains filtered or unexported fields
}

Transaction represents a transaction for a request

func (*Transaction) Begin

func (t *Transaction) Begin() bool

Begin starts a Transaction

func (*Transaction) Commit

func (t *Transaction) Commit() bool

Commit commits a Transaction

func (*Transaction) GetStatus

func (t *Transaction) GetStatus() TransactionStatus

GetStatus returns the status of a Transaction

func (*Transaction) Rollback

func (t *Transaction) Rollback() bool

Rollback rolls back a Transaction

type TransactionStatus

type TransactionStatus struct {
	Host                 Host     `json:"host"`
	Server               Server   `json:"server"`
	Database             Database `json:"database"`
	TransactionID        string   `json:"transaction-id"`
	TransactionName      string   `json:"transaction-name"`
	TransactionMode      string   `json:"transaction-mode"`
	TransactionTimestamp string   `json:"transaction-timestamp"`
	TransactionState     string   `json:"transaction-state"`
	Canceled             string   `json:"canceled"`
	StartTime            string   `json:"start-time"`
	TimeLimit            string   `json:"time-limit"`
	MaxTimeLimit         string   `json:"max-time-limit"`
	User                 string   `json:"user"`
	Admin                string   `json:"admin"`
}

TransactionStatus represents a status of a transaction

type TransactionStatusHandle

type TransactionStatusHandle struct {
	*bytes.Buffer
	TransactionStatus TransactionStatus
	// contains filtered or unexported fields
}

TransactionStatusHandle is a handle that places the results into a TransactionStatus struct

func (*TransactionStatusHandle) AcceptResponse

func (tsh *TransactionStatusHandle) AcceptResponse(resp *http.Response) error

AcceptResponse handles an *http.Response

func (*TransactionStatusHandle) Deserialize

func (tsh *TransactionStatusHandle) Deserialize(bytes []byte)

Deserialize returns Query struct that represents XML or JSON

func (*TransactionStatusHandle) Deserialized

func (tsh *TransactionStatusHandle) Deserialized() interface{}

Deserialized returns interface{}

func (*TransactionStatusHandle) Get

Get returns string of XML or JSON

func (*TransactionStatusHandle) GetFormat

func (tsh *TransactionStatusHandle) GetFormat() int

GetFormat returns int that represents JSON

func (*TransactionStatusHandle) Read

func (tsh *TransactionStatusHandle) Read(bytes []byte) (n int, err error)

Read bytes

func (*TransactionStatusHandle) Serialize

func (tsh *TransactionStatusHandle) Serialize(transactionStatus interface{})

Serialize returns []byte of XML or JSON that represents the Query struct

func (*TransactionStatusHandle) Serialized

func (tsh *TransactionStatusHandle) Serialized() string

Serialized returns string of XML or JSON

func (*TransactionStatusHandle) SetTimestamp

func (tsh *TransactionStatusHandle) SetTimestamp(timestamp string)

SetTimestamp sets the timestamp

func (*TransactionStatusHandle) Timestamp

func (tsh *TransactionStatusHandle) Timestamp() string

Timestamp retieves a timestamp

type Transform

type Transform struct {
	Name       string
	Parameters map[string]string
}

Transform represents a transform for a request

func (*Transform) ToParameters

func (t *Transform) ToParameters() string

ToParameters converts a transform to its url form

type URIsHandle

type URIsHandle struct {
	*bytes.Buffer
	URIs []string
	// contains filtered or unexported fields
}

URIsHandle for retrieving URIs from the internal/uris endpoint

func (*URIsHandle) AcceptResponse

func (uh *URIsHandle) AcceptResponse(resp *http.Response) error

AcceptResponse handles an *http.Response

func (*URIsHandle) Deserialize

func (uh *URIsHandle) Deserialize(bytes []byte)

Deserialize returns Query struct that represents XML or JSON

func (*URIsHandle) Deserialized

func (uh *URIsHandle) Deserialized() interface{}

Deserialized returns string array of URIs as interface{}

func (*URIsHandle) Get

func (uh *URIsHandle) Get() []string

Get returns string of URIs

func (*URIsHandle) GetFormat

func (uh *URIsHandle) GetFormat() int

GetFormat returns int that represents XML or JSON

func (*URIsHandle) Serialize

func (uh *URIsHandle) Serialize(uris interface{})

Serialize returns []byte of XML or JSON that represents the Query struct

func (*URIsHandle) Serialized

func (uh *URIsHandle) Serialized() string

Serialized returns string of XML or JSON

func (*URIsHandle) SetTimestamp

func (uh *URIsHandle) SetTimestamp(timestamp string)

SetTimestamp sets the timestamp

func (*URIsHandle) Timestamp

func (uh *URIsHandle) Timestamp() string

Timestamp retieves a timestamp

Jump to

Keyboard shortcuts

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