Files
lincodex/labd/internal/api/oas_schemas_gen.go
T

1326 lines
35 KiB
Go

// Code generated by ogen, DO NOT EDIT.
package api
import (
"fmt"
"time"
"github.com/go-faster/errors"
"github.com/google/uuid"
)
func (s *ProblemStatusCode) Error() string {
return fmt.Sprintf("code %d: %+v", s.StatusCode, s.Response)
}
type BearerAuth struct {
Token string
Roles []string
}
// GetToken returns the value of Token.
func (s *BearerAuth) GetToken() string {
return s.Token
}
// GetRoles returns the value of Roles.
func (s *BearerAuth) GetRoles() []string {
return s.Roles
}
// SetToken sets the value of Token.
func (s *BearerAuth) SetToken(val string) {
s.Token = val
}
// SetRoles sets the value of Roles.
func (s *BearerAuth) SetRoles(val []string) {
s.Roles = val
}
// Single-use console token for one node. The token is a secret of the console gateway: it is never
// logged, stored by the backend, or passed to a browser.
// Ref: #/components/schemas/ConsoleToken
type ConsoleToken struct {
// 32 random bytes in unpadded base64url.
Token string `json:"token"`
Node NodeName `json:"node"`
ExpiresAt time.Time `json:"expires_at"`
// Path of the WebSocket attach on the provisioner origin.
AttachPath string `json:"attach_path"`
}
// GetToken returns the value of Token.
func (s *ConsoleToken) GetToken() string {
return s.Token
}
// GetNode returns the value of Node.
func (s *ConsoleToken) GetNode() NodeName {
return s.Node
}
// GetExpiresAt returns the value of ExpiresAt.
func (s *ConsoleToken) GetExpiresAt() time.Time {
return s.ExpiresAt
}
// GetAttachPath returns the value of AttachPath.
func (s *ConsoleToken) GetAttachPath() string {
return s.AttachPath
}
// SetToken sets the value of Token.
func (s *ConsoleToken) SetToken(val string) {
s.Token = val
}
// SetNode sets the value of Node.
func (s *ConsoleToken) SetNode(val NodeName) {
s.Node = val
}
// SetExpiresAt sets the value of ExpiresAt.
func (s *ConsoleToken) SetExpiresAt(val time.Time) {
s.ExpiresAt = val
}
// SetAttachPath sets the value of AttachPath.
func (s *ConsoleToken) SetAttachPath(val string) {
s.AttachPath = val
}
// ConsoleTokenHeaders wraps ConsoleToken with response headers.
type ConsoleTokenHeaders struct {
CacheControl CreateLabConsoleTokenCreatedCacheControl
Response ConsoleToken
}
// GetCacheControl returns the value of CacheControl.
func (s *ConsoleTokenHeaders) GetCacheControl() CreateLabConsoleTokenCreatedCacheControl {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *ConsoleTokenHeaders) GetResponse() ConsoleToken {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *ConsoleTokenHeaders) SetCacheControl(val CreateLabConsoleTokenCreatedCacheControl) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *ConsoleTokenHeaders) SetResponse(val ConsoleToken) {
s.Response = val
}
// Ref: #/components/schemas/ConsoleTokenRequest
type ConsoleTokenRequest struct {
Node NodeName `json:"node"`
}
// GetNode returns the value of Node.
func (s *ConsoleTokenRequest) GetNode() NodeName {
return s.Node
}
// SetNode sets the value of Node.
func (s *ConsoleTokenRequest) SetNode(val NodeName) {
s.Node = val
}
type CreateLabAccepted LabStatus
func (*CreateLabAccepted) createLabRes() {}
type CreateLabConsoleTokenCreatedCacheControl string
const (
CreateLabConsoleTokenCreatedCacheControlNoStore CreateLabConsoleTokenCreatedCacheControl = "no-store"
)
// AllValues returns all CreateLabConsoleTokenCreatedCacheControl values.
func (CreateLabConsoleTokenCreatedCacheControl) AllValues() []CreateLabConsoleTokenCreatedCacheControl {
return []CreateLabConsoleTokenCreatedCacheControl{
CreateLabConsoleTokenCreatedCacheControlNoStore,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s CreateLabConsoleTokenCreatedCacheControl) MarshalText() ([]byte, error) {
switch s {
case CreateLabConsoleTokenCreatedCacheControlNoStore:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *CreateLabConsoleTokenCreatedCacheControl) UnmarshalText(data []byte) error {
switch CreateLabConsoleTokenCreatedCacheControl(data) {
case CreateLabConsoleTokenCreatedCacheControlNoStore:
*s = CreateLabConsoleTokenCreatedCacheControlNoStore
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type CreateLabOK LabStatus
func (*CreateLabOK) createLabRes() {}
type CriterionId string
// Ref: #/components/schemas/CriterionResult
type CriterionResult struct {
ID CriterionId `json:"id"`
Passed bool `json:"passed"`
}
// GetID returns the value of ID.
func (s *CriterionResult) GetID() CriterionId {
return s.ID
}
// GetPassed returns the value of Passed.
func (s *CriterionResult) GetPassed() bool {
return s.Passed
}
// SetID sets the value of ID.
func (s *CriterionResult) SetID(val CriterionId) {
s.ID = val
}
// SetPassed sets the value of Passed.
func (s *CriterionResult) SetPassed(val bool) {
s.Passed = val
}
type DeleteLabAccepted LabStatus
func (*DeleteLabAccepted) deleteLabRes() {}
type DeleteLabOK LabStatus
func (*DeleteLabOK) deleteLabRes() {}
type GetLabdReadyzOK LabdReadinessResponse
func (*GetLabdReadyzOK) getLabdReadyzRes() {}
type GetLabdReadyzServiceUnavailable LabdReadinessResponse
func (*GetLabdReadyzServiceUnavailable) getLabdReadyzRes() {}
// Result of one check: whether each criterion of the variant holds on the nodes. It carries no node
// output, address, or configuration text.
// Ref: #/components/schemas/LabCheckResult
type LabCheckResult struct {
LabID uuid.UUID `json:"lab_id"`
CheckedAt time.Time `json:"checked_at"`
// Number of passed criteria.
Score int32 `json:"score"`
// Number of criteria.
MaxScore int32 `json:"max_score"`
Criteria []CriterionResult `json:"criteria"`
}
// GetLabID returns the value of LabID.
func (s *LabCheckResult) GetLabID() uuid.UUID {
return s.LabID
}
// GetCheckedAt returns the value of CheckedAt.
func (s *LabCheckResult) GetCheckedAt() time.Time {
return s.CheckedAt
}
// GetScore returns the value of Score.
func (s *LabCheckResult) GetScore() int32 {
return s.Score
}
// GetMaxScore returns the value of MaxScore.
func (s *LabCheckResult) GetMaxScore() int32 {
return s.MaxScore
}
// GetCriteria returns the value of Criteria.
func (s *LabCheckResult) GetCriteria() []CriterionResult {
return s.Criteria
}
// SetLabID sets the value of LabID.
func (s *LabCheckResult) SetLabID(val uuid.UUID) {
s.LabID = val
}
// SetCheckedAt sets the value of CheckedAt.
func (s *LabCheckResult) SetCheckedAt(val time.Time) {
s.CheckedAt = val
}
// SetScore sets the value of Score.
func (s *LabCheckResult) SetScore(val int32) {
s.Score = val
}
// SetMaxScore sets the value of MaxScore.
func (s *LabCheckResult) SetMaxScore(val int32) {
s.MaxScore = val
}
// SetCriteria sets the value of Criteria.
func (s *LabCheckResult) SetCriteria(val []CriterionResult) {
s.Criteria = val
}
// A lab of one template variant. It has no field for a candidate, account, attempt, task, or company.
// Ref: #/components/schemas/LabCreateRequest
type LabCreateRequest struct {
TemplateID TemplateId `json:"template_id"`
// Version of the template. The provisioner refuses a version it does not hold, so a lab always matches
// the variant the backend served.
TemplateVersion int32 `json:"template_version"`
// Variant seed: 32 random bytes in lowercase hex chosen by the backend for the item instance. The
// template renders the variant configuration of every node and the checker criteria from it. It is
// never returned by the provisioner.
Seed string `json:"seed"`
// Lifetime of the lab from its creation. The provisioner refuses a value above its configured maximum.
TTLSeconds int32 `json:"ttl_seconds"`
}
// GetTemplateID returns the value of TemplateID.
func (s *LabCreateRequest) GetTemplateID() TemplateId {
return s.TemplateID
}
// GetTemplateVersion returns the value of TemplateVersion.
func (s *LabCreateRequest) GetTemplateVersion() int32 {
return s.TemplateVersion
}
// GetSeed returns the value of Seed.
func (s *LabCreateRequest) GetSeed() string {
return s.Seed
}
// GetTTLSeconds returns the value of TTLSeconds.
func (s *LabCreateRequest) GetTTLSeconds() int32 {
return s.TTLSeconds
}
// SetTemplateID sets the value of TemplateID.
func (s *LabCreateRequest) SetTemplateID(val TemplateId) {
s.TemplateID = val
}
// SetTemplateVersion sets the value of TemplateVersion.
func (s *LabCreateRequest) SetTemplateVersion(val int32) {
s.TemplateVersion = val
}
// SetSeed sets the value of Seed.
func (s *LabCreateRequest) SetSeed(val string) {
s.Seed = val
}
// SetTTLSeconds sets the value of TTLSeconds.
func (s *LabCreateRequest) SetTTLSeconds(val int32) {
s.TTLSeconds = val
}
// Why a lab failed. None of the reasons depends on the person who uses the lab.
//
// - provisioning_failed: LXD refused or failed an operation of the provisioning.
// - provisioning_timed_out: a node did not answer on its management port within the provisioning
// timeout.
// - interrupted: the provisioner process stopped while the lab was provisioning.
//
// Ref: #/components/schemas/LabFailureReason
type LabFailureReason string
const (
LabFailureReasonProvisioningFailed LabFailureReason = "provisioning_failed"
LabFailureReasonProvisioningTimedOut LabFailureReason = "provisioning_timed_out"
LabFailureReasonInterrupted LabFailureReason = "interrupted"
)
// AllValues returns all LabFailureReason values.
func (LabFailureReason) AllValues() []LabFailureReason {
return []LabFailureReason{
LabFailureReasonProvisioningFailed,
LabFailureReasonProvisioningTimedOut,
LabFailureReasonInterrupted,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabFailureReason) MarshalText() ([]byte, error) {
switch s {
case LabFailureReasonProvisioningFailed:
return []byte(s), nil
case LabFailureReasonProvisioningTimedOut:
return []byte(s), nil
case LabFailureReasonInterrupted:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabFailureReason) UnmarshalText(data []byte) error {
switch LabFailureReason(data) {
case LabFailureReasonProvisioningFailed:
*s = LabFailureReasonProvisioningFailed
return nil
case LabFailureReasonProvisioningTimedOut:
*s = LabFailureReasonProvisioningTimedOut
return nil
case LabFailureReasonInterrupted:
*s = LabFailureReasonInterrupted
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// A node of a lab by its template name and kind. It never carries an address, a MAC address, an
// instance name, or a credential.
// Ref: #/components/schemas/LabNode
type LabNode struct {
Name NodeName `json:"name"`
Kind NodeKind `json:"kind"`
}
// GetName returns the value of Name.
func (s *LabNode) GetName() NodeName {
return s.Name
}
// GetKind returns the value of Kind.
func (s *LabNode) GetKind() NodeKind {
return s.Kind
}
// SetName sets the value of Name.
func (s *LabNode) SetName(val NodeName) {
s.Name = val
}
// SetKind sets the value of Kind.
func (s *LabNode) SetKind(val NodeKind) {
s.Kind = val
}
// LabPoolBusyHeaders wraps Problem with response headers.
type LabPoolBusyHeaders struct {
RetryAfter int32
Response Problem
}
// GetRetryAfter returns the value of RetryAfter.
func (s *LabPoolBusyHeaders) GetRetryAfter() int32 {
return s.RetryAfter
}
// GetResponse returns the value of Response.
func (s *LabPoolBusyHeaders) GetResponse() Problem {
return s.Response
}
// SetRetryAfter sets the value of RetryAfter.
func (s *LabPoolBusyHeaders) SetRetryAfter(val int32) {
s.RetryAfter = val
}
// SetResponse sets the value of Response.
func (s *LabPoolBusyHeaders) SetResponse(val Problem) {
s.Response = val
}
func (*LabPoolBusyHeaders) createLabRes() {}
// State of a lab.
//
// - provisioning: capacity is reserved and the nodes are being cloned, connected, and booted.
// - ready: every node answers on its management port; console tokens and checks are allowed.
// - deleting: the timer ended, DeleteLab was called, or provisioning failed; the instances and
// bridges are being removed.
// - deleted: every instance and bridge of the lab is gone and its capacity is free.
// - failed: provisioning failed or timed out, or the provisioner restarted while provisioning;
// `failure_reason` says which. Its resources are removed as for `deleting` and the capacity returns
// once they are gone; create a new lab with a new ID.
//
// Adding a value is a contract change.
// Ref: #/components/schemas/LabState
type LabState string
const (
LabStateProvisioning LabState = "provisioning"
LabStateReady LabState = "ready"
LabStateDeleting LabState = "deleting"
LabStateDeleted LabState = "deleted"
LabStateFailed LabState = "failed"
)
// AllValues returns all LabState values.
func (LabState) AllValues() []LabState {
return []LabState{
LabStateProvisioning,
LabStateReady,
LabStateDeleting,
LabStateDeleted,
LabStateFailed,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabState) MarshalText() ([]byte, error) {
switch s {
case LabStateProvisioning:
return []byte(s), nil
case LabStateReady:
return []byte(s), nil
case LabStateDeleting:
return []byte(s), nil
case LabStateDeleted:
return []byte(s), nil
case LabStateFailed:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabState) UnmarshalText(data []byte) error {
switch LabState(data) {
case LabStateProvisioning:
*s = LabStateProvisioning
return nil
case LabStateReady:
*s = LabStateReady
return nil
case LabStateDeleting:
*s = LabStateDeleting
return nil
case LabStateDeleted:
*s = LabStateDeleted
return nil
case LabStateFailed:
*s = LabStateFailed
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// State of a lab after one call. It never contains the seed, a node address, a key, a password, or an
// LXD object name.
// Ref: #/components/schemas/LabStatus
type LabStatus struct {
LabID uuid.UUID `json:"lab_id"`
State LabState `json:"state"`
TemplateID TemplateId `json:"template_id"`
TemplateVersion int32 `json:"template_version"`
CreatedAt time.Time `json:"created_at"`
// Time the lab became `ready`; absent before.
ReadyAt OptDateTime `json:"ready_at"`
// Time the provisioner deletes the lab. It never moves, also not across restarts of the provisioner.
ExpiresAt time.Time `json:"expires_at"`
// Time the last resource of the lab was removed; absent before.
DeletedAt OptDateTime `json:"deleted_at"`
FailureReason OptLabFailureReason `json:"failure_reason"`
// Nodes of the template in template order.
Nodes []LabNode `json:"nodes"`
}
// GetLabID returns the value of LabID.
func (s *LabStatus) GetLabID() uuid.UUID {
return s.LabID
}
// GetState returns the value of State.
func (s *LabStatus) GetState() LabState {
return s.State
}
// GetTemplateID returns the value of TemplateID.
func (s *LabStatus) GetTemplateID() TemplateId {
return s.TemplateID
}
// GetTemplateVersion returns the value of TemplateVersion.
func (s *LabStatus) GetTemplateVersion() int32 {
return s.TemplateVersion
}
// GetCreatedAt returns the value of CreatedAt.
func (s *LabStatus) GetCreatedAt() time.Time {
return s.CreatedAt
}
// GetReadyAt returns the value of ReadyAt.
func (s *LabStatus) GetReadyAt() OptDateTime {
return s.ReadyAt
}
// GetExpiresAt returns the value of ExpiresAt.
func (s *LabStatus) GetExpiresAt() time.Time {
return s.ExpiresAt
}
// GetDeletedAt returns the value of DeletedAt.
func (s *LabStatus) GetDeletedAt() OptDateTime {
return s.DeletedAt
}
// GetFailureReason returns the value of FailureReason.
func (s *LabStatus) GetFailureReason() OptLabFailureReason {
return s.FailureReason
}
// GetNodes returns the value of Nodes.
func (s *LabStatus) GetNodes() []LabNode {
return s.Nodes
}
// SetLabID sets the value of LabID.
func (s *LabStatus) SetLabID(val uuid.UUID) {
s.LabID = val
}
// SetState sets the value of State.
func (s *LabStatus) SetState(val LabState) {
s.State = val
}
// SetTemplateID sets the value of TemplateID.
func (s *LabStatus) SetTemplateID(val TemplateId) {
s.TemplateID = val
}
// SetTemplateVersion sets the value of TemplateVersion.
func (s *LabStatus) SetTemplateVersion(val int32) {
s.TemplateVersion = val
}
// SetCreatedAt sets the value of CreatedAt.
func (s *LabStatus) SetCreatedAt(val time.Time) {
s.CreatedAt = val
}
// SetReadyAt sets the value of ReadyAt.
func (s *LabStatus) SetReadyAt(val OptDateTime) {
s.ReadyAt = val
}
// SetExpiresAt sets the value of ExpiresAt.
func (s *LabStatus) SetExpiresAt(val time.Time) {
s.ExpiresAt = val
}
// SetDeletedAt sets the value of DeletedAt.
func (s *LabStatus) SetDeletedAt(val OptDateTime) {
s.DeletedAt = val
}
// SetFailureReason sets the value of FailureReason.
func (s *LabStatus) SetFailureReason(val OptLabFailureReason) {
s.FailureReason = val
}
// SetNodes sets the value of Nodes.
func (s *LabStatus) SetNodes(val []LabNode) {
s.Nodes = val
}
// Ref: #/components/schemas/LabdHealthResponse
type LabdHealthResponse struct {
Status LabdHealthResponseStatus `json:"status"`
}
// GetStatus returns the value of Status.
func (s *LabdHealthResponse) GetStatus() LabdHealthResponseStatus {
return s.Status
}
// SetStatus sets the value of Status.
func (s *LabdHealthResponse) SetStatus(val LabdHealthResponseStatus) {
s.Status = val
}
type LabdHealthResponseStatus string
const (
LabdHealthResponseStatusOk LabdHealthResponseStatus = "ok"
)
// AllValues returns all LabdHealthResponseStatus values.
func (LabdHealthResponseStatus) AllValues() []LabdHealthResponseStatus {
return []LabdHealthResponseStatus{
LabdHealthResponseStatusOk,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabdHealthResponseStatus) MarshalText() ([]byte, error) {
switch s {
case LabdHealthResponseStatusOk:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabdHealthResponseStatus) UnmarshalText(data []byte) error {
switch LabdHealthResponseStatus(data) {
case LabdHealthResponseStatusOk:
*s = LabdHealthResponseStatusOk
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Ref: #/components/schemas/LabdReadinessResponse
type LabdReadinessResponse struct {
Status LabdReadinessResponseStatus `json:"status"`
}
// GetStatus returns the value of Status.
func (s *LabdReadinessResponse) GetStatus() LabdReadinessResponseStatus {
return s.Status
}
// SetStatus sets the value of Status.
func (s *LabdReadinessResponse) SetStatus(val LabdReadinessResponseStatus) {
s.Status = val
}
type LabdReadinessResponseStatus string
const (
LabdReadinessResponseStatusReady LabdReadinessResponseStatus = "ready"
LabdReadinessResponseStatusNotReady LabdReadinessResponseStatus = "not_ready"
)
// AllValues returns all LabdReadinessResponseStatus values.
func (LabdReadinessResponseStatus) AllValues() []LabdReadinessResponseStatus {
return []LabdReadinessResponseStatus{
LabdReadinessResponseStatusReady,
LabdReadinessResponseStatusNotReady,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s LabdReadinessResponseStatus) MarshalText() ([]byte, error) {
switch s {
case LabdReadinessResponseStatusReady:
return []byte(s), nil
case LabdReadinessResponseStatusNotReady:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *LabdReadinessResponseStatus) UnmarshalText(data []byte) error {
switch LabdReadinessResponseStatus(data) {
case LabdReadinessResponseStatusReady:
*s = LabdReadinessResponseStatusReady
return nil
case LabdReadinessResponseStatusNotReady:
*s = LabdReadinessResponseStatusNotReady
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Guest system of a node.
//
// - mikrotik: a MikroTik Cloud Hosted Router VM; its console is RouterOS.
// - ubuntu: a small Ubuntu VM; its console is a Linux login.
//
// Adding a value is a contract change.
// Ref: #/components/schemas/NodeKind
type NodeKind string
const (
NodeKindMikrotik NodeKind = "mikrotik"
NodeKindUbuntu NodeKind = "ubuntu"
)
// AllValues returns all NodeKind values.
func (NodeKind) AllValues() []NodeKind {
return []NodeKind{
NodeKindMikrotik,
NodeKindUbuntu,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s NodeKind) MarshalText() ([]byte, error) {
switch s {
case NodeKindMikrotik:
return []byte(s), nil
case NodeKindUbuntu:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *NodeKind) UnmarshalText(data []byte) error {
switch NodeKind(data) {
case NodeKindMikrotik:
*s = NodeKindMikrotik
return nil
case NodeKindUbuntu:
*s = NodeKindUbuntu
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type NodeName string
// NewOptDateTime returns new OptDateTime with value set to v.
func NewOptDateTime(v time.Time) OptDateTime {
return OptDateTime{
Value: v,
Set: true,
}
}
// OptDateTime is optional time.Time.
type OptDateTime struct {
Value time.Time
Set bool
}
// IsSet returns true if OptDateTime was set.
func (o OptDateTime) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptDateTime) Reset() {
var v time.Time
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptDateTime) SetTo(v time.Time) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptDateTime) Get() (v time.Time, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptDateTime) Or(d time.Time) time.Time {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewOptLabFailureReason returns new OptLabFailureReason with value set to v.
func NewOptLabFailureReason(v LabFailureReason) OptLabFailureReason {
return OptLabFailureReason{
Value: v,
Set: true,
}
}
// OptLabFailureReason is optional LabFailureReason.
type OptLabFailureReason struct {
Value LabFailureReason
Set bool
}
// IsSet returns true if OptLabFailureReason was set.
func (o OptLabFailureReason) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptLabFailureReason) Reset() {
var v LabFailureReason
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptLabFailureReason) SetTo(v LabFailureReason) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptLabFailureReason) Get() (v LabFailureReason, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptLabFailureReason) Or(d LabFailureReason) LabFailureReason {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewOptString returns new OptString with value set to v.
func NewOptString(v string) OptString {
return OptString{
Value: v,
Set: true,
}
}
// OptString is optional string.
type OptString struct {
Value string
Set bool
}
// IsSet returns true if OptString was set.
func (o OptString) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptString) Reset() {
var v string
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptString) SetTo(v string) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptString) Get() (v string, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptString) Or(d string) string {
if v, ok := o.Get(); ok {
return v
}
return d
}
// Problem details (RFC 9457) returned with the application/problem+json media type for every error
// response. This is the lab provisioner copy of the public api/core Problem schema; keep both copies
// identical except for descriptions and the ProblemCode enum. `code` is the stable, machine-readable
// reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body
// never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or
// echoed request values.
// Ref: #/components/schemas/Problem
type Problem struct {
// URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an
// identifier, not a link to dereference.
Type string `json:"type"`
// Short, fixed English summary of the problem type. It does not change between occurrences.
Title string `json:"title"`
// HTTP status code generated by the origin server.
Status int32 `json:"status"`
Code ProblemCode `json:"code"`
// Safe English explanation of this occurrence. It never contains internal error text or request
// values.
Detail OptString `json:"detail"`
// URI reference that identifies this occurrence, when one exists.
Instance OptString `json:"instance"`
// Request identifier of the call when the caller propagated one; it is not a secret.
TraceID OptString `json:"trace_id"`
// Field-level reasons for validation_failed. Other codes omit it.
Errors []ProblemFieldError `json:"errors"`
}
// GetType returns the value of Type.
func (s *Problem) GetType() string {
return s.Type
}
// GetTitle returns the value of Title.
func (s *Problem) GetTitle() string {
return s.Title
}
// GetStatus returns the value of Status.
func (s *Problem) GetStatus() int32 {
return s.Status
}
// GetCode returns the value of Code.
func (s *Problem) GetCode() ProblemCode {
return s.Code
}
// GetDetail returns the value of Detail.
func (s *Problem) GetDetail() OptString {
return s.Detail
}
// GetInstance returns the value of Instance.
func (s *Problem) GetInstance() OptString {
return s.Instance
}
// GetTraceID returns the value of TraceID.
func (s *Problem) GetTraceID() OptString {
return s.TraceID
}
// GetErrors returns the value of Errors.
func (s *Problem) GetErrors() []ProblemFieldError {
return s.Errors
}
// SetType sets the value of Type.
func (s *Problem) SetType(val string) {
s.Type = val
}
// SetTitle sets the value of Title.
func (s *Problem) SetTitle(val string) {
s.Title = val
}
// SetStatus sets the value of Status.
func (s *Problem) SetStatus(val int32) {
s.Status = val
}
// SetCode sets the value of Code.
func (s *Problem) SetCode(val ProblemCode) {
s.Code = val
}
// SetDetail sets the value of Detail.
func (s *Problem) SetDetail(val OptString) {
s.Detail = val
}
// SetInstance sets the value of Instance.
func (s *Problem) SetInstance(val OptString) {
s.Instance = val
}
// SetTraceID sets the value of TraceID.
func (s *Problem) SetTraceID(val OptString) {
s.TraceID = val
}
// SetErrors sets the value of Errors.
func (s *Problem) SetErrors(val []ProblemFieldError) {
s.Errors = val
}
// Stable error code of the lab provisioner API. Adding a code is a contract change; renaming or
// removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
//
// - validation_failed (400): parameters or body do not match the contract or a semantic rule, such as
// an unknown template or node; `errors` points at the fields.
// - unauthenticated (401): the bearer token is missing or wrong.
// - not_found (404): the route or the lab does not exist.
// - method_not_allowed (405): the route does not support the method.
// - state_conflict (409): the lab is not in a state that allows the operation, for example a console
// token or a check for a lab that is not ready.
// - payload_too_large (413): the request body exceeds the limit.
// - unsupported_media_type (415): the request Content-Type is not accepted.
// - idempotency_key_reused (422): the lab ID was already used with a different payload.
// - internal (500): unexpected server error.
// - not_implemented (501): the route is described but not implemented yet, such as the console
// attach.
// - lab_pool_busy (503): the lab does not fit the capacity or the provisioner is draining; see
// Retry-After.
// - lab_unavailable (503): LXD or a node could not be reached, so nothing was done or evaluated. It
// is an infrastructure failure, never a failed check.
//
// The Problem shape is the api/core shape; only this enum is specific to the lab provisioner.
// Ref: #/components/schemas/ProblemCode
type ProblemCode string
const (
ProblemCodeValidationFailed ProblemCode = "validation_failed"
ProblemCodeUnauthenticated ProblemCode = "unauthenticated"
ProblemCodeNotFound ProblemCode = "not_found"
ProblemCodeMethodNotAllowed ProblemCode = "method_not_allowed"
ProblemCodeStateConflict ProblemCode = "state_conflict"
ProblemCodePayloadTooLarge ProblemCode = "payload_too_large"
ProblemCodeUnsupportedMediaType ProblemCode = "unsupported_media_type"
ProblemCodeIdempotencyKeyReused ProblemCode = "idempotency_key_reused"
ProblemCodeInternal ProblemCode = "internal"
ProblemCodeNotImplemented ProblemCode = "not_implemented"
ProblemCodeLabPoolBusy ProblemCode = "lab_pool_busy"
ProblemCodeLabUnavailable ProblemCode = "lab_unavailable"
)
// AllValues returns all ProblemCode values.
func (ProblemCode) AllValues() []ProblemCode {
return []ProblemCode{
ProblemCodeValidationFailed,
ProblemCodeUnauthenticated,
ProblemCodeNotFound,
ProblemCodeMethodNotAllowed,
ProblemCodeStateConflict,
ProblemCodePayloadTooLarge,
ProblemCodeUnsupportedMediaType,
ProblemCodeIdempotencyKeyReused,
ProblemCodeInternal,
ProblemCodeNotImplemented,
ProblemCodeLabPoolBusy,
ProblemCodeLabUnavailable,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ProblemCode) MarshalText() ([]byte, error) {
switch s {
case ProblemCodeValidationFailed:
return []byte(s), nil
case ProblemCodeUnauthenticated:
return []byte(s), nil
case ProblemCodeNotFound:
return []byte(s), nil
case ProblemCodeMethodNotAllowed:
return []byte(s), nil
case ProblemCodeStateConflict:
return []byte(s), nil
case ProblemCodePayloadTooLarge:
return []byte(s), nil
case ProblemCodeUnsupportedMediaType:
return []byte(s), nil
case ProblemCodeIdempotencyKeyReused:
return []byte(s), nil
case ProblemCodeInternal:
return []byte(s), nil
case ProblemCodeNotImplemented:
return []byte(s), nil
case ProblemCodeLabPoolBusy:
return []byte(s), nil
case ProblemCodeLabUnavailable:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ProblemCode) UnmarshalText(data []byte) error {
switch ProblemCode(data) {
case ProblemCodeValidationFailed:
*s = ProblemCodeValidationFailed
return nil
case ProblemCodeUnauthenticated:
*s = ProblemCodeUnauthenticated
return nil
case ProblemCodeNotFound:
*s = ProblemCodeNotFound
return nil
case ProblemCodeMethodNotAllowed:
*s = ProblemCodeMethodNotAllowed
return nil
case ProblemCodeStateConflict:
*s = ProblemCodeStateConflict
return nil
case ProblemCodePayloadTooLarge:
*s = ProblemCodePayloadTooLarge
return nil
case ProblemCodeUnsupportedMediaType:
*s = ProblemCodeUnsupportedMediaType
return nil
case ProblemCodeIdempotencyKeyReused:
*s = ProblemCodeIdempotencyKeyReused
return nil
case ProblemCodeInternal:
*s = ProblemCodeInternal
return nil
case ProblemCodeNotImplemented:
*s = ProblemCodeNotImplemented
return nil
case ProblemCodeLabPoolBusy:
*s = ProblemCodeLabPoolBusy
return nil
case ProblemCodeLabUnavailable:
*s = ProblemCodeLabUnavailable
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// One reason why a request field or parameter is invalid.
// Ref: #/components/schemas/ProblemFieldError
type ProblemFieldError struct {
In ProblemFieldLocation `json:"in"`
// JSON Pointer (RFC 6901). For `body` it points into the request body document, for example
// `/ttl_seconds`; an empty string means the whole body. For a parameter it is `/` followed by the
// parameter name, for example `/lab_id`.
Pointer string `json:"pointer"`
// Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or
// a value outside the schema). Clients must tolerate new values.
Code string `json:"code"`
// Fixed English message that never echoes the submitted value.
Message string `json:"message"`
}
// GetIn returns the value of In.
func (s *ProblemFieldError) GetIn() ProblemFieldLocation {
return s.In
}
// GetPointer returns the value of Pointer.
func (s *ProblemFieldError) GetPointer() string {
return s.Pointer
}
// GetCode returns the value of Code.
func (s *ProblemFieldError) GetCode() string {
return s.Code
}
// GetMessage returns the value of Message.
func (s *ProblemFieldError) GetMessage() string {
return s.Message
}
// SetIn sets the value of In.
func (s *ProblemFieldError) SetIn(val ProblemFieldLocation) {
s.In = val
}
// SetPointer sets the value of Pointer.
func (s *ProblemFieldError) SetPointer(val string) {
s.Pointer = val
}
// SetCode sets the value of Code.
func (s *ProblemFieldError) SetCode(val string) {
s.Code = val
}
// SetMessage sets the value of Message.
func (s *ProblemFieldError) SetMessage(val string) {
s.Message = val
}
// Part of the request that contains the invalid field.
// Ref: #/components/schemas/ProblemFieldLocation
type ProblemFieldLocation string
const (
ProblemFieldLocationBody ProblemFieldLocation = "body"
ProblemFieldLocationQuery ProblemFieldLocation = "query"
ProblemFieldLocationPath ProblemFieldLocation = "path"
ProblemFieldLocationHeader ProblemFieldLocation = "header"
ProblemFieldLocationCookie ProblemFieldLocation = "cookie"
)
// AllValues returns all ProblemFieldLocation values.
func (ProblemFieldLocation) AllValues() []ProblemFieldLocation {
return []ProblemFieldLocation{
ProblemFieldLocationBody,
ProblemFieldLocationQuery,
ProblemFieldLocationPath,
ProblemFieldLocationHeader,
ProblemFieldLocationCookie,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s ProblemFieldLocation) MarshalText() ([]byte, error) {
switch s {
case ProblemFieldLocationBody:
return []byte(s), nil
case ProblemFieldLocationQuery:
return []byte(s), nil
case ProblemFieldLocationPath:
return []byte(s), nil
case ProblemFieldLocationHeader:
return []byte(s), nil
case ProblemFieldLocationCookie:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *ProblemFieldLocation) UnmarshalText(data []byte) error {
switch ProblemFieldLocation(data) {
case ProblemFieldLocationBody:
*s = ProblemFieldLocationBody
return nil
case ProblemFieldLocationQuery:
*s = ProblemFieldLocationQuery
return nil
case ProblemFieldLocationPath:
*s = ProblemFieldLocationPath
return nil
case ProblemFieldLocationHeader:
*s = ProblemFieldLocationHeader
return nil
case ProblemFieldLocationCookie:
*s = ProblemFieldLocationCookie
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// ProblemStatusCode wraps Problem with StatusCode.
type ProblemStatusCode struct {
StatusCode int
Response Problem
}
// GetStatusCode returns the value of StatusCode.
func (s *ProblemStatusCode) GetStatusCode() int {
return s.StatusCode
}
// GetResponse returns the value of Response.
func (s *ProblemStatusCode) GetResponse() Problem {
return s.Response
}
// SetStatusCode sets the value of StatusCode.
func (s *ProblemStatusCode) SetStatusCode(val int) {
s.StatusCode = val
}
// SetResponse sets the value of Response.
func (s *ProblemStatusCode) SetResponse(val Problem) {
s.Response = val
}
type TemplateId string