simplekpiutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2020 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ApiDateFormat = timeutil.RFC3339FullDate
	ApiTimeFormat = timeutil.ISO8601NoTZ

	EnvSimplekpiSite     = "SIMPLEKPI_SITE"
	EnvSimplekpiToken    = "SIMPLEKPI_TOKEN"
	EnvSimplekpiUsername = "SIMPLEKPI_USERNAME"
	EnvSimplekpiUserID   = "SIMPLEKPI_USERID"
)

Variables

This section is empty.

Functions

func FrequencyIDToInterval

func FrequencyIDToInterval(frequencyId string) timeutil.Interval

func GetUserIDEnv

func GetUserIDEnv() (uint, error)

func KPIEntriesToDataSeries

func KPIEntriesToDataSeries(kentries []simplekpi.KpiEntry) (statictimeseries.DataSeries, error)

func KpiEntryResponseErrors

func KpiEntryResponseErrors(resps []KpiEntryResponse) []error

KpiEntryResponseErrors returns a collapsed error slice.

func NewApiClient

func NewApiClient(site, username, token string) (*simplekpi.APIClient, error)

func NewApiClientConfig

func NewApiClientConfig(opts Config) (*simplekpi.APIClient, error)

func NewApiClientEnv

func NewApiClientEnv() (*simplekpi.APIClient, error)

func UpsertKpiEntriesStaticTimeSeries

func UpsertKpiEntriesStaticTimeSeries(
	client *simplekpi.APIClient,
	userID, kpiID int64,
	ds statictimeseries.DataSeries) (KpiEntryQueries, []KpiEntryResponse, error)

UpsertKpiEntriesStaticTimeSeries is a high level function that takse requests and executes them.

func UpsertKpiEntriesStaticTimeSeriesTimes

func UpsertKpiEntriesStaticTimeSeriesTimes(
	client *simplekpi.APIClient,
	userID, kpiID int64,
	oldDateFrom, oldDateTo string,
	ds statictimeseries.DataSeries) (KpiEntryQueries, []KpiEntryResponse, error)

UpsertKpiEntriesStaticTimeSeriesTimes is a high level function that takse requests and executes them.

func WriteKpisXlsx

func WriteKpisXlsx(apiClient *simplekpi.APIClient, filename string, kpiIDs []uint64, dateStart, dateEnd time.Time) error

Types

type ClientUtil

type ClientUtil struct {
	APIClient *simplekpi.APIClient
}

func (*ClientUtil) GetAllKPIEntries

func (sku *ClientUtil) GetAllKPIEntries(kpiId uint64, startDate, endDate time.Time) ([]simplekpi.KpiEntry, error)

func (*ClientUtil) GetKPI

func (sku *ClientUtil) GetKPI(kpiId uint64) (simplekpi.Kpi, error)

func (*ClientUtil) GetKPIEntriesAsDataSeries

func (sku *ClientUtil) GetKPIEntriesAsDataSeries(kpiId uint64, startDate, endDate time.Time) (statictimeseries.DataSeries, error)

type Config

type Config struct {
	Site     string `short:"s" long:"site" description:"Your site" required:"true"`
	Username string `short:"u" long:"username" description:"Your username" required:"true"`
	Token    string `short:"t" long:"token" description:"Your token" required:"true"`
}

type KpiEntriesClient

type KpiEntriesClient struct {
	ApiClient *simplekpi.APIClient
	UserID    int64
}

func NewKpiEntriesClientEnv

func NewKpiEntriesClientEnv() (KpiEntriesClient, error)

func (*KpiEntriesClient) UpsertKpiEntriesDataSeries

func (kec *KpiEntriesClient) UpsertKpiEntriesDataSeries(kpiID int64,
	ds statictimeseries.DataSeries) (KpiEntryQueries, []KpiEntryResponse, error)

func (*KpiEntriesClient) UpsertKpiEntriesDataSeriesSetSimple

func (kec *KpiEntriesClient) UpsertKpiEntriesDataSeriesSetSimple(name2KpiID map[string]int64,
	ds3 statictimeseries.DataSeriesSet) ([]KpiEntryQueries, [][]KpiEntryResponse, error)

type KpiEntryQueries

type KpiEntryQueries struct {
	Create []simplekpi.KpiEntry
	Update []simplekpi.KpiEntry
}

KpiEntryQueries represents a set of API KPI Entry queries to be performed.

func GenerateKpiEntryQueriesYMD

func GenerateKpiEntryQueriesYMD(userid, kpiid int64, existing []simplekpi.KpiEntry, new statictimeseries.DataSeries) KpiEntryQueries

GenerateKpiEntryQueriesYMD returns a set of queries given a set of current KPI Entries and a statictimeseries.DataSet containing new data.

type KpiEntryResponse

type KpiEntryResponse struct {
	KpiEntry   simplekpi.KpiEntry
	StatusCode int
	Error      error
}

KpiEntryResponse is a wrapper for a batch API response set.

func CreateKpiEntries

func CreateKpiEntries(client *simplekpi.APIClient, entries []simplekpi.KpiEntry) []KpiEntryResponse

CreateKpiEntries handles multiple creates.

func RunQueries

func RunQueries(client *simplekpi.APIClient, qrys KpiEntryQueries) []KpiEntryResponse

RunQueries is a low level function that executes a set of queries.

func UpdateKpiEntries

func UpdateKpiEntries(client *simplekpi.APIClient, entries []simplekpi.KpiEntry) []KpiEntryResponse

UpdateKpiEntries handles multiple updates.

Jump to

Keyboard shortcuts

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