Skip to content

Commit

Permalink
add godoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
toppercodes committed Jun 19, 2024
1 parent 4f366db commit c3e8225
Showing 1 changed file with 57 additions and 27 deletions.
84 changes: 57 additions & 27 deletions axiom/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,86 @@ import (
"time"
)

type Actions []string

type APIToken struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
ExpiresAt time.Time `json:"expiresAt"`
// ID is the unique ID of the token.
ID string `json:"id"`
// Name is the name of the token.
Name string `json:"name"`
// Description is the description of the token.
Description string `json:"description"`
// ExpiresAt is the time when the token expires.
ExpiresAt time.Time `json:"expiresAt"`
// DatasetCapabilities is a map of dataset names to the capabilities available to that dataset for the token.
DatasetCapabilities map[string]DatasetCapabilities `json:"datasetCapabilities"`
OrgCapabilities OrgCapabilities `json:"orgCapabilities"`
// OrgCapabilities is the organisation capabilities available to the token.
OrgCapabilities OrgCapabilities `json:"orgCapabilities"`
}

type DatasetCapabilities struct {
Ingest []string `json:"ingest"`
Query []string `json:"query"`
// Ingest is the ingest capability and the actions that can be performed on them.
Ingest []string `json:"ingest"`
// Query is the query capability and the actions that can be performed on them.
Query []string `json:"query"`
// StarredQueries is the starred queries capability and the actions that can be performed on them.
StarredQueries []string `json:"starredQueries"`
VirtualFields []string `json:"virtualFields"`
// VirtualFields is the VirtualFields capability and the actions that can be performed on them.
VirtualFields []string `json:"virtualFields"`
}

type OrgCapabilities struct {
Annotations []string `json:"annotations,omitempty"`
APITokens []string `json:"apiTokens,omitempty"`
Billing []string `json:"billing,omitempty"`
Dashboards []string `json:"dashboards,omitempty"`
Datasets []string `json:"datasets,omitempty"`
Endpoints []string `json:"endpoints,omitempty"`
Flows []string `json:"flows,omitempty"`
Integrations []string `json:"integrations,omitempty"`
Monitors []string `json:"monitors,omitempty"`
Notifiers []string `json:"notifiers,omitempty"`
Rbac []string `json:"rbac,omitempty"`
// Annotations is the Annotations capability and the actions that can be performed on them.
Annotations []string `json:"annotations,omitempty"`
// APITokens is the APITokens capability and the actions that can be performed on them.
APITokens []string `json:"apiTokens,omitempty"`
// Billing is the Billing capability and the actions that can be performed on them.
Billing []string `json:"billing,omitempty"`
// Dashboards is the Dashboards capability and the actions that can be performed on them.
Dashboards []string `json:"dashboards,omitempty"`
// Datasets is the Datasets capability and the actions that can be performed on them.
Datasets []string `json:"datasets,omitempty"`
// Endpoints is the Endpoints capability and the actions that can be performed on them.
Endpoints []string `json:"endpoints,omitempty"`
// Flows is the Flows capability and the actions that can be performed on them.
Flows []string `json:"flows,omitempty"`
// Integrations is the Integrations capability and the actions that can be performed on them.
Integrations []string `json:"integrations,omitempty"`
// Monitors is the Monitors capability and the actions that can be performed on them.
Monitors []string `json:"monitors,omitempty"`
// Notifiers is the Notifiers capability and the actions that can be performed on them.
Notifiers []string `json:"notifiers,omitempty"`
// Rbac is the Rbac capability and the actions that can be performed on them.
Rbac []string `json:"rbac,omitempty"`
// SharedAccessKeys is the SharedAccessKeys capability and the actions that can be performed on them.
SharedAccessKeys []string `json:"sharedAccessKeys,omitempty"`
Users []string `json:"users,omitempty"`
// Users is the Users capability and the actions that can be performed on them.
Users []string `json:"users,omitempty"`
}

type CreateTokenRequest struct {
Name string `json:"name"`
Description string `json:"description"`
ExpiresAt time.Time `json:"expiresAt"`
// Name is the name of the token.
Name string `json:"name"`
// Description is the description of the token.
Description string `json:"description"`
// ExpiresAt is the time when the token expires.
ExpiresAt time.Time `json:"expiresAt"`

// DatasetCapabilities is a map of dataset names to the capabilities available to that dataset for the token.
DatasetCapabilities map[string]DatasetCapabilities `json:"datasetCapabilities"`
OrgCapabilities OrgCapabilities `json:"orgCapabilities"`
// OrgCapabilities is the organisation capabilities available to the token.
OrgCapabilities OrgCapabilities `json:"orgCapabilities"`
}

type CreateTokenResponse struct {
APIToken
// Token is the token value to be used in api calls
Token string `json:"token"`
}

type RegenerateTokenRequest struct {
// ExistingTokenExpiresAt is the time when the existing token will expire.
ExistingTokenExpiresAt time.Time `json:"existingTokenExpiresAt"`
NewTokenExpiresAt time.Time `json:"newTokenExpiresAt"`
// NewTokenExpiresAt is the time when the new token will expire.
NewTokenExpiresAt time.Time `json:"newTokenExpiresAt"`
}

// Axiom API Reference: /v2/tokens
Expand Down

0 comments on commit c3e8225

Please sign in to comment.