package module
Version: v0.0.0-...-c7e1f73 Latest Latest

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 12 Imported by: 0


go-opendistro GitHub license Travis CI Go Report Card Docs

Go client for OpenDistro


export GO111MODULE=on
go mod init
go get 




The main purpose of this repository it to create and evolve a working opendistro client for go. We are grateful for anyone in the community support this client by writing, debugging or improve the code.

For further information have a look into our full Contribution Guide.

Any other questions?

Join our Community Slack Channel by writting a one liner to



Package go-opendistro provides a simple client implementation to interact with the OpenDistro for Elasticsearch REST APIs.


	import (

A client can be instantiated by providing a client configuration containing the user, password, base URL and a TLS configuration (optionally). For example:

clientConfig := &opendistro.ClientConfig{
	Username:  "vault",
	Password:  "vault",
	BaseURL:   "",
	TLSConfig: nil,

client, err := opendistro.NewClient(clientConfig)
if err != nil {
	fmt.Printf("instantiate client: %s\n", err)

if err := client.Security.Users.Create(context.TODO(), "kirk", &security.UserCreate{
	Password: "kirkpass",
	BackendRoles: []string{
	Attributes: map[string]string{
		"attribute1": "value1",
		"attribute2": "value2",
}); err != nil {
	fmt.Printf("create user: %s\n", err)

Some code snippets are provided within the directory.

Each of the resources is aimed to be implemented by a Go service object (f.e. opendistro.Security.UserService) which in turn provides available methods of the resource.



This section is empty.


This section is empty.


This section is empty.


type Client

type Client struct {
	Client *retryablehttp.Client

	Username, Password, BaseURL string

	Security securityClient
	// contains filtered or unexported fields

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, reqBytes interface{}, endpoint string, method string) ([]byte, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, T interface{}) error

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() string

func (*Client) Modify

func (c *Client) Modify(ctx context.Context, path string, method string, reqBytes interface{}) error

type ClientConfig

type ClientConfig struct {
	Username, Password, BaseURL string

	TLSConfig *TLSConfig

type TLSConfig

type TLSConfig struct {
	CACert        string
	CAPath        string
	ClientCert    string
	ClientKey     string
	TLSServerName string
	Insecure      bool

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

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