responses

package
v0.27.0-rc.13 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 3 Imported by: 2

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"`
	Key       string          `json:"key"`
	Name      string          `json:"name"`
	CreatedBy string          `json:"created_by"`
	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. Key is the credential and this is the only time it is ever sent: nothing can read it back afterwards. ID is the key's surrogate identifier, which every other route returns too and which an access policy and an SSH identity point at.

func CreateAPIKeyFromModel added in v0.16.0

func CreateAPIKeyFromModel(m *models.APIKey, plaintext string) *CreateAPIKey

CreateAPIKeyFromModel projects the stored key onto the response, which is where the model's internal fields are dropped rather than serialized by accident. The plaintext is a parameter because it is not a field of the key: it exists only in the call that generated it, and is never persisted.

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 CreateProvisioningKey

type CreateProvisioningKey struct {
	models.ProvisioningKey

	// Key is the plaintext provisioning key. Pass it to the installer as PROVISIONING_KEY.
	Key string `json:"key"`
}

CreateProvisioningKey is the response to minting a provisioning key: the stored key exactly as the listing returns it, plus the plaintext, which is shown here and afterwards only through reveal.

func CreateProvisioningKeyFromModel

func CreateProvisioningKeyFromModel(m *models.ProvisioningKey, plaintext string) *CreateProvisioningKey

CreateProvisioningKeyFromModel projects a stored provisioning key into its creation response. The plaintext 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 Member

type Member struct {
	ID               string            `json:"id,omitempty"`
	AddedAt          time.Time         `json:"added_at"`
	Email            string            `json:"email"`
	Role             authorizer.Role   `json:"role"`
	AccountStatus    models.UserStatus `json:"account_status,omitempty"`
	AwaitingApproval bool              `json:"awaiting_approval,omitempty"`
}

Member is a person's membership as the namespace routes return it. It carries no principal type, because every member here is a person.

type Namespace

type Namespace struct {
	Name     string                    `json:"name"`
	Owner    string                    `json:"owner"`
	TenantID string                    `json:"tenant_id"`
	Members  []Member                  `json:"members"`
	Settings *models.NamespaceSettings `json:"settings"`

	DevicesAcceptedCount int64 `json:"devices_accepted_count"`
	DevicesPendingCount  int64 `json:"devices_pending_count"`
	DevicesRejectedCount int64 `json:"devices_rejected_count"`
	DevicesRemovedCount  int64 `json:"devices_removed_count"`

	MaxDevices int             `json:"max_devices"`
	CreatedAt  time.Time       `json:"created_at"`
	Billing    *models.Billing `json:"billing"`
	Type       models.Type     `json:"type"`
}

Namespace is what the namespace routes return. Its Members holds people. An automation is an API key, holds no membership, and is listed by GET /api/namespaces/api-key.

func NamespaceFromModel

func NamespaceFromModel(m *models.Namespace) *Namespace

NamespaceFromModel projects the stored namespace onto the response. It returns nil for a nil namespace, and its Members is never nil, so a namespace with no member serializes as an empty array rather than null.

func NamespacesFromModel

func NamespacesFromModel(m []models.Namespace) []Namespace

NamespacesFromModel projects a page of namespaces, and returns an empty slice for an empty or nil page so the list route never serializes null.

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 RevealProvisioningKey

type RevealProvisioningKey struct {
	Key string `json:"key"`
}

RevealProvisioningKey carries a provisioning key's plaintext, decrypted on demand from its at-rest ciphertext.

Jump to

Keyboard shortcuts

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