Documentation ¶
Overview ¶
Package axiom implements Go bindings for the Axiom API.
Usage:
import "github.com/axiomhq/axiom-go/axiom" import "github.com/axiomhq/axiom-go/axiom/query" // When constructing queries
Construct a new Axiom client, then use the various services on the client to access different parts of the Axiom API. A valid deployment URL and an access token must be passed. The access token can be a personal one or an ingest token. The ingest token however, will just allow ingestion into the datasets targeted by the ingest token:
client, err := axiom.NewClient("https://my-axiom.example.com", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") Get the version of the configured deployment: version, err := client.Version.Get(ctx)
Some API methods have additional parameters that can be passed:
dashboards, err := client.Dashboards.List(ctx, axiom.ListOptions{ Limit: 5, })
NOTE: Every client method mapping to an API method takes a context.Context (https://godoc.org/context) as its first parameter to pass cancelation signals and deadlines to requests. In case there is no context available, then context.Background() can be used as a starting point.
For more code samples, check out the https://github.com/axiomhq/axiom-go/tree/main/examples directory.
Example ¶
package main import ( "context" "fmt" "log" "github.com/axiomhq/axiom-go/axiom" ) func main() { client, err := axiom.NewClient("https://my-axiom.example.com", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") if err != nil { log.Fatal(err) } version, err := client.Version.Get(context.Background()) if err != nil { log.Fatal(err) } fmt.Println(version) }
Output:
Index ¶
- Constants
- Variables
- func DefaultHTTPClient() *http.Client
- func GZIPStreamer(r io.Reader, level int) (io.Reader, error)
- func IsIngestToken(token string) bool
- func IsPersonalToken(token string) bool
- type AuthenticatedUser
- type Client
- type Comparison
- type ContentEncoding
- type ContentType
- type Dashboard
- type DashboardsService
- func (s *DashboardsService) Create(ctx context.Context, req Dashboard) (*Dashboard, error)
- func (s *DashboardsService) Delete(ctx context.Context, id string) error
- func (s *DashboardsService) Get(ctx context.Context, id string) (*Dashboard, error)
- func (s *DashboardsService) List(ctx context.Context, opts ListOptions) ([]*Dashboard, error)
- func (s *DashboardsService) Update(ctx context.Context, id string, req Dashboard) (*Dashboard, error)
- type Dataset
- type DatasetCreateRequest
- type DatasetInfo
- type DatasetStats
- type DatasetUpdateRequest
- type DatasetsService
- func (s *DatasetsService) Create(ctx context.Context, req DatasetCreateRequest) (*Dataset, error)
- func (s *DatasetsService) Delete(ctx context.Context, id string) error
- func (s *DatasetsService) Get(ctx context.Context, id string) (*Dataset, error)
- func (s *DatasetsService) History(ctx context.Context, id string) (*HistoryQuery, error)
- func (s *DatasetsService) Info(ctx context.Context, id string) (*DatasetInfo, error)
- func (s *DatasetsService) Ingest(ctx context.Context, id string, r io.Reader, typ ContentType, ...) (*IngestStatus, error)
- func (s *DatasetsService) IngestEvents(ctx context.Context, id string, opts IngestOptions, events ...Event) (*IngestStatus, error)
- func (s *DatasetsService) List(ctx context.Context) ([]*Dataset, error)
- func (s *DatasetsService) Query(ctx context.Context, id string, q query.Query, opts query.Options) (*query.Result, error)
- func (s *DatasetsService) Stats(ctx context.Context) (*DatasetStats, error)
- func (s *DatasetsService) Trim(ctx context.Context, id string, maxDuration time.Duration) (*TrimResult, error)
- func (s *DatasetsService) Update(ctx context.Context, id string, req DatasetUpdateRequest) (*Dataset, error)
- type Error
- type Event
- type Field
- type HistoryQuery
- type IngestFailure
- type IngestOptions
- type IngestStatus
- type IngestTokensService
- type License
- type ListOptions
- type Monitor
- type MonitorsService
- func (s *MonitorsService) Create(ctx context.Context, req Monitor) (*Monitor, error)
- func (s *MonitorsService) Delete(ctx context.Context, id string) error
- func (s *MonitorsService) Get(ctx context.Context, id string) (*Monitor, error)
- func (s *MonitorsService) List(ctx context.Context) ([]*Monitor, error)
- func (s *MonitorsService) Update(ctx context.Context, id string, req Monitor) (*Monitor, error)
- type Notifier
- type NotifiersService
- func (s *NotifiersService) Create(ctx context.Context, req Notifier) (*Notifier, error)
- func (s *NotifiersService) Delete(ctx context.Context, id string) error
- func (s *NotifiersService) Get(ctx context.Context, id string) (*Notifier, error)
- func (s *NotifiersService) List(ctx context.Context) ([]*Notifier, error)
- func (s *NotifiersService) Update(ctx context.Context, id string, req Notifier) (*Notifier, error)
- type Option
- type Organization
- type OrganizationUpdateRequest
- type OrganizationsService
- func (s *OrganizationsService) Get(ctx context.Context, id string) (*Organization, error)
- func (s *OrganizationsService) License(ctx context.Context, organizationID string) (*License, error)
- func (s *OrganizationsService) List(ctx context.Context) ([]*Organization, error)
- func (s *OrganizationsService) Update(ctx context.Context, id string, req OrganizationUpdateRequest) (*Organization, error)
- type OwnerKind
- type PersonalTokensService
- type Plan
- type QueryKind
- type RawToken
- type StarredQueriesListOptions
- type StarredQueriesService
- func (s *StarredQueriesService) Create(ctx context.Context, req StarredQuery) (*StarredQuery, error)
- func (s *StarredQueriesService) Delete(ctx context.Context, id string) error
- func (s *StarredQueriesService) Get(ctx context.Context, id string) (*StarredQuery, error)
- func (s *StarredQueriesService) List(ctx context.Context, opts StarredQueriesListOptions) ([]*StarredQuery, error)
- func (s *StarredQueriesService) Update(ctx context.Context, id string, req StarredQuery) (*StarredQuery, error)
- type StarredQuery
- type Team
- type TeamCreateRequest
- type TeamsService
- func (s *TeamsService) Create(ctx context.Context, req TeamCreateRequest) (*Team, error)
- func (s *TeamsService) Delete(ctx context.Context, id string) error
- func (s *TeamsService) Get(ctx context.Context, id string) (*Team, error)
- func (s *TeamsService) List(ctx context.Context) ([]*Team, error)
- func (s *TeamsService) Update(ctx context.Context, id string, req Team) (*Team, error)
- type Token
- type TokenCreateRequest
- type TrimResult
- type Type
- type User
- type UserCreateRequest
- type UserRole
- type UserUpdateRequest
- type UsersService
- func (s *UsersService) Create(ctx context.Context, req UserCreateRequest) (*User, error)
- func (s *UsersService) Current(ctx context.Context) (*AuthenticatedUser, error)
- func (s *UsersService) Delete(ctx context.Context, id string) error
- func (s *UsersService) Get(ctx context.Context, id string) (*User, error)
- func (s *UsersService) List(ctx context.Context) ([]*User, error)
- func (s *UsersService) Update(ctx context.Context, id string, req UserUpdateRequest) (*User, error)
- func (s *UsersService) UpdateRole(ctx context.Context, id string, role UserRole) (*User, error)
- type VersionService
- type VirtualField
- type VirtualFieldListOptions
- type VirtualFieldsService
- func (s *VirtualFieldsService) Create(ctx context.Context, req VirtualField) (*VirtualField, error)
- func (s *VirtualFieldsService) Delete(ctx context.Context, id string) error
- func (s *VirtualFieldsService) Get(ctx context.Context, id string) (*VirtualField, error)
- func (s *VirtualFieldsService) List(ctx context.Context, opts VirtualFieldListOptions) ([]*VirtualField, error)
- func (s *VirtualFieldsService) Update(ctx context.Context, id string, req VirtualField) (*VirtualField, error)
Examples ¶
Constants ¶
const CloudURL = "https://cloud.axiom.co"
CloudURL is the url of the cloud hosted version of Axiom.
const TimestampField = "_time"
TimestampField is the default field the server looks for a time to use as ingestion time. If not present, the server will set the ingestion time by itself.
Variables ¶
var ( // ErrUnauthenticated is raised when the access token isn't valid. ErrUnauthenticated = errors.New("invalid authentication credentials") // ErrUnprivilegedToken is raised when a client tries to call a non-ingest // endpoint with an ingest-only token configured. ErrUnprivilegedToken = errors.New("using ingest token for non-ingest operation") )
var ( // ErrUnknownContentType is raised when the given content type is not valid. ErrUnknownContentType = errors.New("unknown content type") // ErrUnknownContentEncoding is raised when the given content encoding is // not valid. ErrUnknownContentEncoding = errors.New("unknown content encoding") )
Functions ¶
func DefaultHTTPClient ¶
DefaultHTTPClient returns the default HTTP client used for making requests.
func GZIPStreamer ¶
GZIPStreamer returns an io.Reader that gzip compresses the data it reads from the provided reader using the specified compression level.
func IsIngestToken ¶ added in v0.1.2
IsIngestToken returns true if the given acces token is an ingest token. If false is returned, that does not imply that the token is a personal token.
func IsPersonalToken ¶ added in v0.1.2
IsPersonalToken returns true if the given acces token is a personal token. If false is returned, that does not imply that the token is an ingest token.
Types ¶
type AuthenticatedUser ¶
type AuthenticatedUser struct { // ID is the unique id of the user. ID string `json:"id"` // Name of the user. Name string `json:"name"` // Emails are the email addresses of the user. Emails []string `json:"emails"` }
AuthenticatedUser represents an authenticated Axiom user.
type Client ¶
type Client struct { Dashboards *DashboardsService Datasets *DatasetsService Monitors *MonitorsService Notifiers *NotifiersService Organizations *OrganizationsService StarredQueries *StarredQueriesService Teams *TeamsService Tokens struct { Ingest *IngestTokensService Personal *PersonalTokensService } Users *UsersService Version *VersionService VirtualFields *VirtualFieldsService // contains filtered or unexported fields }
Client provides the Axiom HTTP API operations.
func NewClient ¶
NewClient returns a new Axiom API client. The access token must be a personal or ingest token which can be created on the user profile or settings page of a deployment.
func NewCloudClient ¶
NewCloudClient is like NewClient but assumes the official Axiom Cloud URL as base URL and accepts an organization ID. When using an ingest token, the organization ID must match the organization the token was issued for.
type Comparison ¶
type Comparison uint8
Comparison represents a comparison operation for a monitor. A monitor acts on the result of comparing a query result with a threshold.
const ( Below Comparison = iota + 1 BelowOrEqual Above AboveOrEqual )
All available monitor comparison modes.
func (Comparison) MarshalJSON ¶
func (c Comparison) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler. It is in place to marshal the Comparison to its string representation because that's what the server expects.
func (Comparison) String ¶
func (i Comparison) String() string
func (*Comparison) UnmarshalJSON ¶
func (c *Comparison) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the Comparison from the string representation the server returns.
type ContentEncoding ¶
type ContentEncoding uint8
ContentEncoding describes the content encoding of the data to ingest.
const ( // Identity marks the data as not being encoded. Identity ContentEncoding = iota + 1 // // GZIP marks the data as being gzip encoded. GZIP // gzip )
func (ContentEncoding) String ¶
func (i ContentEncoding) String() string
type ContentType ¶
type ContentType uint8
ContentType describes the content type of the data to ingest.
const ( // JSON treats the data as JSON array. JSON ContentType = iota + 1 // application/json // NDJSON treats the data as newline delimited JSON objects. Preferred // format. NDJSON // application/x-ndjson // CSV treats the data as CSV content. CSV // text/csv )
func DetectContentType ¶
DetectContentType detects the content type of an io.Reader's data. The returned io.Reader must be used instead of the passed one. Compressed content is not detected.
func (ContentType) String ¶
func (i ContentType) String() string
type Dashboard ¶
type Dashboard struct { // ID is the unique ID of the dashboard. ID string `json:"id"` // Name of the dashboard. Name string `json:"name"` // Description of the dashboard. Description string `json:"description"` // Owner is the ID of the dashboard owner. Owner string `json:"owner"` // Charts contains the raw data composing the dashboards charts. Charts []interface{} `json:"charts"` // Layout contains the raw data composing the dashboards layout. Layout []interface{} `json:"layout"` // RefreshTime is the duration after which the dashboards data is updated. RefreshTime time.Duration `json:"refreshTime"` // SchemaVersion auto increments with ever change made to the dashboard. SchemaVersion int `json:"schemaVersion"` // TimeWindowStart is the start of the time window displayed by the // dashboard. The format is special: It has the prefix "qr-now", followed // by a string duration. If the dashboard has a time range of "last 30 // minutes", this will be: "qr-now-30m". TimeWindowStart string `json:"timeWindowStart"` // TimeWindowEnd is the end of the time window displayed by the dashboard. // The format is special: It has the prefix "qr-now", followed // by a string duration. If the dashboard has a time range of "last 30 // minutes of yesterday", this will be: "qr-now-1d". But in most cases it // will "qr-now". TimeWindowEnd string `json:"timeWindowEnd"` // Version of the dashboard. Version string `json:"version"` }
Dashboard represents a dashboard.
func (Dashboard) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the RefreshTime to seconds because that's what the server expects.
func (*Dashboard) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the RefreshTime into a proper time.Duration value because the server returns it in seconds.
type DashboardsService ¶
type DashboardsService service
DashboardsService handles communication with the dashboard related operations of the Axiom API.
Axiom API Reference: /api/v1/dashboards
func (*DashboardsService) Create ¶
Create a dashboard with the given properties. The ID and Version fields of the request payload are ignored.
func (*DashboardsService) Delete ¶
func (s *DashboardsService) Delete(ctx context.Context, id string) error
Delete the dashboard identified by the given id.
func (*DashboardsService) List ¶
func (s *DashboardsService) List(ctx context.Context, opts ListOptions) ([]*Dashboard, error)
List all available dashboards.
func (*DashboardsService) Update ¶
func (s *DashboardsService) Update(ctx context.Context, id string, req Dashboard) (*Dashboard, error)
Update the dashboard identified by the given id with the given properties. When updating, the Version is mandantory and must be set to the current version of the dashboard as returned by a Get() call.
type Dataset ¶
type Dataset struct { // ID of the dataset. ID string `json:"id"` // Name is the unique name of the dataset. Name string `json:"name"` // Description of the dataset. Description string `json:"description"` // CreatedBy is the ID of the user who created the dataset. CreatedBy string `json:"who"` // CreatedAt is the time the dataset was created at. CreatedAt time.Time `json:"created"` }
Dataset represents an Axiom dataset.
type DatasetCreateRequest ¶
type DatasetCreateRequest struct { // Name of the dataset to create. Restricted to 128 bytes of [a-zA-Z0-9] and // special characters "-", "_" and ".". Special characters cannot be a // prefix or suffix. The prefix cannot be "axiom-". Name string `json:"name"` // Description of the dataset to create. Description string `json:"description"` }
DatasetCreateRequest is a request used to create a dataset.
type DatasetInfo ¶
type DatasetInfo struct { // Name is the unique name of the dataset. Name string `json:"name"` // NumBlocks is the number of blocks of the dataset. NumBlocks uint64 `json:"numBlocks"` // NumEvents is the number of events of the dataset. NumEvents uint64 `json:"numEvents"` // NumFields is the number of fields of the dataset. NumFields uint32 `json:"numFields"` // InputBytes is the amount of data stored in the dataset. InputBytes uint64 `json:"inputBytes"` // InputBytesHuman is the amount of data stored in the dataset formatted in // a human readable format. InputBytesHuman string `json:"inputBytesHuman"` // CompressedBytes is the amount of compressed data stored in the dataset. CompressedBytes uint64 `json:"compressedBytes"` // CompressedBytesHuman is the amount of compressed data stored in the // dataset formatted in a human readable format. CompressedBytesHuman string `json:"compressedBytesHuman"` // MinTime is the time of the oldest event stored in the dataset. MinTime time.Time `json:"minTime"` // MaxTime is the time of the newest event stored in the dataset. MaxTime time.Time `json:"maxTime"` // Fields are the fields of the dataset. Fields []Field `json:"fields"` // Created is the time the dataset was created at. Created time.Time `json:"created"` }
DatasetInfo represents the details of the information stored inside an Axiom dataset.
type DatasetStats ¶
type DatasetStats struct { Datasets []*DatasetInfo `json:"datasets"` // NumBlocks is the number of blocks of the dataset. NumBlocks uint64 `json:"numBlocks"` // NumEvents is the number of events of the dataset. NumEvents uint64 `json:"numEvents"` // InputBytes is the amount of data stored in the dataset. InputBytes uint64 `json:"inputBytes"` // InputBytesHuman is the amount of data stored in the dataset formatted in // a human readable format. InputBytesHuman string `json:"inputBytesHuman"` // CompressedBytes is the amount of compressed data stored in the dataset. CompressedBytes uint64 `json:"compressedBytes"` // CompressedBytesHuman is the amount of compressed data stored in the // dataset formatted in a human readable format. CompressedBytesHuman string `json:"compressedBytesHuman"` }
DatasetStats are the stats of
type DatasetUpdateRequest ¶
type DatasetUpdateRequest struct { // Description of the dataset to update. Description string `json:"description"` }
DatasetUpdateRequest is a request used to update a dataset.
type DatasetsService ¶
type DatasetsService service
DatasetsService handles communication with the dataset related operations of the Axiom API.
Axiom API Reference: /api/v1/datasets
func (*DatasetsService) Create ¶
func (s *DatasetsService) Create(ctx context.Context, req DatasetCreateRequest) (*Dataset, error)
Create a dataset with the given properties.
func (*DatasetsService) Delete ¶
func (s *DatasetsService) Delete(ctx context.Context, id string) error
Delete the dataset identified by the given id.
func (*DatasetsService) History ¶
func (s *DatasetsService) History(ctx context.Context, id string) (*HistoryQuery, error)
History retrieves the query stored inside the query history dataset identified by its id.
func (*DatasetsService) Info ¶
func (s *DatasetsService) Info(ctx context.Context, id string) (*DatasetInfo, error)
Info retrieves the information of the dataset identified by its id.
func (*DatasetsService) Ingest ¶
func (s *DatasetsService) Ingest(ctx context.Context, id string, r io.Reader, typ ContentType, enc ContentEncoding, opts IngestOptions) (*IngestStatus, error)
Ingest data into the dataset identified by its id. If the dataset doesn't exist, it will be created. The given data will be flattened, thus there are some restrictions on the field names (JSON object keys):
- Not more than 200 bytes
- Valid UTF-8
- "_time" must conform to a valid timestamp or not be present at all
- If "_time" is not present, the server will assign a timestamp
- The ingestion content type must be one of JSON, NDJSON or CSV and the input must be formatted accordingly
func (*DatasetsService) IngestEvents ¶
func (s *DatasetsService) IngestEvents(ctx context.Context, id string, opts IngestOptions, events ...Event) (*IngestStatus, error)
IngestEvents ingests events into the dataset identified by its id. If the dataset doesn't exist, it will be created. The given data will be flattened, thus there are some restrictions on the field names (JSON object keys):
- Not more than 200 bytes
- Valid UTF-8
- "_time" must conform to a valid timestamp or not be present at all
- If "_time" is not present, the server will assign a timestamp
- The ingestion content type must be one of JSON, NDJSON or CSV and the input must be formatted accordingly
func (*DatasetsService) List ¶
func (s *DatasetsService) List(ctx context.Context) ([]*Dataset, error)
List all available datasets.
func (*DatasetsService) Query ¶
func (s *DatasetsService) Query(ctx context.Context, id string, q query.Query, opts query.Options) (*query.Result, error)
Query executes the given query on the dataset identified by its id.
func (*DatasetsService) Stats ¶
func (s *DatasetsService) Stats(ctx context.Context) (*DatasetStats, error)
Stats returns detailed statistics about all available datasets. This operation is more expenssive and listing the datasets and then getting the information of a specific dataset is preferred, when no aggregated statistics across all datasets are needed.
func (*DatasetsService) Trim ¶
func (s *DatasetsService) Trim(ctx context.Context, id string, maxDuration time.Duration) (*TrimResult, error)
Trim the dataset identified by its id to a given length. The max duration given will mark the oldest timestamp an event can have. Older ones will be deleted from the dataset.
func (*DatasetsService) Update ¶
func (s *DatasetsService) Update(ctx context.Context, id string, req DatasetUpdateRequest) (*Dataset, error)
Update the dataset identified by the given id with the given properties.
type Error ¶
type Error struct { ErrorMessage string `json:"error"` Message string `json:"message"` // contains filtered or unexported fields }
Error is the generic error response returned on non 2xx HTTP status codes. Either one of the two fields is populated. However, calling the Error() method is preferred.
type Field ¶
type Field struct { // Name is the unique name of the field. Name string `json:"name"` // Type is the datatype of the field. Type string `json:"type"` // TypeHint is a hint regarding the datatype of the field. TypeHint string `json:"typeHint"` }
Field represents a field of an Axiom dataset.
type HistoryQuery ¶
type HistoryQuery struct { // ID is the unique id of the starred query. ID string `json:"id"` // Kind of the starred query. Kind QueryKind `json:"kind"` // Dataset the starred query belongs to. Dataset string `json:"dataset"` // Owner is the ID of the starred queries owner. Can be a user or team ID. Owner string `json:"who"` // Query is the actual query. Query query.Query `json:"query"` // Created is the time the starred query was created at. Created time.Time `json:"created"` }
HistoryQuery represents a query stored inside the query history.
type IngestFailure ¶
type IngestFailure struct { // Timestamp of the event that failed to ingest. Timestamp time.Time `json:"timestamp"` // Error that made the event fail to ingest. Error string `json:"error"` }
IngestFailure describes the ingestion failure of a single event.
type IngestOptions ¶
type IngestOptions struct { // TimestampField defines a custom field to extract the ingestion timestamp // from. Defaults to `_time`. TimestampField string `url:"timestamp-field,omitempty"` // TimestampFormat defines a custom format for the TimestampField. // The reference time is `Mon Jan 2 15:04:05 -0700 MST 2006`, as specified // in https://pkg.go.dev/time/?tab=doc#Parse. TimestampFormat string `url:"timestamp-format,omitempty"` // CSVDelimiter is the delimiter that separates CSV fields. Only valid when // the content to be ingested is CSV formatted. CSVDelimiter string `url:"csv-delimiter,omitempty"` }
IngestOptions specifies the parameters for the Ingest and IngestEvents method of the Datasets service.
type IngestStatus ¶
type IngestStatus struct { // Ingested is the amount of events that have been ingested. Ingested uint64 `json:"ingested"` // Failed is the amount of events that failed to ingest. Failed uint64 `json:"failed"` // Failures are the ingestion failures, if any. Failures []*IngestFailure `json:"failures"` // ProcessedBytes is the number of bytes processed. ProcessedBytes uint64 `json:"processedBytes"` // BlocksCreated is the amount of blocks created. BlocksCreated uint32 `json:"blocksCreated"` // WALLength is the length of the Write-Ahead Log. WALLength uint32 `json:"walLength"` }
IngestStatus is the status after an event ingestion operation.
type IngestTokensService ¶
type IngestTokensService = tokensService
IngestTokensService handles communication with the ingest token related operations of the Axiom API.
Axiom API Reference: /api/v1/tokens/ingest
type License ¶
type License struct { // ID of the license. ID string `json:"id"` // Issuer of the license. Issuer string `json:"issuer"` // IssuedTo describes who the license was issued to. IssuedTo string `json:"issuedTo"` // IssuedAt is the time the license was issued at. IssuedAt time.Time `json:"issuedAt"` // ValidFrom is the time the license is valid from. ValidFrom time.Time `json:"validFrom"` // ExpiresAt is the time the license expires. ExpiresAt time.Time `json:"expiresAt"` // Tier of the license. Tier Plan `json:"tier"` // DailyIngestGB is the daily amount of data in gigabytes that can be // ingested as part of the license. DailyIngestGB int `json:"dailyIngestGb"` // MaxUsers is the maximum amount of teams allowed. MaxUsers int `json:"maxUsers"` // MaxTeams is the maximum amount of user allowed. MaxTeams int `json:"maxTeams"` // MaxDatasets is the maximum amount of datasets allowed. MaxDatasets int `json:"maxDatasets"` // MaxQueriesPerSecond is the maximum amount of queries allowed per second. MaxQueriesPerSecond int `json:"maxQueriesPerSecond"` // MaxQueryWindow is the maximum query window allowed. MaxQueryWindow time.Duration `json:"maxQueryWindowSeconds"` // MaxAuditWindow is the maximum audit window allowed. MaxAuditWindow time.Duration `json:"maxAuditWindowSeconds"` // WithRBAC specifies it RBAC is enabled. WithRBAC bool `json:"withRBAC"` // WithAuths specifies the supported authentication modes. WithAuths []string `json:"withAuths"` // Error is the last error (if any) on token refresh. Error string `json:"error"` }
License of a deployment or organization.
func (License) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the MaxQueryWindow and MaxAuditWindow to seconds because that's what the server expects.
func (*License) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the MaxQueryWindow and MaxAuditWindow into a proper time.Duration value because the server returns it in seconds.
type ListOptions ¶
type ListOptions struct { // Limit of the of the result set. Limit uint `url:"limit,omitempty"` // Offset the result set has from its base. Offset uint `url:"offset,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support result limits.
type Monitor ¶
type Monitor struct { // ID is the unique id of the monitor. ID string `json:"id"` // Dataset the monitor belongs to. Dataset string `json:"dataset"` // Name is the display name of the monitor. Name string `json:"name"` // Description of the monitor. Description string `json:"description"` // DisabledUntil is the time until the monitor is being executed again. DisabledUntil time.Time `json:"disabledUntil"` // Query is executed by the monitor and the result is compared using the // monitors configured comparison operator against the configured threshold. Query query.Query `json:"query"` // Threshold the query result is compared against, which evalutes if the // monitor acts or not. Threshold float64 `json:"threshold"` // Comparison operator to use for comparing the query result and threshold // value. Comparison Comparison `json:"comparison"` // NoDataCloseWait specifies after which amount of laking a query result, // the monitor is closed. NoDataCloseWait time.Duration `json:"noDataCloseWaitMinutes"` // Frequency the monitor is executed by. Frequency time.Duration `json:"frequencyMinutes"` // Duration the monitor goes back in time and looks at the data it acts on. Duration time.Duration `json:"durationMinutes"` // Notifiers attached to the monitor. Notifiers []string `json:"notifiers"` // LastCheckTime specifies the last time the monitor executed the query and // compared its result against the threshold. LastCheckTime time.Time `json:"lastCheckTime"` // LastCheckState is the state associated with the last monitor execution. LastCheckState map[string]string `json:"lastCheckState"` }
A Monitor continuesly runs a query on a dataset and evaluates its result against a configured threshold. Upon reaching those it will invoke the configured notifiers.
func (Monitor) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the NoDataCloseWait, Frequency and Duration to minutes because that's what the server expects.
func (*Monitor) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the RefreshTime into a proper time.Duration value because the server returns it in seconds.
type MonitorsService ¶
type MonitorsService service
MonitorsService handles communication with the monitor related operations of the Axiom API.
Axiom API Reference: /api/v1/monitors
func (*MonitorsService) Delete ¶
func (s *MonitorsService) Delete(ctx context.Context, id string) error
Delete the monitor identified by the given id.
type Notifier ¶
type Notifier struct { // ID is the unique id of the notifier. ID string `json:"id"` // Name is the display name of the notifier. Name string `json:"name"` // Type of a notifier. Type Type `json:"type"` // Properties of the notifier. Properties interface{} `json:"properties"` // DisabledUntil is the time until the notifier is being executed again. DisabledUntil time.Time `json:"disabledUntil"` // Created is the time the notifer was created at. Created time.Time `json:"metaCreated"` // Modified is the time the notifer was updated at. Modified time.Time `json:"metaModified"` // Version of the notifier. Version int64 `json:"metaVersion"` }
A Notifier alerts users by using the configured service to reach out to them.
type NotifiersService ¶
type NotifiersService service
NotifiersService handles communication with the notifier related operations of the Axiom API.
Axiom API Reference: /api/v1/notifiers
func (*NotifiersService) Delete ¶
func (s *NotifiersService) Delete(ctx context.Context, id string) error
Delete the notifier identified by the given id.
type Option ¶
An Option modifies the behaviour of the API client. If not otherwise specified by a specific option, they are safe to use even after API methods have been called. However, they are not safe to use while the client is performing an operation.
func SetAccessToken ¶ added in v0.1.2
SetAccessToken specifies the access token to use.
func SetBaseURL ¶
SetBaseURL sets the base URL used by the client. It overwrittes the one set by the call to NewClient() or NewCloudClient().
func SetOrgID ¶ added in v0.1.1
SetOrgID specifies the organization ID to use. When a personal access token is used, this method can be used to switch between organizations without creating a new client instance.
func SetUserAgent ¶
SetUserAgent sets the user agent used by the client.
type Organization ¶
type Organization struct { // ID is the unique id of the organization. ID string `json:"id"` // Name of the organization. Name string `json:"name"` // Slug of the organization. Slug string `json:"slug"` // Plan the deployment or organization is on. Plan Plan `json:"plan"` // PlanCreated is the time the plan was created. PlanCreated time.Time `json:"planCreated"` // PlanExpires is the time the plan will expire. PlanExpires time.Time `json:"planExpires"` // Trialed describes if the plan is trialed or not. Trialed bool `json:"trialed"` // PreviousPlan is the previous plan the deployment or organization was on. PreviousPlan Plan `json:"previousPlan"` // PreviousPlanCreated is the time the previous plan was created. PreviousPlanCreated time.Time `json:"previousPlanCreated"` // PreviousPlanExpired is the time the previous plan expired. PreviousPlanExpired time.Time `json:"previousPlanExpired"` // LastUsageSync is the last time the usage instance usage statistics were // synchronized. LastUsageSync time.Time `json:"lastUsageSync"` // Role the requesting user has on the deployment or the organization. Role UserRole `json:"role"` // PrimaryEmail of the user that issued the request. PrimaryEmail string `json:"primaryEmail"` // License of the deployment or organization. License License `json:"license"` // Created is the time the Organization was created. Created time.Time `json:"metaCreated"` // Modified is the time the Organization was modified. Modified time.Time `json:"metaModified"` // Version of the organization. Version string `json:"metaVersion"` }
Organization represents an organization. For selfhost deployments, there is only one main organization, therefor it is referred to as deployment.
type OrganizationUpdateRequest ¶
type OrganizationUpdateRequest struct { // Name of the user. Name string `json:"name"` }
OrganizationUpdateRequest is a request used to update an organization.
type OrganizationsService ¶
type OrganizationsService service
OrganizationsService handles communication with the organization related operations of the Axiom API.
Axiom API Reference: /api/v1/orgs
func (*OrganizationsService) Get ¶
func (s *OrganizationsService) Get(ctx context.Context, id string) (*Organization, error)
Get an organization by id.
func (*OrganizationsService) License ¶
func (s *OrganizationsService) License(ctx context.Context, organizationID string) (*License, error)
License gets an organizations license.
func (*OrganizationsService) List ¶
func (s *OrganizationsService) List(ctx context.Context) ([]*Organization, error)
List all available organizations.
func (*OrganizationsService) Update ¶
func (s *OrganizationsService) Update(ctx context.Context, id string, req OrganizationUpdateRequest) (*Organization, error)
Update the organization identified by the given id with the given properties.
type OwnerKind ¶
type OwnerKind uint8
OwnerKind represents the kind of a starred queries owner.
func (OwnerKind) EncodeValues ¶
EncodeValues implements query.Encoder. It is in place to encode the OwnerKind into a string URL value because that's what the server expects.
type PersonalTokensService ¶
type PersonalTokensService = tokensService
PersonalTokensService handles communication with the personal token related operations of the Axiom API.
Axiom API Reference: /api/v1/tokens/personal
type Plan ¶
type Plan uint8
Plan represents the plan of a deployment or organization.
All available deployment or organization plans.
func (Plan) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the Plan to its string representation because that's what the server expects.
func (*Plan) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the Plan from the string representation the server returns.
type QueryKind ¶
type QueryKind uint8
QueryKind represents the role of a query.
func (QueryKind) EncodeValues ¶
EncodeValues implements query.Encoder. It is in place to encode the QueryKind into a string URL value because that's what the server expects.
func (QueryKind) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the QueryKind to its string representation because that's what the server expects.
func (*QueryKind) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the QueryKind from the string representation the server returns.
type RawToken ¶
type RawToken struct { // Token is the actual secret value of the token. Token string `json:"token"` // Scopes of the token. Only used by ingest tokens. Scopes []string `json:"scopes"` }
RawToken represents a raw token secret and its attached scopes.
type StarredQueriesListOptions ¶
type StarredQueriesListOptions struct { // Kind of queries to list. Required. Kind QueryKind `url:"kind"` // Dataset to list starred queries for. Dataset string `url:"dataset,omitempty"` // Owner specifies if the starred queries of a users teams or personal ones // are listed. Owner OwnerKind `url:"who,omitempty"` ListOptions }
StarredQueriesListOptions specifies the parameters for the List method of the StarredQuerys service.
type StarredQueriesService ¶
type StarredQueriesService service
StarredQueriesService handles communication with the starred query related operations of the Axiom API.
Axiom API Reference: /api/v1/starred
func (*StarredQueriesService) Create ¶
func (s *StarredQueriesService) Create(ctx context.Context, req StarredQuery) (*StarredQuery, error)
Create a starred query with the given properties.
func (*StarredQueriesService) Delete ¶
func (s *StarredQueriesService) Delete(ctx context.Context, id string) error
Delete the starred query identified by the given id.
func (*StarredQueriesService) Get ¶
func (s *StarredQueriesService) Get(ctx context.Context, id string) (*StarredQuery, error)
Get a starred query by id.
func (*StarredQueriesService) List ¶
func (s *StarredQueriesService) List(ctx context.Context, opts StarredQueriesListOptions) ([]*StarredQuery, error)
List all available starred queries.
func (*StarredQueriesService) Update ¶
func (s *StarredQueriesService) Update(ctx context.Context, id string, req StarredQuery) (*StarredQuery, error)
Update the starred query identified by the given id with the given properties.
type StarredQuery ¶
type StarredQuery struct { // ID is the unique id of the starred query. ID string `json:"id"` // Kind of the starred query. Kind QueryKind `json:"kind"` // Dataset the starred query belongs to. Dataset string `json:"dataset"` // Owner is the ID of the starred queries owner. Can be a user or team ID. Owner string `json:"who"` // Name is the display name of the starred query. Name string `json:"name"` // Query is the actual query. Query query.Query `json:"query"` // Metadata associated with the query. Metadata map[string]string `json:"metadata"` // Created is the time the starred query was created at. Created time.Time `json:"created"` }
StarredQuery represents a starred query of a dataset.
type Team ¶
type Team struct { // ID is the unique id of the team. ID string `json:"id"` // Name of the team. Name string `json:"name"` // Members are the IDs of the teams members. Members []string `json:"members"` // Datasets are the IDs of the teams assigned datasets. Datasets []string `json:"datasets"` }
Team represents a team.
type TeamCreateRequest ¶
type TeamCreateRequest struct { // Name of the team. Name string `json:"name"` // Datasets of the team. Datasets []string `json:"datasets"` }
TeamCreateRequest is a request used to create a team.
type TeamsService ¶
type TeamsService service
TeamsService handles communication with the team related operations of the Axiom API.
Axiom API Reference: /api/v1/teams
func (*TeamsService) Create ¶
func (s *TeamsService) Create(ctx context.Context, req TeamCreateRequest) (*Team, error)
Create a team with the given properties.
func (*TeamsService) Delete ¶
func (s *TeamsService) Delete(ctx context.Context, id string) error
Delete the team identified by the given id.
type Token ¶
type Token struct { // ID is the unique id of the token. ID string `json:"id"` // Name of the token. Name string `json:"name"` // Description of the token. Description string `json:"description"` // Scopes of the token. Only used by ingest tokens. Scopes []string `json:"scopes"` }
Token represents an access token. Tokens can either be ingest tokens, valid for ingestion into one or more datasets or personal tokens for access to the whole Axiom API.
type TokenCreateRequest ¶
type TokenCreateRequest struct { // Name of the token. Name string `json:"name"` // Description of the token. Description string `json:"description"` // Scopes of the token. Only used by ingest tokens. Can be set to a list of // dataset IDs to allow ingestion into the specified ones or "*" for all, // which is the default when the field is unset. Scopes []string `json:"scopes"` }
TokenCreateRequest is a request used to create a token.
type TrimResult ¶
type TrimResult struct { // BlocksDeleted is the amount of blocks deleted by the trim operation. BlocksDeleted int `json:"numDeleted"` }
TrimResult is the result of a trim operation.
type Type ¶
type Type uint8
Type represents the type of a notifier.
All available notifier types.
func (Type) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the Type to its string representation because that's what the server expects.
func (*Type) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the Type from the string representation the server returns.
type User ¶
type User struct { // ID is the unique id of the user. ID string `json:"id"` // Name of the user. Name string `json:"name"` // Email is the primary email of the user. Email string `json:"email"` // Role of the user. Role UserRole `json:"role"` // Permissions of the user. Permissions []string `json:"permissions"` }
User represents an user.
type UserCreateRequest ¶
type UserCreateRequest struct { // Name of the user. Name string `json:"name"` // Email is the primary email address of the user. Email string `json:"email"` // Role of the user. Role UserRole `json:"role"` // TeamIDs are the unique IDs of the teams the user will be part of. TeamIDs []string `json:"teamIds"` }
UserCreateRequest is a request used to create an user.
type UserRole ¶
type UserRole uint8
UserRole represents the role of a user.
const ( RoleReadOnly UserRole = iota + 1 // read-only RoleUser // user RoleAdmin // admin RoleOwner // owner )
All available user roles.
func (UserRole) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It is in place to marshal the UserRole to its string representation because that's what the server expects.
func (*UserRole) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler. It is in place to unmarshal the UserRole from the string representation the server returns.
type UserUpdateRequest ¶
type UserUpdateRequest struct { // Name of the user. Name string `json:"name"` }
UserUpdateRequest is a request used to update an user.
type UsersService ¶
type UsersService service
UsersService handles communication with the user related operations of the Axiom API.
Axiom API Reference: /api/v1/users
func (*UsersService) Create ¶
func (s *UsersService) Create(ctx context.Context, req UserCreateRequest) (*User, error)
Create a user with the given properties.
func (*UsersService) Current ¶
func (s *UsersService) Current(ctx context.Context) (*AuthenticatedUser, error)
Current retrieves the authenticated user.
func (*UsersService) Delete ¶
func (s *UsersService) Delete(ctx context.Context, id string) error
Delete the user identified by the given id.
func (*UsersService) List ¶
func (s *UsersService) List(ctx context.Context) ([]*User, error)
List all available users.
func (*UsersService) Update ¶
func (s *UsersService) Update(ctx context.Context, id string, req UserUpdateRequest) (*User, error)
Update the user identified by the given id with the given properties.
func (*UsersService) UpdateRole ¶
UpdateRole updates the role of the user identified by the given id with the given properties.
type VersionService ¶
type VersionService service
VersionService handles communication with the version related operations of the Axiom API.
Axiom API Reference: /api/v1/version
type VirtualField ¶
type VirtualField struct { // ID is the unique id of the virtual field. ID string `json:"id"` // Dataset the virtual field belongs to. Dataset string `json:"dataset"` // Name is the display name of the virtual field. Name string `json:"name"` // Description of the virtual field. Description string `json:"description"` // Alias the virtual field is referenced by. Alias string `json:"alias"` // Expression that evaluates the virtual fields value. Expression string `json:"expression"` }
VirtualField represents a virtual field of a dataset.
type VirtualFieldListOptions ¶
type VirtualFieldListOptions struct { // Dataset to list virtual fields for. Required. Dataset string `url:"dataset"` ListOptions }
VirtualFieldListOptions specifies the parameters for the List method of the VirtualFields service.
type VirtualFieldsService ¶
type VirtualFieldsService service
VirtualFieldsService handles communication with the virtual field related operations of the Axiom API.
Axiom API Reference: /api/v1/vfields
func (*VirtualFieldsService) Create ¶
func (s *VirtualFieldsService) Create(ctx context.Context, req VirtualField) (*VirtualField, error)
Create a virtual field with the given properties.
func (*VirtualFieldsService) Delete ¶
func (s *VirtualFieldsService) Delete(ctx context.Context, id string) error
Delete the virtual field identified by the given id.
func (*VirtualFieldsService) Get ¶
func (s *VirtualFieldsService) Get(ctx context.Context, id string) (*VirtualField, error)
Get a virtual field by id.
func (*VirtualFieldsService) List ¶
func (s *VirtualFieldsService) List(ctx context.Context, opts VirtualFieldListOptions) ([]*VirtualField, error)
List all available virtual fields.
func (*VirtualFieldsService) Update ¶
func (s *VirtualFieldsService) Update(ctx context.Context, id string, req VirtualField) (*VirtualField, error)
Update the virtual field identified by the given id with the given properties.