es

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 20 Imported by: 30

Documentation

Index

Constants

View Source
const (
	BucketPrefix         = "by-"
	BucketKeyKey         = "key"
	AggBucketKey         = "buckets"
	BucketKeyAsStringKey = "key_as_string"
	BucketValueKey       = "value"
	BucketValueValueKey  = "value"
)
View Source
const (
	IndexPrefixLineItems = "lineitems"
)

Variables

View Source
var (
	ErrNoSingleRootAggregation   = errors.New("document does not have a single aggregation at its root")
	ErrNoSingleAggregationBranch = errors.New("document's aggregations branch")
	ErrFailedJsonParsing         = errors.New("failed to parse JSON document")
	ErrKeyNotFound               = errors.New("could not find 'key' field")
	ErrNoAggregation             = errors.New("found no next aggregation and no value")
)
View Source
var Client *elastic.Client

Functions

func CleanByBillRepositoryId

func CleanByBillRepositoryId(ctx context.Context, aaUId, brId int) error

CleanBillByBillRepositoryId removes every bills information of a specific bill repository

func CleanCurrentMonthBillByBillRepositoryId

func CleanCurrentMonthBillByBillRepositoryId(ctx context.Context, aaUId, brId int) error

CleanCurrentMonthBillByBillRepositoryId removes incomplete bills of a specific bill repository (invoiceId == "" when incomplete)

func IndexNameForUser

func IndexNameForUser(u users.User, p string) string

func IndexNameForUserId

func IndexNameForUserId(i int, p string) string

func NewSignedElasticClient

func NewSignedElasticClient(endpoint string, creds *credentials.Credentials) (*elastic.Client, error)

NewSignedElasticClient creates a signed *elastic.Client ready for using with AWS ElasticSearch. It takes as parameter:

  • endpoint: The endpoint URI gettable from AWS.
  • creds: Credentials from AWS/Credentials.

func NewSignedElasticClientOptions

func NewSignedElasticClientOptions(endpoint string, creds *credentials.Credentials) ([]elastic.ClientOptionFunc, error)

NewSignedElasticClientOptions builds elastic client option funcs which configure an ElasticSearch client to use AWSv4 signature.

func NewSignedHttpClient

func NewSignedHttpClient(creds *credentials.Credentials, region, service string) (*http.Client, error)

NewSignedHttpCilent returns an http.Client which signs its requests with AWS v4 signatures for the provided service name and region.

func NewSignedHttpClientForElasticSearch

func NewSignedHttpClientForElasticSearch(endpoint string, creds *credentials.Credentials) (*http.Client, error)

NewSignedHttpClientForElasticSearch returns an http.Client which signs its requests with AWS v4 signatures, for ElasticSearch only.

Types

type AccountsAndIndexes

type AccountsAndIndexes struct {
	Accounts []string
	Indexes  []string
}

AccountsAndIndexes stores the accounts and indexes

func GetAccountsAndIndexes

func GetAccountsAndIndexes(accountList []string, user users.User, tx *sql.Tx, indexPrefix string) (AccountsAndIndexes, int, error)

GetAccountsAndIndexesreturns an AccountsAndIndexes struct, a status code and an error if the accountList parameter is empty the function will call getAllAccountsAndIndexes if the accountList parameter is not empty the function will validate the accounts and find their indexes

type SimplifiedCostsDocument

type SimplifiedCostsDocument struct {
	Key          string
	Children     []SimplifiedCostsDocument
	ChildrenKind string
	HasValue     bool
	Value        float64
}

SimplifiedCostsDocument contains the data necessary to show a clean version of the costs breakdowns returned from the ElasticSearch.

func SimplifyCostsDocument

func SimplifyCostsDocument(ctx context.Context, sr *elastic.SearchResult) (SimplifiedCostsDocument, error)

func (SimplifiedCostsDocument) ToJsonable

func (scd SimplifiedCostsDocument) ToJsonable() map[string]interface{}

ToJsonable returns the simplified costs document as a map that can easily be marshaled to JSON.

Jump to

Keyboard shortcuts

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