api

package
v1.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2015 License: MIT Imports: 23 Imported by: 0

README

Scaleway's API

This package contains facilities to play with the Scaleway API, it includes the following features:

  • dedicated configuration file containing credentials to deal with the API
  • caching to resolve UUIDs without contacting the API

Documentation

Overview

Package api contains client and functions to interact with Scaleway API

Index

Constants

View Source
const (
	// IdentifierUnknown is used when we don't know explicitely the type key of the object (used for nil comparison)
	IdentifierUnknown = 1 << iota
	// IdentifierServer is the type key of cached server objects
	IdentifierServer
	// IdentifierImage is the type key of cached image objects
	IdentifierImage
	// IdentifierSnapshot is the type key of cached snapshot objects
	IdentifierSnapshot
	// IdentifierBootscript is the type key of cached bootscript objects
	IdentifierBootscript
	// IdentifierVolume is the type key of cached volume objects
	IdentifierVolume
)

Variables

View Source
var FuncMap = template.FuncMap{
	"json": func(v interface{}) string {
		a, _ := json.Marshal(v)
		return string(a)
	},
}

FuncMap used for json inspection

Functions

func CreateServer

func CreateServer(api *ScalewayAPI, imageName string, name string, bootscript string, env string, additionalVolumes string, dynamicIPRequired bool) (string, error)

CreateServer creates a server using API based on typical server fields

func CreateVolumeFromHumanSize

func CreateVolumeFromHumanSize(api *ScalewayAPI, size string) (*string, error)

CreateVolumeFromHumanSize creates a volume on the API with a human readable size

func InspectIdentifiers

func InspectIdentifiers(api *ScalewayAPI, ci chan ScalewayResolvedIdentifier, cj chan InspectIdentifierResult)

InspectIdentifiers inspects identifiers concurrently

func ResolveGateway

func ResolveGateway(api *ScalewayAPI, gateway string) (string, error)

ResolveGateway tries to resolve a server public ip address, else returns the input string, i.e. IPv4, hostname

func ResolveIdentifiers

func ResolveIdentifiers(api *ScalewayAPI, needles []string, out chan ScalewayResolvedIdentifier)

ResolveIdentifiers resolves needles provided by the user

func StartServer

func StartServer(api *ScalewayAPI, needle string, wait bool) error

StartServer start a server based on its needle, can optionaly block while server is booting

func StartServerOnce

func StartServerOnce(api *ScalewayAPI, needle string, wait bool, successChan chan bool, errChan chan error)

StartServerOnce wraps StartServer for golang channel

Types

type ByCreationDate

type ByCreationDate []ScalewayImageInterface

ByCreationDate sorts images by CreationDate field

func (ByCreationDate) Len

func (a ByCreationDate) Len() int

func (ByCreationDate) Less

func (a ByCreationDate) Less(i, j int) bool

func (ByCreationDate) Swap

func (a ByCreationDate) Swap(i, j int)

type Config

type Config struct {
	// ComputeAPI is the endpoint to the Scaleway API
	ComputeAPI string `json:"api_endpoint"`

	// AccountAPI is the endpoint to the Scaleway Account API
	AccountAPI string `json:"account_endpoint"`

	// Organization is the identifier of the Scaleway orgnization
	Organization string `json:"organization"`

	// Token is the authentication token for the Scaleway organization
	Token string `json:"token"`
}

Config is a Scaleway CLI configuration file

func (*Config) Save

func (c *Config) Save() error

Save write the config file

type InspectIdentifierResult

type InspectIdentifierResult struct {
	Type   int
	Object interface{}
}

InspectIdentifierResult is returned by `InspectIdentifiers` and contains the inspected `Object` with its `Type`

type ScalewayAPI

type ScalewayAPI struct {
	// ComputeAPI is the endpoint to the Scaleway API
	ComputeAPI string

	// AccountAPI is the endpoint to the Scaleway Account API
	AccountAPI string

	// APIEndPoint or ACCOUNTEndPoint
	APIUrl string

	// Organization is the identifier of the Scaleway organization
	Organization string

	// Token is the authentication token for the Scaleway organization
	Token string

	// Cache is used to quickly resolve identifiers from names
	Cache *ScalewayCache
	// contains filtered or unexported fields
}

ScalewayAPI is the interface used to communicate with the Scaleway API

func NewScalewayAPI

func NewScalewayAPI(apiEndPoint, accountEndPoint, organization, token string) (*ScalewayAPI, error)

NewScalewayAPI creates a ready-to-use ScalewayAPI client

func (*ScalewayAPI) CheckCredentials

func (s *ScalewayAPI) CheckCredentials() error

CheckCredentials performs a dummy check to ensure we can contact the API

func (*ScalewayAPI) DeleteImage

func (s *ScalewayAPI) DeleteImage(imageID string) error

DeleteImage deletes a image

func (*ScalewayAPI) DeleteResponse

func (s *ScalewayAPI) DeleteResponse(resource string) (*http.Response, error)

DeleteResponse returns an http.Response object for the deleted resource

func (*ScalewayAPI) DeleteServer

func (s *ScalewayAPI) DeleteServer(serverID string) error

DeleteServer deletes a server

func (*ScalewayAPI) DeleteServerSafe

func (a *ScalewayAPI) DeleteServerSafe(serverID string) error

DeleteServerSafe tries to delete a server using multiple ways

func (*ScalewayAPI) GetBootscript

func (s *ScalewayAPI) GetBootscript(bootscriptID string) (*ScalewayBootscript, error)

GetBootscript gets a bootscript from the ScalewayAPI

func (*ScalewayAPI) GetBootscriptID

func (s *ScalewayAPI) GetBootscriptID(needle string) string

GetBootscriptID returns exactly one bootscript matching or dies

func (*ScalewayAPI) GetBootscripts

func (s *ScalewayAPI) GetBootscripts() (*[]ScalewayBootscript, error)

GetBootscripts gets the list of bootscripts from the ScalewayAPI

func (*ScalewayAPI) GetImage

func (s *ScalewayAPI) GetImage(imageID string) (*ScalewayImage, error)

GetImage gets an image from the ScalewayAPI

func (*ScalewayAPI) GetImageID

func (s *ScalewayAPI) GetImageID(needle string, exitIfMissing bool) string

GetImageID returns exactly one image matching or dies

func (*ScalewayAPI) GetImages

func (s *ScalewayAPI) GetImages() (*[]ScalewayImage, error)

GetImages gets the list of images from the ScalewayAPI

func (*ScalewayAPI) GetResponse

func (s *ScalewayAPI) GetResponse(resource string) (*http.Response, error)

GetResponse returns an http.Response object for the requested resource

func (*ScalewayAPI) GetServer

func (s *ScalewayAPI) GetServer(serverID string) (*ScalewayServer, error)

GetServer gets a server from the ScalewayAPI

func (*ScalewayAPI) GetServerID

func (s *ScalewayAPI) GetServerID(needle string) string

GetServerID returns exactly one server matching or dies

func (*ScalewayAPI) GetServers

func (s *ScalewayAPI) GetServers(all bool, limit int) (*[]ScalewayServer, error)

GetServers gets the list of servers from the ScalewayAPI

func (*ScalewayAPI) GetSnapshot

func (s *ScalewayAPI) GetSnapshot(snapshotID string) (*ScalewaySnapshot, error)

GetSnapshot gets a snapshot from the ScalewayAPI

func (*ScalewayAPI) GetSnapshotID

func (s *ScalewayAPI) GetSnapshotID(needle string) string

GetSnapshotID returns exactly one snapshot matching or dies

func (*ScalewayAPI) GetSnapshots

func (s *ScalewayAPI) GetSnapshots() (*[]ScalewaySnapshot, error)

GetSnapshots gets the list of snapshots from the ScalewayAPI

func (*ScalewayAPI) GetTasks

func (s *ScalewayAPI) GetTasks() (*[]ScalewayTask, error)

GetTasks get the list of tasks from the ScalewayAPI

func (*ScalewayAPI) GetUserID

func (s *ScalewayAPI) GetUserID() (string, error)

GetUserID returns the UserID

func (*ScalewayAPI) GetVolume

func (s *ScalewayAPI) GetVolume(volumeID string) (*ScalewayVolume, error)

GetVolume gets a volume from the ScalewayAPI

func (*ScalewayAPI) GetVolumes

func (s *ScalewayAPI) GetVolumes() (*[]ScalewayVolume, error)

GetVolumes gets the list of volumes from the ScalewayAPI

func (*ScalewayAPI) HideAPICredentials

func (s *ScalewayAPI) HideAPICredentials(input string) string

HideAPICredentials removes API credentials from a string

func (*ScalewayAPI) PatchResponse

func (s *ScalewayAPI) PatchResponse(resource string, data interface{}) (*http.Response, error)

PatchResponse returns an http.Response object for the updated resource

func (*ScalewayAPI) PatchServer

func (s *ScalewayAPI) PatchServer(serverID string, definition ScalewayServerPatchDefinition) error

PatchServer updates a server

func (*ScalewayAPI) PatchUser

func (s *ScalewayAPI) PatchUser(UserID string, definition ScalewayUserPatchDefinition) error

PatchUser updates a user

func (*ScalewayAPI) PostImage

func (s *ScalewayAPI) PostImage(volumeID string, name string) (string, error)

PostImage creates a new image

func (*ScalewayAPI) PostResponse

func (s *ScalewayAPI) PostResponse(resource string, data interface{}) (*http.Response, error)

PostResponse returns an http.Response object for the updated resource

func (*ScalewayAPI) PostServer

func (s *ScalewayAPI) PostServer(definition ScalewayServerDefinition) (string, error)

PostServer creates a new server

func (*ScalewayAPI) PostServerAction

func (s *ScalewayAPI) PostServerAction(serverID, action string) error

PostServerAction posts an action on a server

func (*ScalewayAPI) PostSnapshot

func (s *ScalewayAPI) PostSnapshot(volumeID string, name string) (string, error)

PostSnapshot creates a new snapshot

func (*ScalewayAPI) PostVolume

func (s *ScalewayAPI) PostVolume(definition ScalewayVolumeDefinition) (string, error)

PostVolume creates a new volume

func (*ScalewayAPI) PutResponse

func (s *ScalewayAPI) PutResponse(resource string, data interface{}) (*http.Response, error)

PutResponse returns an http.Response object for the updated resource

func (*ScalewayAPI) PutVolume

func (s *ScalewayAPI) PutVolume(volumeID string, definition ScalewayVolumePutDefinition) error

PutVolume updates a volume

func (*ScalewayAPI) ResolveBootscript

func (s *ScalewayAPI) ResolveBootscript(needle string) (ScalewayResolverResults, error)

ResolveBootscript attempts the find a matching Identifier for the input string

func (*ScalewayAPI) ResolveImage

func (s *ScalewayAPI) ResolveImage(needle string) (ScalewayResolverResults, error)

ResolveImage attempts the find a matching Identifier for the input string

func (*ScalewayAPI) ResolveServer

func (s *ScalewayAPI) ResolveServer(needle string) (ScalewayResolverResults, error)

ResolveServer attempts the find a matching Identifier for the input string

func (*ScalewayAPI) ResolveSnapshot

func (s *ScalewayAPI) ResolveSnapshot(needle string) (ScalewayResolverResults, error)

ResolveSnapshot attempts the find a matching Identifier for the input string

func (*ScalewayAPI) Sync

func (s *ScalewayAPI) Sync()

Sync flushes out the cache to the disk

type ScalewayAPIError

type ScalewayAPIError struct {
	// Message is a human-friendly error message
	APIMessage string `json:"message,omitempty"`

	// Type is a string code that defines the kind of error
	Type string `json:"type,omitempty"`

	// Fields contains detail about validation error
	Fields map[string][]string `json:"fields,omitempty"`

	// StatusCode is the HTTP status code received
	StatusCode int `json:"-"`

	// Message
	Message string `json:"-"`
}

ScalewayAPIError represents a Scaleway API Error

func (ScalewayAPIError) Debug

func (e ScalewayAPIError) Debug()

Debug create a debug log entry with HTTP error informations

func (ScalewayAPIError) Error

func (e ScalewayAPIError) Error() string

Error returns a string representing the error

type ScalewayBootCmdArgs

type ScalewayBootCmdArgs struct {
	// Identifier is the unique identifier of boot args
	Identifier string `json:"id,omitempty"`

	// Value is the content of the cmd args
	Value string `json:"value,omitempty"`
}

ScalewayBootCmdArgs represents the boot arguments of a bootscript

type ScalewayBootscript

type ScalewayBootscript struct {
	// Identifier is a unique identifier for the bootscript
	Identifier string `json:"id,omitempty"`

	// Name is a user-defined name for the bootscript
	Title string `json:"title,omitempty"`

	// BootCmdArgs represents the arguments used to boot
	BootCmdArgs ScalewayBootCmdArgs `json:"bootcmdargs,omitempty"`

	// Initrd is the initrd used by this bootscript
	Initrd ScalewayInitrd `json:"initrd,omitempty"`

	// Kernel is the kernel associated to this server
	Kernel ScalewayKernel `json:"kernel,omitempty"`

	// Public is true for public bootscripts and false for user bootscripts
	Public bool `json:"public,omitempty"`
}

ScalewayBootscript represents a Scaleway Bootscript

type ScalewayBootscripts

type ScalewayBootscripts struct {
	// Bootscripts holds Scaleway bootscripts of the response
	Bootscripts []ScalewayBootscript `json:"bootscripts,omitempty"`
}

ScalewayBootscripts represents a group of Scaleway bootscripts

type ScalewayCache

type ScalewayCache struct {
	// Images contains names of Scaleway images indexed by identifier
	Images map[string]string `json:"images"`

	// Snapshots contains names of Scaleway snapshots indexed by identifier
	Snapshots map[string]string `json:"snapshots"`

	// Volumes contains names of Scaleway volumes indexed by identifier
	Volumes map[string]string `json:"volumes"`

	// Bootscripts contains names of Scaleway bootscripts indexed by identifier
	Bootscripts map[string]string `json:"bootscripts"`

	// Servers contains names of Scaleway C1 servers indexed by identifier
	Servers map[string]string `json:"servers"`

	// Path is the path to the cache file
	Path string `json:"-"`

	// Modified tells if the cache needs to be overwritten or not
	Modified bool `json:"-"`

	// Lock allows ScalewayCache to be used concurrently
	Lock sync.Mutex `json:"-"`
}

ScalewayCache is used not to query the API to resolve full identifiers

func NewScalewayCache

func NewScalewayCache() (*ScalewayCache, error)

NewScalewayCache loads a per-user cache

func (*ScalewayCache) ClearBootscripts

func (c *ScalewayCache) ClearBootscripts()

ClearBootscripts removes all bootscripts from the cache

func (*ScalewayCache) ClearImages

func (c *ScalewayCache) ClearImages()

ClearImages removes all images from the cache

func (*ScalewayCache) ClearServers

func (c *ScalewayCache) ClearServers()

ClearServers removes all servers from the cache

func (*ScalewayCache) ClearSnapshots

func (c *ScalewayCache) ClearSnapshots()

ClearSnapshots removes all snapshots from the cache

func (*ScalewayCache) ClearVolumes

func (c *ScalewayCache) ClearVolumes()

ClearVolumes removes all volumes from the cache

func (*ScalewayCache) Flush

func (c *ScalewayCache) Flush() error

Flush flushes the cache database

func (*ScalewayCache) GetNbBootscripts

func (c *ScalewayCache) GetNbBootscripts() int

GetNbBootscripts returns the number of bootscripts in the cache

func (*ScalewayCache) GetNbImages

func (c *ScalewayCache) GetNbImages() int

GetNbImages returns the number of images in the cache

func (*ScalewayCache) GetNbServers

func (c *ScalewayCache) GetNbServers() int

GetNbServers returns the number of servers in the cache

func (*ScalewayCache) GetNbSnapshots

func (c *ScalewayCache) GetNbSnapshots() int

GetNbSnapshots returns the number of snapshots in the cache

func (*ScalewayCache) GetNbVolumes

func (c *ScalewayCache) GetNbVolumes() int

GetNbVolumes returns the number of volumes in the cache

func (*ScalewayCache) InsertBootscript

func (c *ScalewayCache) InsertBootscript(identifier, name string)

InsertBootscript registers an bootscript in the cache

func (*ScalewayCache) InsertImage

func (c *ScalewayCache) InsertImage(identifier, name string)

InsertImage registers an image in the cache

func (*ScalewayCache) InsertServer

func (c *ScalewayCache) InsertServer(identifier, name string)

InsertServer registers a server in the cache

func (*ScalewayCache) InsertSnapshot

func (c *ScalewayCache) InsertSnapshot(identifier, name string)

InsertSnapshot registers an snapshot in the cache

func (*ScalewayCache) InsertVolume

func (c *ScalewayCache) InsertVolume(identifier, name string)

InsertVolume registers an volume in the cache

func (*ScalewayCache) LookUpBootscripts

func (c *ScalewayCache) LookUpBootscripts(needle string, acceptUUID bool) ScalewayResolverResults

LookUpBootscripts attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpIdentifiers

func (c *ScalewayCache) LookUpIdentifiers(needle string) ScalewayResolverResults

LookUpIdentifiers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpImages

func (c *ScalewayCache) LookUpImages(needle string, acceptUUID bool) ScalewayResolverResults

LookUpImages attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpServers

func (c *ScalewayCache) LookUpServers(needle string, acceptUUID bool) ScalewayResolverResults

LookUpServers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpSnapshots

func (c *ScalewayCache) LookUpSnapshots(needle string, acceptUUID bool) ScalewayResolverResults

LookUpSnapshots attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpVolumes

func (c *ScalewayCache) LookUpVolumes(needle string, acceptUUID bool) ScalewayResolverResults

LookUpVolumes attempts to return identifiers matching a pattern

func (*ScalewayCache) RemoveBootscript

func (c *ScalewayCache) RemoveBootscript(identifier string)

RemoveBootscript removes a bootscript from the cache

func (*ScalewayCache) RemoveImage

func (c *ScalewayCache) RemoveImage(identifier string)

RemoveImage removes a server from the cache

func (*ScalewayCache) RemoveServer

func (c *ScalewayCache) RemoveServer(identifier string)

RemoveServer removes a server from the cache

func (*ScalewayCache) RemoveSnapshot

func (c *ScalewayCache) RemoveSnapshot(identifier string)

RemoveSnapshot removes a server from the cache

func (*ScalewayCache) RemoveVolume

func (c *ScalewayCache) RemoveVolume(identifier string)

RemoveVolume removes a server from the cache

func (*ScalewayCache) Save

func (c *ScalewayCache) Save() error

Save atomically overwrites the current cache database

type ScalewayIPAddress

type ScalewayIPAddress struct {
	// Identifier is a unique identifier for the IP address
	Identifier string `json:"id,omitempty"`

	// IP is an IPv4 address
	IP string `json:"address,omitempty"`

	// Dynamic is a flag that defines an IP that change on each reboot
	Dynamic *bool `json:"dynamic,omitempty"`
}

ScalewayIPAddress represents a Scaleway IP address

type ScalewayImage

type ScalewayImage struct {
	// Identifier is a unique identifier for the image
	Identifier string `json:"id,omitempty"`

	// Name is a user-defined name for the image
	Name string `json:"name,omitempty"`

	// CreationDate is the creation date of the image
	CreationDate string `json:"creation_date,omitempty"`

	// ModificationDate is the date of the last modification of the image
	ModificationDate string `json:"modification_date,omitempty"`

	// RootVolume is the root volume bound to the image
	RootVolume ScalewayVolume `json:"root_volume,omitempty"`

	// Public is true for public images and false for user images
	Public bool `json:"public,omitempty"`

	// Bootscript is the bootscript bound to the image
	DefaultBootscript *ScalewayBootscript `json:"default_bootscript,omitempty"`

	// Organization is the owner of the image
	Organization string `json:"organization,omitempty"`

	// Arch is the architecture target of the image
	Arch string `json:"arch,omitempty"`
}

ScalewayImage represents a Scaleway Image

type ScalewayImageDefinition

type ScalewayImageDefinition struct {
	SnapshotIDentifier string `json:"root_volume"`
	Name               string `json:"name,omitempty"`
	Organization       string `json:"organization"`
	Arch               string `json:"arch"`
}

ScalewayImageDefinition represents a Scaleway image definition

type ScalewayImageInterface

type ScalewayImageInterface struct {
	CreationDate time.Time
	Identifier   string
	Name         string
	Tag          string
	VirtualSize  float64
	Public       bool
	Type         string
}

ScalewayImageInterface is an interface to multiple Scaleway items

type ScalewayImages

type ScalewayImages struct {
	// Images holds scaleway images of the response
	Images []ScalewayImage `json:"images,omitempty"`
}

ScalewayImages represents a group of Scaleway images

type ScalewayInitrd

type ScalewayInitrd struct {
	// Identifier is the unique identifier of the initrd
	Identifier string `json:"id,omitempty"`

	// Path is the path to the initrd used
	Path string `json:"path,omitempty"`

	// Title is the title of the initrd used
	Title string `json:"title,omitempty"`
}

ScalewayInitrd represents the initrd used by a bootscript

type ScalewayKernel

type ScalewayKernel struct {
	// Identifier is the unique identifier of the kernel
	Identifier string `json:"id,omitempty"`

	// DTB is the kernel DTB used by this kernel
	DTB string `json:"dtb"`

	// Path is the path to the kernel image
	Path string `json:"path,omitempty"`

	// Title is the title of the kernel
	Title string `json:"title,omitempty"`
}

ScalewayKernel represents a kernel used on C1 servers

type ScalewayOneBootscript

type ScalewayOneBootscript struct {
	Bootscript ScalewayBootscript `json:"bootscript,omitempty"`
}

ScalewayOneBootscript represents the response of a GET /bootscripts/UUID API call

type ScalewayOneImage

type ScalewayOneImage struct {
	Image ScalewayImage `json:"image,omitempty"`
}

ScalewayOneImage represents the response of a GET /images/UUID API call

type ScalewayOneServer

type ScalewayOneServer struct {
	Server ScalewayServer `json:"server,omitempty"`
}

ScalewayOneServer represents the response of a GET /servers/UUID API call

type ScalewayOneSnapshot

type ScalewayOneSnapshot struct {
	Snapshot ScalewaySnapshot `json:"snapshot,omitempty"`
}

ScalewayOneSnapshot represents the response of a GET /snapshots/UUID API call

type ScalewayOneTask

type ScalewayOneTask struct {
	Task ScalewayTask `json:"task,omitempty"`
}

ScalewayOneTask represents the response of a GET /tasks/UUID API call

type ScalewayOneVolume

type ScalewayOneVolume struct {
	Volume ScalewayVolume `json:"volume,omitempty"`
}

ScalewayOneVolume represents the response of a GET /volumes/UUID API call

type ScalewayResolvedIdentifier

type ScalewayResolvedIdentifier struct {
	// Identifiers holds matching identifiers
	Identifiers ScalewayResolverResults

	// Needle is the criteria used to lookup identifiers
	Needle string
}

ScalewayResolvedIdentifier represents a list of matching identifier for a specifier pattern

type ScalewayResolverResult

type ScalewayResolverResult struct {
	Identifier string
	Type       int
	Name       string
	Needle     string
	RankMatch  int
}

ScalewayResolverResult is a structure containing human-readable information about resolver results. This structure is used to display the user choices.

func GetIdentifier

func GetIdentifier(api *ScalewayAPI, needle string) *ScalewayResolverResult

GetIdentifier returns a an identifier if the resolved needles only match one element, else, it exists the program

func (*ScalewayResolverResult) CodeName

func (s *ScalewayResolverResult) CodeName() string

CodeName returns a full resource name with typed prefix

func (*ScalewayResolverResult) ComputeRankMatch

func (s *ScalewayResolverResult) ComputeRankMatch(needle string)

ComputeRankMatch fills `ScalewayResolverResult.RankMatch` with its `fuzzy` score

func (*ScalewayResolverResult) TruncIdentifier

func (s *ScalewayResolverResult) TruncIdentifier() string

TruncIdentifier returns first 8 characters of an Identifier (UUID)

type ScalewayResolverResults

type ScalewayResolverResults []ScalewayResolverResult

ScalewayResolverResults is a list of `ScalewayResolverResult`

func ResolveIdentifier

func ResolveIdentifier(api *ScalewayAPI, needle string) ScalewayResolverResults

ResolveIdentifier resolves needle provided by the user

func (ScalewayResolverResults) Len

func (s ScalewayResolverResults) Len() int

func (ScalewayResolverResults) Less

func (s ScalewayResolverResults) Less(i, j int) bool

func (ScalewayResolverResults) Swap

func (s ScalewayResolverResults) Swap(i, j int)

type ScalewaySecurityGroup

type ScalewaySecurityGroup struct {
	// Identifier is a unique identifier for the security group
	Identifier string `json:"id,omitempty"`

	// Name is the user-defined name of the security group
	Name string `json:"name,omitempty"`
}

ScalewaySecurityGroup represents a Scaleway security group

type ScalewayServer

type ScalewayServer struct {
	// Identifier is a unique identifier for the server
	Identifier string `json:"id,omitempty"`

	// Name is the user-defined name of the server
	Name string `json:"name,omitempty"`

	// CreationDate is the creation date of the server
	CreationDate string `json:"creation_date,omitempty"`

	// ModificationDate is the date of the last modification of the server
	ModificationDate string `json:"modification_date,omitempty"`

	// Image is the image used by the server
	Image ScalewayImage `json:"image,omitempty"`

	// DynamicIPRequired is a flag that defines a server with a dynamic ip address attached
	DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"`

	// PublicIP is the public IP address bound to the server
	PublicAddress ScalewayIPAddress `json:"public_ip,omitempty"`

	// State is the current status of the server
	State string `json:"state,omitempty"`

	// StateDetail is the detailed status of the server
	StateDetail string `json:"state_detail,omitempty"`

	// PrivateIP represents the private IPV4 attached to the server (changes on each boot)
	PrivateIP string `json:"private_ip,omitempty"`

	// Bootscript is the unique identifier of the selected bootscript
	Bootscript *ScalewayBootscript `json:"bootscript,omitempty"`

	// Hostname represents the ServerName in a format compatible with unix's hostname
	Hostname string `json:"hostname,omitempty"`

	// Tags represents user-defined tags
	Tags []string `json:"tags,omitempty"`

	// Volumes are the attached volumes
	Volumes map[string]ScalewayVolume `json:"volumes,omitempty"`

	// SecurityGroup is the selected security group object
	SecurityGroup ScalewaySecurityGroup `json:"security_group,omitempty"`

	// Organization is the owner of the server
	Organization string `json:"organization,omitempty"`
}

ScalewayServer represents a Scaleway C1 server

func WaitForServerReady

func WaitForServerReady(api *ScalewayAPI, serverID string, gateway string) (*ScalewayServer, error)

WaitForServerReady wait for a server state to be running, then wait for the SSH port to be available

func WaitForServerState

func WaitForServerState(api *ScalewayAPI, serverID string, targetState string) (*ScalewayServer, error)

WaitForServerState asks API in a loop until a server matches a wanted state

func WaitForServerStopped

func WaitForServerStopped(api *ScalewayAPI, serverID string) (*ScalewayServer, error)

WaitForServerStopped wait for a server state to be stopped

type ScalewayServerAction

type ScalewayServerAction struct {
	// Action is the name of the action to trigger
	Action string `json:"action,omitempty"`
}

ScalewayServerAction represents an action to perform on a Scaleway C1 server

type ScalewayServerDefinition

type ScalewayServerDefinition struct {
	// Name is the user-defined name of the server
	Name string `json:"name"`

	// Image is the image used by the server
	Image *string `json:"image,omitempty"`

	// Volumes are the attached volumes
	Volumes map[string]string `json:"volumes,omitempty"`

	// DynamicIPRequired is a flag that defines a server with a dynamic ip address attached
	DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"`

	// Bootscript is the bootscript used by the server
	Bootscript *string `json:"bootscript"`

	// Tags are the metadata tags attached to the server
	Tags []string `json:"tags,omitempty"`

	// Organization is the owner of the server
	Organization string `json:"organization"`
}

ScalewayServerDefinition represents a Scaleway C1 server with image definition

type ScalewayServerPatchDefinition

type ScalewayServerPatchDefinition struct {
	Name              *string                    `json:"name,omitempty"`
	CreationDate      *string                    `json:"creation_date,omitempty"`
	ModificationDate  *string                    `json:"modification_date,omitempty"`
	Image             *ScalewayImage             `json:"image,omitempty"`
	DynamicIPRequired *bool                      `json:"dynamic_ip_required,omitempty"`
	PublicAddress     *ScalewayIPAddress         `json:"public_ip,omitempty"`
	State             *string                    `json:"state,omitempty"`
	StateDetail       *string                    `json:"state_detail,omitempty"`
	PrivateIP         *string                    `json:"private_ip,omitempty"`
	Bootscript        *ScalewayBootscript        `json:"bootscript,omitempty"`
	Hostname          *string                    `json:"hostname,omitempty"`
	Volumes           *map[string]ScalewayVolume `json:"volumes,omitempty"`
	SecurityGroup     *ScalewaySecurityGroup     `json:"security_group,omitempty"`
	Organization      *string                    `json:"organization,omitempty"`
}

ScalewayServerPatchDefinition represents a Scaleway C1 server with nullable fields (for PATCH)

type ScalewayServers

type ScalewayServers struct {
	// Servers holds scaleway servers of the response
	Servers []ScalewayServer `json:"servers,omitempty"`
}

ScalewayServers represents a group of Scaleway C1 servers

type ScalewaySnapshot

type ScalewaySnapshot struct {
	// Identifier is a unique identifier for the snapshot
	Identifier string `json:"id,omitempty"`

	// Name is a user-defined name for the snapshot
	Name string `json:"name,omitempty"`

	// CreationDate is the creation date of the snapshot
	CreationDate string `json:"creation_date,omitempty"`

	// ModificationDate is the date of the last modification of the snapshot
	ModificationDate string `json:"modification_date,omitempty"`

	// Size is the allocated size of the volume
	Size uint64 `json:"size,omitempty"`

	// Organization is the owner of the snapshot
	Organization string `json:"organization"`

	// State is the current state of the snapshot
	State string `json:"state"`

	// VolumeType is the kind of volume behind the snapshot
	VolumeType string `json:"volume_type"`

	// BaseVolume is the volume from which the snapshot inherits
	BaseVolume ScalewayVolume `json:"base_volume,omitempty"`
}

ScalewaySnapshot represents a Scaleway Snapshot

type ScalewaySnapshotDefinition

type ScalewaySnapshotDefinition struct {
	VolumeIDentifier string `json:"volume_id"`
	Name             string `json:"name,omitempty"`
	Organization     string `json:"organization"`
}

ScalewaySnapshotDefinition represents a Scaleway snapshot definition

type ScalewaySnapshots

type ScalewaySnapshots struct {
	// Snapshots holds scaleway snapshots of the response
	Snapshots []ScalewaySnapshot `json:"snapshots,omitempty"`
}

ScalewaySnapshots represents a group of Scaleway snapshots

type ScalewayTask

type ScalewayTask struct {
	// Identifier is a unique identifier for the task
	Identifier string `json:"id,omitempty"`

	// StartDate is the start date of the task
	StartDate string `json:"started_at,omitempty"`

	// TerminationDate is the termination date of the task
	TerminationDate string `json:"terminated_at,omitempty"`

	HrefFrom string `json:"href_from,omitempty"`

	Description string `json:"description,omitempty"`

	Status string `json:"status,omitempty"`

	Progress int `json:"progress,omitempty"`
}

ScalewayTask represents a Scaleway Task

type ScalewayTasks

type ScalewayTasks struct {
	// Tasks holds scaleway tasks of the response
	Tasks []ScalewayTask `json:"tasks,omitempty"`
}

ScalewayTasks represents a group of Scaleway tasks

type ScalewayTokenDefinition

type ScalewayTokenDefinition struct {
	UserID             string                            `json:"user_id"`
	Description        string                            `json:"description,omitempty"`
	Roles              ScalewayTokenUserIDRoleDefinition `json:"roles"`
	Expires            string                            `json:"expires"`
	InheritsUsersPerms bool                              `json:"inherits_user_perms"`
	ID                 string                            `json:"id"`
}

ScalewayTokenDefinition represents a Scaleway Token

type ScalewayTokenUserIDRoleDefinition

type ScalewayTokenUserIDRoleDefinition struct {
	Organization string `json:"organization,omitempty"`
	Role         string `json:"role,omitempty"`
}

ScalewayTokenUserIDRoleDefinition represents a Scaleway Token UserId Role

type ScalewayTokensDefinition

type ScalewayTokensDefinition struct {
	Tokens []ScalewayTokenDefinition `json:"tokens"`
}

ScalewayTokensDefinition represents a Scaleway Tokens

type ScalewayUserPatchDefinition

type ScalewayUserPatchDefinition struct {
	SSHPublicKeys []ScalewayUserPatchKeyDefinition `json:"ssh_public_keys"`
}

ScalewayUserPatchDefinition represents a User Patch

type ScalewayUserPatchKeyDefinition

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

ScalewayUserPatchKeyDefinition represents a key

type ScalewayVolume

type ScalewayVolume struct {
	// Identifier is a unique identifier for the volume
	Identifier string `json:"id,omitempty"`

	// Size is the allocated size of the volume
	Size uint64 `json:"size,omitempty"`

	// CreationDate is the creation date of the volume
	CreationDate string `json:"creation_date,omitempty"`

	// ModificationDate is the date of the last modification of the volume
	ModificationDate string `json:"modification_date,omitempty"`

	// Organization is the organization owning the volume
	Organization string `json:"organization,omitempty"`

	// Name is the name of the volume
	Name string `json:"name,omitempty"`

	// Server is the server using this image
	Server *struct {
		Identifier string `json:"id,omitempty"`
		Name       string `json:"name,omitempty"`
	} `json:"server,omitempty"`

	// VolumeType is a Scaleway identifier for the kind of volume (default: l_ssd)
	VolumeType string `json:"volume_type,omitempty"`

	// ExportURI represents the url used by initrd/scripts to attach the volume
	ExportURI string `json:"export_uri,omitempty"`
}

ScalewayVolume represents a Scaleway Volume

type ScalewayVolumeDefinition

type ScalewayVolumeDefinition struct {
	// Name is the user-defined name of the volume
	Name string `json:"name"`

	// Image is the image used by the volume
	Size uint64 `json:"size"`

	// Bootscript is the bootscript used by the volume
	Type string `json:"volume_type"`

	// Organization is the owner of the volume
	Organization string `json:"organization"`
}

ScalewayVolumeDefinition represents a Scaleway C1 volume definition

type ScalewayVolumePutDefinition

type ScalewayVolumePutDefinition struct {
	Identifier       *string `json:"id,omitempty"`
	Size             *uint64 `json:"size,omitempty"`
	CreationDate     *string `json:"creation_date,omitempty"`
	ModificationDate *string `json:"modification_date,omitempty"`
	Organization     *string `json:"organization,omitempty"`
	Name             *string `json:"name,omitempty"`
	Server           struct {
		Identifier *string `json:"id,omitempty"`
		Name       *string `json:"name,omitempty"`
	} `json:"server,omitempty"`
	VolumeType *string `json:"volume_type,omitempty"`
	ExportURI  *string `json:"export_uri,omitempty"`
}

ScalewayVolumePutDefinition represents a Scaleway C1 volume with nullable fields (for PUT)

type ScalewayVolumes

type ScalewayVolumes struct {
	// Volumes holds scaleway volumes of the response
	Volumes []ScalewayVolume `json:"volumes,omitempty"`
}

ScalewayVolumes represents a group of Scaleway volumes

Jump to

Keyboard shortcuts

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