Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateAPIKey ¶ added in v0.16.0
type CreateAPIKey struct {
ID string `json:"id"`
Name string `json:"name"`
UserID string `json:"user_id"`
TenantID string `json:"tenant_id"`
Role authorizer.Role `json:"role" validate:"required,oneof=administrator operator observer"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiresIn int64 `json:"expires_in"`
}
CreateAPIKey is what the create-API-key route returns. ID is the key itself and this is the only time it is ever sent: nothing can read it back afterwards.
func CreateAPIKeyFromModel ¶ added in v0.16.0
func CreateAPIKeyFromModel(m *models.APIKey) *CreateAPIKey
CreateAPIKeyFromModel projects the stored key onto the response, which is where the model's internal fields are dropped rather than serialized by accident.
type CreateInstallKey ¶
type CreateInstallKey struct {
// Key is the plaintext install key. It is shown at creation and afterwards only via reveal.
Key string `json:"key"`
Name string `json:"name"`
UserID string `json:"user_id"`
TenantID string `json:"tenant_id"`
Reusable bool `json:"reusable"`
UsageLimit int `json:"usage_limit"`
UsedTimes int `json:"used_times"`
LastUsedAt *time.Time `json:"last_used_at"`
Ephemeral bool `json:"ephemeral"`
Tags []string `json:"tags"`
Revoked bool `json:"revoked"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiresAt *time.Time `json:"expires_at"`
}
CreateInstallKey is returned once, at creation. It carries the plaintext key, which afterwards can only be seen again through the reveal endpoint.
func CreateInstallKeyFromModel ¶
func CreateInstallKeyFromModel(m *models.InstallKey) *CreateInstallKey
CreateInstallKeyFromModel maps a model into the create response. The plaintext key must be placed into m.ID by the caller before mapping (the stored model only ever holds the hash).
type CreateInstanceAPIKey ¶
type CreateInstanceAPIKey struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedBy string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiresAt time.Time `json:"expires_at"`
}
CreateInstanceAPIKey is the response to minting an instance API key. ID carries the plaintext key, which is returned here and nowhere else; the server keeps only its digest.
func CreateInstanceAPIKeyFromModel ¶
func CreateInstanceAPIKeyFromModel(m *models.InstanceAPIKey, plaintext string) *CreateInstanceAPIKey
CreateInstanceAPIKeyFromModel projects a stored instance API key into its creation response. The plaintext key is a separate argument because the model carries only its digest: passing it explicitly is what stops the digest being returned to the caller by omission.
type Error ¶
type Error struct {
// Message is a human-readable description of what failed. It is always present.
Message string `json:"message"`
// Fields maps a request field name to the reason it was rejected. It is present only when the
// error carries per-field detail.
Fields map[string]string `json:"fields,omitempty"`
}
Error is the body of every API error response.
It is a projection, not a marshalling of the internal error type: that type carries a layer name and an internal code which must never reach a client.
type PublicKeyCreate ¶
type PublicKeyCreate struct {
Data []byte `json:"data"`
Filter PublicKeyFilter `json:"filter"`
Name string `json:"name"`
Username string `json:"username"`
TenantID string `json:"tenant_id"`
Fingerprint string `json:"fingerprint"`
}
PublicKeyCreate is the structure to represent the request data for create public key endpoint.
type PublicKeyFilter ¶
type PublicKeyFilter struct {
Hostname string `json:"hostname,omitempty" validate:"required_without=Tags,excluded_with=Tags,regexp"`
// FIXME: add validation for tags when it has at least one item.
//
// If used `min=1` to do that validation, when tags is empty, its zero value, and only hostname is provided,
// it throws a error even with `required_without` and `excluded_with`.
Tags []string `` /* 142-byte string literal not displayed */
}
PublicKeyFilter is the device selector as it is sent back to a client: either a hostname pattern or a tag set, never both.
type RevealInstallKey ¶
type RevealInstallKey struct {
Key string `json:"key"`
}
RevealInstallKey carries a install key's plaintext, decrypted on demand from its at-rest ciphertext.