resources

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NuvlaTimeStampFormat = "2006-01-02T15:04:05.000Z07:00"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonAttributesResource

type CommonAttributesResource struct {
	Id           string    `json:"id"`
	ResourceType string    `json:"resource-type"`
	Created      time.Time `json:"created"`
	Updated      time.Time `json:"updated"`
	// Optional fields
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tags        []string `json:"tags"`
	Parent      string   `json:"parent"`
}

func (*CommonAttributesResource) GetId

func (r *CommonAttributesResource) GetId() string

func (*CommonAttributesResource) GetType

func (r *CommonAttributesResource) GetType() string

type ContainerHostResources

type ContainerHostResources struct {
	Memory int     `json:"memory"`
	Cpus   float32 `json:"cpus"`
}

type ContainerMounts

type ContainerMounts struct {
	MountType string `json:"mount-type"`
	Target    string `json:"target"`
	// Optional fields
	Source        string              `json:"source"`
	ReadOnly      bool                `json:"read-only"`
	VolumeOptions []map[string]string `json:"volume-options"`
}

type ContainerPorts

type ContainerPorts struct {
	TargetPort int `json:"target-port"`
	// Optional fields
	Protocol      string `json:"protocol"`
	PublishedPort int    `json:"published-port"`
}

type ContainerResource

type ContainerResource struct {
}

type DeploymentResource

type DeploymentResource struct {
	CommonAttributesResource
	// Required by Nuvla API server
	Module      *ModuleResource `json:"module"`
	State       DeploymentState `json:"state"`
	ApiEndpoint string          `json:"api-endpoint"`

	// Optional
	ApiCredentials struct {
		ApiKey    string `json:"api-key"`
		ApiSecret string `json:"api-secret"`
	} `json:"api-credentials"`

	Data                      map[string]interface{} `json:"data"`
	RegistriesCredentials     []string               `json:"registries-credentials"`
	Owner                     string                 `json:"owner"`
	InfrastructureService     string                 `json:"infrastructure-service"`
	Nuvlabox                  string                 `json:"nuvlabox"`
	ExecutionMode             string                 `json:"execution-mode"`
	CredentialName            string                 `json:"credential-name"`
	InfrastructureServiceName string                 `json:"infrastructure-service-name"`
	Id                        string                 `json:"id"`
}

type DeploymentState

type DeploymentState string
const (
	StateCreated    DeploymentState = "CREATED"
	StateStarted    DeploymentState = "STARTED"
	StateStarting   DeploymentState = "STARTING"
	StateStopped    DeploymentState = "STOPPED"
	StateStopping   DeploymentState = "STOPPING"
	StatePausing    DeploymentState = "PAUSING"
	StatePaused     DeploymentState = "PAUSED"
	StateSuspending DeploymentState = "SUSPENDING"
	StateSuspended  DeploymentState = "SUSPENDED"
	StateUpdating   DeploymentState = "UPDATING"
	StateUpdated    DeploymentState = "UPDATED"
	StatePending    DeploymentState = "PENDING"
	StateError      DeploymentState = "ERROR"
)

type EnvironmentVariable

type EnvironmentVariable struct {
	Name string `json:"name"`
	// Optional fields
	Description string `json:"description"`
	Required    bool   `json:"required"`
	Value       string `json:"value"`
}

type JobResource

type JobResource struct {
	// Required
	State         JobState `json:"state"`
	Action        string   `json:"action"`
	Progress      int8     `json:"progress"`
	ExecutionMode string   `json:"execution-mode"`

	// Optional
	Version        int8 `json:"version"`
	TargetResource struct {
		Href string `json:"href"`
	} `json:"target-resource"`
	AffectedResources []struct {
		Href string `json:"href"`
	} `json:"affected-resources"`
	ReturnCode         int8   `json:"return-code"`
	StatusMessage      string `json:"status-message"`
	TimeOfStatusChange string `json:"time-of-status-change"` // TODO: Try using timestamps and automatic conversion
	ParentJob          string `json:"parent-job"`
	NestedJobs         string `json:"nested-jobs"`
	Priority           int16  `json:"priority"`
	Started            string `json:"started"` // TODO: Try using timestamps and automatic conversion
	Duration           int16  `json:"duration"`
	Expiry             string `json:"expiry"` // TODO: Try using timestamps and automatic conversion
	Output             string `json:"output"`
	Payload            string `json:"payload"` // JSON-compliant string to be passed to the job, such as execution arguments
}

type JobState

type JobState string
const (
	StateQueued   JobState = "QUEUED"
	StateRUNNING  JobState = "RUNNING"
	StateFailed   JobState = "FAILED"
	StateCanceled JobState = "CANCELED"
	StateSuccess  JobState = "SUCCESS"
)

type ModuleApplicationFile

type ModuleApplicationFile struct {
	FileName    string `json:"file-name"`
	FileContent string `json:"file-content"`
}

type ModuleApplicationResource

type ModuleApplicationResource struct {
	CommonAttributesResource
	DockerCompose string `json:"docker-compose"`
	Author        string `json:"author"`
	// Optional fields
	Commit                string                  `json:"commit"`
	Urls                  [][]string              `json:"urls"`
	OutputParameters      []OutputParameter       `json:"output-parameters"`
	EnvironmentVariables  []EnvironmentVariable   `json:"environment-variables"`
	PrivateRegistries     []string                `json:"private-registries"`
	RegistriesCredentials []string                `json:"registries-credentials"`
	Files                 []ModuleApplicationFile `json:"files"`
	RequiresUserRights    bool                    `json:"requires-user-rights"`
}

type ModuleComponentResource

type ModuleComponentResource struct {
	CommonAttributesResource
	Author        string                 `json:"author"`
	Architectures []string               `json:"architectures"`
	Image         map[string]interface{} `json:"image"` // Server definition of image is a map with constraint keys, might be useful to have a struct here
	// Optional fields
	Commit                 string                `json:"commit"`
	Memory                 int                   `json:"memory"`
	Cpus                   float32               `json:"cpus"`
	RestartPolicy          RestartPolicy         `json:"restart-policy"`
	Ports                  []ContainerPorts      `json:"ports"`
	Mounts                 []ContainerMounts     `json:"mounts"`
	PrivateRegistries      []string              `json:"private-registries"`
	RegistriesCredentials  []string              `json:"registries-credentials"`
	Urls                   [][]string            `json:"urls"`
	EnvironmentalVariables []EnvironmentVariable `json:"environmental-variables"`
	OutputParameters       []OutputParameter     `json:"output-parameters"`
}

type ModuleResource

type ModuleResource struct {
	CommonAttributesResource
	Name          string                     `json:"name"`
	Path          string                     `json:"path"`
	ParentPath    string                     `json:"parent-path"`
	SubType       string                     `json:"subtype"`
	Versions      []map[string]interface{}   `json:"versions"`
	Content       *ModuleApplicationResource `json:"content"`
	Valid         bool                       `json:"valid"`
	Compatibility string                     `json:"compatibility"`
	Href          string                     `json:"href"`
}

type NuvlaEdgeResource

type NuvlaEdgeResource struct {
	CommonAttributesResource

	// Required
	State             NuvlaEdgeState `json:"state"`
	RefreshInterval   int            `json:"refresh-interval"`
	HeartbeatInterval int            `json:"heartbeat-interval"`
	Version           int            `json:"version"`
	Owner             string         `json:"owner"`

	// Optional
	Location              []string `json:"location"`
	VPNServerID           string   `json:"vpn-server-id"`
	SSHKeys               []string `json:"ssh-keys"`
	Capabilities          []string `json:"capabilities"`
	Online                bool     `json:"online"`
	InferredLocation      string   `json:"inferred-location"`
	NuvlaBoxEngineVersion string   `json:"nuvlabox-engine-version"`

	NuvlaBoxStatus             string `json:"nuvlabox-status"`
	InfrastructureServiceGroup string `json:"infrastructure-service-group"`
	CredentialApiKey           string `json:"credential-api-key"`
	HostLevelManagementApiKey  string `json:"host-level-management-api-key"`
}

type NuvlaEdgeState

type NuvlaEdgeState string
const (
	NuvlaEdgeStateNew             NuvlaEdgeState = "NEW"
	NuvlaEdgeStateActivated       NuvlaEdgeState = "ACTIVATED"
	NuvlaEdgeStateCommissioned    NuvlaEdgeState = "COMMISSIONED"
	NuvlaEdgeStateDecommissioning NuvlaEdgeState = "DECOMMISSIONING"
	NuvlaEdgeStateDecommissioned  NuvlaEdgeState = "DECOMMISSIONED"
	NuvlaEdgeStateError           NuvlaEdgeState = "ERROR"
	NuvlaEdgeStateSuspended       NuvlaEdgeState = "SUSPENDED"
)

type NuvlaResource

type NuvlaResource interface {
	GetId() string
	GetType() string
}

type NuvlaResourceCollection

type NuvlaResourceCollection struct {
	Resources    []map[string]interface{} `json:"resources"`
	Count        int                      `json:"count"`
	ResourceName string                   `json:"id"`
}

func NewCollectionFromResponse

func NewCollectionFromResponse(response *http.Response) (*NuvlaResourceCollection, error)

NewCollectionFromResponse creates a NuvlaResourceCollection from a http.Response. It expects the body of the response to be a CimiCollection where key "resources" contains the list of resources.

type NuvlaResourceType

type NuvlaResourceType string
const (
	DeploymentType NuvlaResourceType = "deployment"
	UserType       NuvlaResourceType = "user"
	NuvlaEdgeType  NuvlaResourceType = "nuvlaedge"
	NuvlaBoxType   NuvlaResourceType = "nuvlabox"
	JobType        NuvlaResourceType = "job"
)

func GetResourceFromString

func GetResourceFromString(resource string) NuvlaResourceType

type OutputParameter

type OutputParameter struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

type RestartPolicy

type RestartPolicy struct {
	Condition string `json:"condition"`
	// Optional fields
	Delay       int `json:"delay"`
	MaxAttempts int `json:"max-attempts"`
	Window      int `json:"window"`
}

Jump to

Keyboard shortcuts

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