opendistro

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

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

README

go-opendistro GitHub license Travis CI Go Report Card Docs

Go client for OpenDistro

Installation

export GO111MODULE=on
go mod init
go get github.com/WhizUs/go-opendistro 

Examples

TODO

Contributing

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 community@whizus.com.

Documentation

Overview

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

Usage:

	import (
        "github.com/WhizUs/go-opendistro"
        "github.com/WhizUs/go-opendistro/security"
    )

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:   "https://es.dev.whizus.net",
	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{
		"captains",
		"starfleet",
	},
	Attributes: map[string]string{
		"attribute1": "value1",
		"attribute2": "value2",
	},
}); err != nil {
	fmt.Printf("create user: %s\n", err)
}

Some code snippets are provided within the https://github.com/WhizUs/go-opendistro/tree/master/example 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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