gaia

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 13 Imported by: 1

README

Gaia

Elasticsearch client package for Go.

GoDoc Go Report Card GitHub release Contributor Covenant

Usage

To use the gaia client:

package main

import (
	"fmt"

	"github.com/procore/gaia"
)

func main() {
	config := gaia.NewConfig()
	config.Debug = true
	client := gaia.NewClient(config)
	response := client.Cat("indices")
	fmt.Println(response)
}

Testing

To run tests:

$ go test ./test/
ok  github.com/procore/gaia/test  0.046s

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About Procore

Procore Logo

Gaia is maintained by Procore Technologies.

Procore - building the software that builds the world.

Learn more about the #1 most widely used construction management software at procore.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config *Config
}

Client wraps config for making requests to the Elasticsearch cluster

func NewClient

func NewClient(config *Config) *Client

NewClient returns a client that is ready to make requests to the elasticsearch cluster

func (*Client) AllocationExplain added in v0.1.1

func (c *Client) AllocationExplain() string

AllocationExplain provides explanations for shard allocations in the cluster

func (*Client) Bulk

func (c *Client) Bulk(body []string) string

Bulk performs a bulk API request Parameters:

  • body []string a slice of bulk operations

Example:

var body []string
body = append("{'update': {...}}", body)
body = append("{'doc': {...}}", body)
client.Bulk(body)

func (*Client) Cat

func (c *Client) Cat(action string) string

Cat endpoint

func (*Client) CatCountIndex

func (c *Client) CatCountIndex(index string) string

CatCountIndex count documents for a specific index

func (*Client) CatNodeType

func (c *Client) CatNodeType(nodetype string) []string

CatNodeType Cat nodes of a certain type

func (*Client) CatSnapshots

func (c *Client) CatSnapshots(repo string) string

CatSnapshots list snapshots in a repo

func (*Client) ClusterHealth

func (c *Client) ClusterHealth() string

ClusterHealth returns the general health of the cluster

func (*Client) ClusterInfo

func (c *Client) ClusterInfo() string

ClusterInfo returns general data about your cluster

func (*Client) ClusterPendingTasks

func (c *Client) ClusterPendingTasks() string

ClusterPendingTasks returns list of cluster level changes that have not been executedut

func (*Client) ClusterReroute

func (c *Client) ClusterReroute(body string) string

ClusterReroute explicitly executes a cluster reroute allocation command

func (*Client) ClusterSettings

func (c *Client) ClusterSettings(flatSettings bool) string

ClusterSettings returns current cluster level settings

func (*Client) ClusterState

func (c *Client) ClusterState() string

ClusterState returns the general health of the cluster

func (*Client) ClusterStats

func (c *Client) ClusterStats() string

ClusterStats Get some sweet sweet stats about your cluster

func (*Client) ClusterUpdateSettings

func (c *Client) ClusterUpdateSettings(body string, flatSettings bool) string

ClusterUpdateSettings allows updating cluster wide settings

func (*Client) Count

func (c *Client) Count(index string, body string) int

Count returns the number of results from a query

func (*Client) CountNodeType

func (c *Client) CountNodeType(nodetype string) int

CountNodeType Cat nodes of a certain type

func (*Client) CountNodes

func (c *Client) CountNodes() int

CountNodes returns number of nodes

func (*Client) DeleteScroll

func (c *Client) DeleteScroll(scrollID string) string

DeleteScroll clears the scroll context when you no longer need it

func (*Client) DocumentDelete

func (c *Client) DocumentDelete(index string, id string) string

DocumentDelete deletes a document

func (*Client) DocumentDeleteByQuery

func (c *Client) DocumentDeleteByQuery(index string, query string) string

DocumentDeleteByQuery performs a query then deletes the results

func (*Client) DocumentGet

func (c *Client) DocumentGet(index string, id string, source bool, fields string) string

DocumentGet get json document

func (*Client) DocumentIndex

func (c *Client) DocumentIndex(index string, id string, body string) string

DocumentIndex indexes a document

func (*Client) DocumentMultiGet

func (c *Client) DocumentMultiGet(index string, body string, fields string) string

DocumentMultiGet allows to get multiple documents Annoyngly the mget api requires a GET request AND a request body so we need to call directly against the request instead of using the `get` wrapper

func (*Client) DocumentReindex

func (c *Client) DocumentReindex(body string) string

DocumentReindex copies documents from one index to another !!! Reindex does not attempt to set up the destination index. It does not copy the settings of the source index. You should set up the destination index prior to running a _reindex action, including setting up mappings, shard counts, replicas, etc.

func (*Client) DocumentUpdate

func (c *Client) DocumentUpdate(index string, id string, body string) string

DocumentUpdate performs update operation on a document

func (*Client) GetTask

func (c *Client) GetTask(taskID string, nodes string) string

GetTask retrieves currently executing tasks on a node Args

  • taskID string id of the task to get
  • nodes string comma separated list of nodes to query

func (*Client) IndexAliasesGet added in v0.1.3

func (c *Client) IndexAliasesGet(i string) string

IndexAliasesGet filters information about an index to only include the specific alias features Args:

  • i string comma seperated list of indices to retrieve, or _all

func (*Client) IndexDelete

func (c *Client) IndexDelete(i string) string

IndexDelete deletes an index Use with caution Args:

  • i string the name of the index to delete

func (*Client) IndexGet added in v0.1.3

func (c *Client) IndexGet(i string) string

IndexGet retrieves information about one or more indexes Args:

  • i string comma seperated list of indices to retrieve, or _all

func (*Client) IndexMappingsGet added in v0.1.3

func (c *Client) IndexMappingsGet(i string) string

IndexMappingsGet filters information about an index to only include the specific alias features Args:

  • i string comma seperated list of indices to retrieve, or _all

func (*Client) IndexSettingsGet added in v0.1.3

func (c *Client) IndexSettingsGet(i string) string

IndexSettingsGet filters information about an index to only include the specific settings features Args:

  • i string comma seperated list of indices to retrieve, or _all

func (*Client) IndexToggleOpen

func (c *Client) IndexToggleOpen(s string, i string) string

IndexToggleOpen can toggle the open/close status of an index Args:

  • s string the state of the index (open, close)
  • i string the name of the index to open/close

func (*Client) KibanaQuery

func (c *Client) KibanaQuery(command string, body string) string

KibanaQuery allows for running kibana-like commands it takes in a command string [METHOD] [ENDPOINT] and a json body and returns the results from ES

func (*Client) NodeList

func (c *Client) NodeList() string

NodeList lists nodes in cluster

func (*Client) NodeSearchStats

func (c *Client) NodeSearchStats() string

NodeSearchStats returns search stats for a node

func (*Client) NodeShow

func (c *Client) NodeShow(node string) string

NodeShow info about a specific node

func (*Client) NodeStats

func (c *Client) NodeStats() string

NodeStats for this cluster

func (*Client) RemoteInfo

func (c *Client) RemoteInfo() string

RemoteInfo returns info on remote clusters

func (*Client) Scroll

func (c *Client) Scroll(scrollID string, scroll string) string

Scroll gets the next page of results for a search

func (*Client) Search

func (c *Client) Search(index string, body string, options map[string]string) string

Search runs the search provided on the index provided

func (*Client) SnapshotClean

func (c *Client) SnapshotClean(n int, r string)

SnapshotClean deletes all but a certain number of snapshots Args:

  • n string number of snapshots to keep
  • r string repository in which the snapshots are located

func (*Client) SnapshotDelete

func (c *Client) SnapshotDelete(n string, r string) string

SnapshotDelete deletes a given snapshot Args:

  • n string name of the snapshot
  • r string repository in which the snapshot is located

func (*Client) SnapshotGet

func (c *Client) SnapshotGet(n string, r string) string

SnapshotGet returns details on a specific snapshot Args:

  • n string name of the snapshot
  • r string repository in which the snapshot is located

func (*Client) SnapshotList

func (c *Client) SnapshotList(r string) string

SnapshotList lists all snapshots in a repo Args:

  • r string repository name

func (*Client) SnapshotRepoRegister

func (c *Client) SnapshotRepoRegister(r string, b string) string

SnapshotRepoRegister register a new repository for snapshots Args:

  • r string repository in which the snapshots are located
  • b string request body

func (*Client) SnapshotRestore

func (c *Client) SnapshotRestore(n string, r string, b string, w bool) string

SnapshotRestore kicks off a restore for a snapshot Args:

  • n string name of the snapshot
  • r string repository in which the snapshot is located
  • b string snapshot request body
  • w bool whether or not to wait for completion

func (*Client) SnapshotStart

func (c *Client) SnapshotStart(n string, r string, b string, w bool, notify bool, s string) string

SnapshotStart starts a snapshot with the given name in the given repo. Waits for completion if w and sends a notification if notify to slack webhook s Args:

  • n string name of the snapshot
  • r string repository in which the snapshot is located
  • b string snapshot request body
  • w bool whether or not to wait for completion
  • notify bool whether or not to send notification once snapshot is finished
  • s string slack webhook to send the notification to

func (*Client) ToggleRouting

func (c *Client) ToggleRouting(setting string, flatSettings bool) string

ToggleRouting turns off dynaamic allocation Parameters:

  • setting string string setting for cluster allocation

type Config

type Config struct {
	User struct {
		Name     string
		Password string
	}
	Net struct {
		Host string
		Port string
		TLS  struct {
			Enable bool
		}
	}
	Pretty bool
	Debug  bool
}

Config holds configuration for a connection to elasticsearch

func NewConfig

func NewConfig() *Config

NewConfig provides a factory for initializing a config

Jump to

Keyboard shortcuts

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