Documentation ¶
Index ¶
- Constants
- Variables
- func CleanByBillRepositoryId(ctx context.Context, aaUId, brId int) error
- func CleanCurrentMonthBillByBillRepositoryId(ctx context.Context, aaUId, brId int) error
- func IndexNameForUser(u users.User, p string) string
- func IndexNameForUserId(i int, p string) string
- func NewSignedElasticClient(endpoint string, creds *credentials.Credentials) (*elastic.Client, error)
- func NewSignedElasticClientOptions(endpoint string, creds *credentials.Credentials) ([]elastic.ClientOptionFunc, error)
- func NewSignedHttpClient(creds *credentials.Credentials, region, service string) (*http.Client, error)
- func NewSignedHttpClientForElasticSearch(endpoint string, creds *credentials.Credentials) (*http.Client, error)
- type AccountsAndIndexes
- type SimplifiedCostsDocument
Constants ¶
const ( BucketPrefix = "by-" BucketKeyKey = "key" AggBucketKey = "buckets" BucketKeyAsStringKey = "key_as_string" BucketValueKey = "value" BucketValueValueKey = "value" )
const (
IndexPrefixLineItems = "lineitems"
)
Variables ¶
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") )
var Client *elastic.Client
Functions ¶
func CleanByBillRepositoryId ¶
CleanBillByBillRepositoryId removes every bills information of a specific bill repository
func CleanCurrentMonthBillByBillRepositoryId ¶
CleanCurrentMonthBillByBillRepositoryId removes incomplete bills of a specific bill repository (invoiceId == "" when incomplete)
func IndexNameForUserId ¶
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 ¶
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.