api

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2016 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package api contains client and functions to interact with Scaleway API

Index

Constants

View Source
const (
	// CacheRegion permits to access at the region field
	CacheRegion = iota
	// CacheArch permits to access at the arch field
	CacheArch
	// CacheOwner permits to access at the owner field
	CacheOwner
	// CacheTitle permits to access at the title field
	CacheTitle
	// CacheMarketPlaceUUID is used to determine the UUID of local images
	CacheMarketPlaceUUID

	// CacheMaxfield is used to determine the size of array
	CacheMaxfield
)
View Source
const (
	// IdentifierUnknown is used when we don't know explicitly 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 (
	AccountAPI     = "https://account.scaleway.com/"
	MetadataAPI    = "http://169.254.42.42/"
	MarketplaceAPI = "https://api-marketplace.scaleway.com"
	URLPublicDNS   = ".pub.cloud.scaleway.com"
	URLPrivateDNS  = ".priv.cloud.scaleway.com"
)

Default values

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, c *ConfigCreateServer) (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, arch string)

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 string, 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 ConfigCreateServer added in v1.6.0

type ConfigCreateServer struct {
	ImageName         string
	Name              string
	Bootscript        string
	Env               string
	AdditionalVolumes string
	IP                string
	CommercialType    string
	DynamicIPRequired bool
	EnableIPV6        bool
}

ConfigCreateServer represents the options sent to CreateServer and defining a server

type InspectIdentifierResult

type InspectIdentifierResult struct {
	Type   int
	Object interface{}
}

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

type Logger added in v1.10.1

type Logger interface {
	LogHTTP(*http.Request)
	Fatalf(format string, v ...interface{})
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
}

Logger handles logging concerns for the Scaleway API SDK

func NewDefaultLogger added in v1.10.1

func NewDefaultLogger() Logger

NewDefaultLogger returns a logger which is configured for stdout

func NewDisableLogger added in v1.10.1

func NewDisableLogger() Logger

NewDisableLogger returns a logger which is configured to do nothing

type MarketImage added in v1.8.0

type MarketImage struct {
	Categories           []string `json:"categories"`
	CreationDate         string   `json:"creation_date"`
	CurrentPublicVersion string   `json:"current_public_version"`
	Description          string   `json:"description"`
	ID                   string   `json:"id"`
	ModificationDate     string   `json:"modification_date"`
	Name                 string   `json:"name"`
	Organization         struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"organization"`
	Public bool `json:"-"`
	MarketVersions
}

MarketImage represents MarketPlace image

type MarketImages added in v1.8.0

type MarketImages struct {
	Images []MarketImage `json:"images"`
}

MarketImages represents MarketPlace images

type MarketLocalImage added in v1.8.0

type MarketLocalImage struct {
	LocalImages MarketLocalImageDefinition `json:"local_image"`
}

MarketLocalImage represents local image

type MarketLocalImageDefinition added in v1.8.0

type MarketLocalImageDefinition struct {
	Arch string `json:"arch"`
	ID   string `json:"id"`
	Zone string `json:"zone"`
}

MarketLocalImageDefinition represents localImage of marketplace version

type MarketLocalImages added in v1.8.0

type MarketLocalImages struct {
	LocalImages []MarketLocalImageDefinition `json:"local_images"`
}

MarketLocalImages represents an array of local images

type MarketVersion added in v1.8.0

type MarketVersion struct {
	Version MarketVersionDefinition `json:"version"`
}

MarketVersion represents version of marketplace image

type MarketVersionDefinition added in v1.8.0

type MarketVersionDefinition struct {
	CreationDate string `json:"creation_date"`
	ID           string `json:"id"`
	Image        struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"image"`
	ModificationDate string `json:"modification_date"`
	Name             string `json:"name"`
	MarketLocalImages
}

MarketVersionDefinition represents version of marketplace image

type MarketVersions added in v1.8.0

type MarketVersions struct {
	Versions []MarketVersionDefinition `json:"versions"`
}

MarketVersions represents an array of marketplace image versions

type ScalewayAPI

type ScalewayAPI struct {
	// 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

	//
	Logger
	// contains filtered or unexported fields
}

ScalewayAPI is the interface used to communicate with the Scaleway API

func NewScalewayAPI

func NewScalewayAPI(organization, token, userAgent, region string, options ...func(*ScalewayAPI)) (*ScalewayAPI, error)

NewScalewayAPI creates a ready-to-use ScalewayAPI client

func (*ScalewayAPI) AttachIP added in v1.6.0

func (s *ScalewayAPI) AttachIP(ipID, serverID string) error

AttachIP attachs an IP to a server

func (*ScalewayAPI) CheckCredentials

func (s *ScalewayAPI) CheckCredentials() error

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

func (*ScalewayAPI) ClearCache added in v1.10.1

func (s *ScalewayAPI) ClearCache()

ClearCache clears the cache

func (*ScalewayAPI) DeleteIP added in v1.6.0

func (s *ScalewayAPI) DeleteIP(ipID string) error

DeleteIP deletes an IP

func (*ScalewayAPI) DeleteImage

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

DeleteImage deletes a image

func (*ScalewayAPI) DeleteMarketPlaceImage added in v1.8.0

func (s *ScalewayAPI) DeleteMarketPlaceImage(uudImage string) error

DeleteMarketPlaceImage deletes image

func (*ScalewayAPI) DeleteMarketPlaceImageVersion added in v1.8.0

func (s *ScalewayAPI) DeleteMarketPlaceImageVersion(uuidImage, uuidVersion string) error

DeleteMarketPlaceImageVersion delete image version

func (*ScalewayAPI) DeleteMarketPlaceLocalImage added in v1.8.0

func (s *ScalewayAPI) DeleteMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string) error

DeleteMarketPlaceLocalImage deletes local image

func (*ScalewayAPI) DeleteResponse

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

DeleteResponse returns an http.Response object for the deleted resource

func (*ScalewayAPI) DeleteSecurityGroup added in v1.7.0

func (s *ScalewayAPI) DeleteSecurityGroup(securityGroupID string) error

DeleteSecurityGroup deletes a SecurityGroup

func (*ScalewayAPI) DeleteSecurityGroupRule added in v1.7.0

func (s *ScalewayAPI) DeleteSecurityGroupRule(SecurityGroupID, RuleID string) error

DeleteSecurityGroupRule deletes a SecurityGroupRule

func (*ScalewayAPI) DeleteServer

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

DeleteServer deletes a server

func (*ScalewayAPI) DeleteServerForce added in v1.10.1

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

DeleteServerForce tries to delete a server using multiple ways

func (*ScalewayAPI) DeleteSnapshot added in v1.7.0

func (s *ScalewayAPI) DeleteSnapshot(snapshotID string) error

DeleteSnapshot deletes a snapshot

func (*ScalewayAPI) DeleteUserdata added in v1.5.0

func (s *ScalewayAPI) DeleteUserdata(serverID, key string, metadata bool) error

DeleteUserdata deletes a server user_data

func (*ScalewayAPI) DeleteVolume added in v1.7.0

func (s *ScalewayAPI) DeleteVolume(volumeID string) error

DeleteVolume deletes a volume

func (*ScalewayAPI) DetachIP added in v1.10.1

func (s *ScalewayAPI) DetachIP(ipID string) error

DetachIP detaches an IP from a server

func (*ScalewayAPI) GetASecurityGroup added in v1.6.0

func (s *ScalewayAPI) GetASecurityGroup(groupsID string) (*ScalewayGetSecurityGroup, error)

GetASecurityGroup returns a ScalewaySecurityGroup

func (*ScalewayAPI) GetASecurityGroupRule added in v1.6.0

func (s *ScalewayAPI) GetASecurityGroupRule(groupID string, rulesID string) (*ScalewayGetSecurityGroupRule, error)

GetASecurityGroupRule returns a ScalewaySecurityGroupRule

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, arch string) (string, error)

GetBootscriptID returns exactly one bootscript matching

func (*ScalewayAPI) GetBootscripts

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

GetBootscripts gets the list of bootscripts from the ScalewayAPI

func (*ScalewayAPI) GetContainerDatas added in v1.6.0

func (s *ScalewayAPI) GetContainerDatas(container string) (*ScalewayGetContainerDatas, error)

GetContainerDatas returns a ScalewayGetContainerDatas

func (*ScalewayAPI) GetContainers added in v1.6.0

func (s *ScalewayAPI) GetContainers() (*ScalewayGetContainers, error)

GetContainers returns a ScalewayGetContainers

func (*ScalewayAPI) GetDashboard added in v1.6.0

func (s *ScalewayAPI) GetDashboard() (*ScalewayDashboard, error)

GetDashboard returns the dashboard

func (*ScalewayAPI) GetIP added in v1.6.0

func (s *ScalewayAPI) GetIP(ipID string) (*ScalewayGetIP, error)

GetIP returns a ScalewayGetIP

func (*ScalewayAPI) GetIPS added in v1.6.0

func (s *ScalewayAPI) GetIPS() (*ScalewayGetIPS, error)

GetIPS returns a ScalewayGetIPS

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, arch string) (*ScalewayImageIdentifier, error)

GetImageID returns exactly one image matching

func (*ScalewayAPI) GetImages

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

GetImages gets the list of images from the ScalewayAPI

func (*ScalewayAPI) GetMarketPlaceImageCurrentVersion added in v1.8.0

func (s *ScalewayAPI) GetMarketPlaceImageCurrentVersion(uuidImage string) (*MarketVersion, error)

GetMarketPlaceImageCurrentVersion return the image current version

func (*ScalewayAPI) GetMarketPlaceImageVersions added in v1.8.0

func (s *ScalewayAPI) GetMarketPlaceImageVersions(uuidImage, uuidVersion string) (*MarketVersions, error)

GetMarketPlaceImageVersions returns image version

func (*ScalewayAPI) GetMarketPlaceImages added in v1.8.0

func (s *ScalewayAPI) GetMarketPlaceImages(uuidImage string) (*MarketImages, error)

GetMarketPlaceImages returns images from marketplace

func (*ScalewayAPI) GetMarketPlaceLocalImages added in v1.8.0

func (s *ScalewayAPI) GetMarketPlaceLocalImages(uuidImage, uuidVersion, uuidLocalImage string) (*MarketLocalImages, error)

GetMarketPlaceLocalImages returns images from local region

func (*ScalewayAPI) GetOrganization

func (s *ScalewayAPI) GetOrganization() (*ScalewayOrganizationsDefinition, error)

GetOrganization returns Organization

func (*ScalewayAPI) GetPermissions added in v1.6.0

func (s *ScalewayAPI) GetPermissions() (*ScalewayPermissionDefinition, error)

GetPermissions returns the permissions

func (*ScalewayAPI) GetQuotas added in v1.6.0

func (s *ScalewayAPI) GetQuotas() (*ScalewayGetQuotas, error)

GetQuotas returns a ScalewayGetQuotas

func (*ScalewayAPI) GetResponsePaginate added in v1.10.1

func (s *ScalewayAPI) GetResponsePaginate(apiURL, resource string, values url.Values) (*http.Response, error)

GetResponsePaginate fetchs all resources and returns an http.Response object for the requested resource

func (*ScalewayAPI) GetSSHFingerprintFromServer added in v1.7.0

func (a *ScalewayAPI) GetSSHFingerprintFromServer(serverID string) []string

GetSSHFingerprintFromServer returns an array which containts ssh-host-fingerprints

func (*ScalewayAPI) GetSecurityGroupRules added in v1.6.0

func (s *ScalewayAPI) GetSecurityGroupRules(groupID string) (*ScalewayGetSecurityGroupRules, error)

GetSecurityGroupRules returns a ScalewaySecurityGroupRules

func (*ScalewayAPI) GetSecurityGroups added in v1.6.0

func (s *ScalewayAPI) GetSecurityGroups() (*ScalewayGetSecurityGroups, error)

GetSecurityGroups returns a ScalewaySecurityGroups

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, error)

GetServerID returns exactly one server matching

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, error)

GetSnapshotID returns exactly one snapshot matching

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) GetUser

func (s *ScalewayAPI) GetUser() (*ScalewayUserDefinition, error)

GetUser returns the user

func (*ScalewayAPI) GetUserID

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

GetUserID returns the userID

func (*ScalewayAPI) GetUserdata added in v1.5.0

func (s *ScalewayAPI) GetUserdata(serverID, key string, metadata bool) (*ScalewayUserdata, error)

GetUserdata gets a specific userdata for a server

func (*ScalewayAPI) GetUserdatas added in v1.5.0

func (s *ScalewayAPI) GetUserdatas(serverID string, metadata bool) (*ScalewayUserdatas, error)

GetUserdatas gets list of userdata for a server

func (*ScalewayAPI) GetVolume

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

GetVolume gets a volume from the ScalewayAPI

func (*ScalewayAPI) GetVolumeID added in v1.7.0

func (s *ScalewayAPI) GetVolumeID(needle string) (string, error)

GetVolumeID returns exactly one volume matching

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) NewIP added in v1.6.0

func (s *ScalewayAPI) NewIP() (*ScalewayGetIP, error)

NewIP returns a new IP

func (*ScalewayAPI) PatchResponse

func (s *ScalewayAPI) PatchResponse(apiURL, 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) PatchUserSSHKey

func (s *ScalewayAPI) PatchUserSSHKey(UserID string, definition ScalewayUserPatchSSHKeyDefinition) error

PatchUserSSHKey updates a user

func (*ScalewayAPI) PatchUserdata added in v1.5.0

func (s *ScalewayAPI) PatchUserdata(serverID, key string, value []byte, metadata bool) error

PatchUserdata sets a user data

func (*ScalewayAPI) PostImage

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

PostImage creates a new image

func (*ScalewayAPI) PostMarketPlaceImage added in v1.8.0

func (s *ScalewayAPI) PostMarketPlaceImage(images MarketImage) error

PostMarketPlaceImage adds new image

func (*ScalewayAPI) PostMarketPlaceImageVersion added in v1.8.0

func (s *ScalewayAPI) PostMarketPlaceImageVersion(uuidImage string, version MarketVersion) error

PostMarketPlaceImageVersion adds new image version

func (*ScalewayAPI) PostMarketPlaceLocalImage added in v1.8.0

func (s *ScalewayAPI) PostMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error

PostMarketPlaceLocalImage adds new local image

func (*ScalewayAPI) PostResponse

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

PostResponse returns an http.Response object for the updated resource

func (*ScalewayAPI) PostSecurityGroup added in v1.7.0

func (s *ScalewayAPI) PostSecurityGroup(group ScalewayNewSecurityGroup) error

PostSecurityGroup posts a group on a server

func (*ScalewayAPI) PostSecurityGroupRule added in v1.7.0

func (s *ScalewayAPI) PostSecurityGroupRule(SecurityGroupID string, rules ScalewayNewSecurityGroupRule) error

PostSecurityGroupRule posts a rule on a server

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) PutMarketPlaceImage added in v1.8.0

func (s *ScalewayAPI) PutMarketPlaceImage(uudiImage string, images MarketImage) error

PutMarketPlaceImage updates image

func (*ScalewayAPI) PutMarketPlaceImageVersion added in v1.8.0

func (s *ScalewayAPI) PutMarketPlaceImageVersion(uuidImage, uuidVersion string, version MarketVersion) error

PutMarketPlaceImageVersion updates image version

func (*ScalewayAPI) PutMarketPlaceLocalImage added in v1.8.0

func (s *ScalewayAPI) PutMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local MarketLocalImage) error

PutMarketPlaceLocalImage updates local image

func (*ScalewayAPI) PutResponse

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

PutResponse returns an http.Response object for the updated resource

func (*ScalewayAPI) PutSecurityGroup added in v1.7.0

func (s *ScalewayAPI) PutSecurityGroup(group ScalewayUpdateSecurityGroup, securityGroupID string) error

PutSecurityGroup updates a SecurityGroup

func (*ScalewayAPI) PutSecurityGroupRule added in v1.7.0

func (s *ScalewayAPI) PutSecurityGroupRule(rules ScalewayNewSecurityGroupRule, securityGroupID, RuleID string) error

PutSecurityGroupRule updates a SecurityGroupRule

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 to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveImage

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

ResolveImage attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveServer

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

ResolveServer attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveSnapshot

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

ResolveSnapshot attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveVolume added in v1.7.0

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

ResolveVolume attempts to find a matching Identifier for the input string

func (*ScalewayAPI) SetPassword

func (s *ScalewayAPI) SetPassword(password string)

SetPassword register the password

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) Error

func (e ScalewayAPIError) Error() string

Error returns a string representing the error

type ScalewayBootscript

type ScalewayBootscript struct {
	Bootcmdargs string `json:"bootcmdargs,omitempty"`
	Dtb         string `json:"dtb,omitempty"`
	Initrd      string `json:"initrd,omitempty"`
	Kernel      string `json:"kernel,omitempty"`

	// Arch is the architecture target of the bootscript
	Arch string `json:"architecture,omitempty"`

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

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

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

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

	Default bool `json:"default,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][CacheMaxfield]string `json:"images"`

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

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

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

	// Servers contains names of Scaleway servers indexed by identifier
	Servers map[string][CacheMaxfield]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:"-"`
	// contains filtered or unexported fields
}

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

func NewScalewayCache

func NewScalewayCache(hookSave func()) (*ScalewayCache, error)

NewScalewayCache loads a per-user cache

func (*ScalewayCache) Clear added in v1.10.1

func (c *ScalewayCache) Clear()

Clear removes all information from the 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, region, arch, owner, name string)

InsertBootscript registers an bootscript in the cache

func (*ScalewayCache) InsertImage

func (c *ScalewayCache) InsertImage(identifier, region, arch, owner, name, marketPlaceUUID string)

InsertImage registers an image in the cache

func (*ScalewayCache) InsertServer

func (c *ScalewayCache) InsertServer(identifier, region, arch, owner, name string)

InsertServer registers a server in the cache

func (*ScalewayCache) InsertSnapshot

func (c *ScalewayCache) InsertSnapshot(identifier, region, arch, owner, name string)

InsertSnapshot registers an snapshot in the cache

func (*ScalewayCache) InsertVolume

func (c *ScalewayCache) InsertVolume(identifier, region, arch, owner, name string)

InsertVolume registers an volume in the cache

func (*ScalewayCache) LookUpBootscripts

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

LookUpBootscripts attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpIdentifiers

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

LookUpIdentifiers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpImages

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

LookUpImages attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpServers

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

LookUpServers attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpSnapshots

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

LookUpSnapshots attempts to return identifiers matching a pattern

func (*ScalewayCache) LookUpVolumes

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

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 ScalewayConnect

type ScalewayConnect struct {
	Email       string `json:"email"`
	Password    string `json:"password"`
	Description string `json:"description"`
	Expires     bool   `json:"expires"`
}

ScalewayConnect represents the data to connect

type ScalewayConnectResponse

type ScalewayConnectResponse struct {
	Token ScalewayTokenDefinition `json:"token"`
}

ScalewayConnectResponse represents the answer from POST /tokens

type ScalewayContainer added in v1.6.0

type ScalewayContainer struct {
	ScalewayOrganizationDefinition `json:"organization"`
	Name                           string `json:"name"`
	Size                           string `json:"size"`
}

ScalewayContainer represents a Scaleway container (S3)

type ScalewayContainerData added in v1.6.0

type ScalewayContainerData struct {
	LastModified string `json:"last_modified"`
	Name         string `json:"name"`
	Size         string `json:"size"`
}

ScalewayContainerData represents a Scaleway container data (S3)

type ScalewayDashboard added in v1.6.0

type ScalewayDashboard struct {
	VolumesCount        int `json:"volumes_count"`
	RunningServersCount int `json:"running_servers_count"`
	ImagesCount         int `json:"images_count"`
	SnapshotsCount      int `json:"snapshots_count"`
	ServersCount        int `json:"servers_count"`
	IPsCount            int `json:"ips_count"`
}

ScalewayDashboard represents a dashboard

type ScalewayDashboardResp added in v1.6.0

type ScalewayDashboardResp struct {
	Dashboard ScalewayDashboard
}

ScalewayDashboardResp represents a dashboard received from the API

type ScalewayGetContainerDatas added in v1.6.0

type ScalewayGetContainerDatas struct {
	Container []ScalewayContainerData `json:"container"`
}

ScalewayGetContainerDatas represents a list of Scaleway containers data (S3)

type ScalewayGetContainers added in v1.6.0

type ScalewayGetContainers struct {
	Containers []ScalewayContainer `json:"containers"`
}

ScalewayGetContainers represents a list of Scaleway containers (S3)

type ScalewayGetIP added in v1.6.0

type ScalewayGetIP struct {
	IP ScalewayIPDefinition `json:"ip"`
}

ScalewayGetIP represents the response of a GET /ips/{id_ip}

type ScalewayGetIPS added in v1.6.0

type ScalewayGetIPS struct {
	IPS []ScalewayIPDefinition `json:"ips"`
}

ScalewayGetIPS represents the response of a GET /ips/

type ScalewayGetQuotas added in v1.6.0

type ScalewayGetQuotas struct {
	Quotas ScalewayQuota `json:"quotas"`
}

ScalewayGetQuotas represents the response of GET /organizations/{orga_id}/quotas

type ScalewayGetSecurityGroup added in v1.6.0

type ScalewayGetSecurityGroup struct {
	SecurityGroups ScalewaySecurityGroups `json:"security_group"`
}

ScalewayGetSecurityGroup represents the response of a GET /security_groups/{groupID}

type ScalewayGetSecurityGroupRule added in v1.6.0

type ScalewayGetSecurityGroupRule struct {
	Rules ScalewaySecurityGroupRule `json:"rule"`
}

ScalewayGetSecurityGroupRule represents the response of a GET /security_group/{groupID}/rules/{ruleID}

type ScalewayGetSecurityGroupRules added in v1.6.0

type ScalewayGetSecurityGroupRules struct {
	Rules []ScalewaySecurityGroupRule `json:"rules"`
}

ScalewayGetSecurityGroupRules represents the response of a GET /security_group/{groupID}/rules

type ScalewayGetSecurityGroups added in v1.6.0

type ScalewayGetSecurityGroups struct {
	SecurityGroups []ScalewaySecurityGroups `json:"security_groups"`
}

ScalewayGetSecurityGroups represents the response of a GET /security_groups/

type ScalewayGetTokens added in v1.10.1

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

ScalewayGetTokens represents a list of Scaleway Tokens

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 ScalewayIPDefinition added in v1.6.0

type ScalewayIPDefinition struct {
	Organization string  `json:"organization"`
	Reverse      *string `json:"reverse"`
	ID           string  `json:"id"`
	Server       *struct {
		Identifier string `json:"id,omitempty"`
		Name       string `json:"name,omitempty"`
	} `json:"server"`
	Address string `json:"address"`
}

ScalewayIPDefinition represents the IP's fields

type ScalewayIPV6Definition added in v1.10.1

type ScalewayIPV6Definition struct {
	Netmask string `json:"netmask"`
	Gateway string `json:"gateway"`
	Address string `json:"address"`
}

ScalewayIPV6Definition represents a Scaleway ipv6

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"`
	DefaultBootscript  *string `json:"default_bootscript,omitempty"`
}

ScalewayImageDefinition represents a Scaleway image definition

type ScalewayImageIdentifier added in v1.7.0

type ScalewayImageIdentifier struct {
	Identifier string
	Arch       string
	Region     string
	Owner      string
}

ScalewayImageIdentifier represents a Scaleway Image Identifier

type ScalewayImageInterface

type ScalewayImageInterface struct {
	CreationDate time.Time
	Identifier   string
	Name         string
	Tag          string
	VirtualSize  float64
	Public       bool
	Type         string
	Organization string
	Archs        []string
	Region       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 ScalewayKeyDefinition

type ScalewayKeyDefinition struct {
	Key         string `json:"key"`
	Fingerprint string `json:"fingerprint,omitempty"`
}

ScalewayKeyDefinition represents a key

type ScalewayNewSecurityGroup added in v1.6.0

type ScalewayNewSecurityGroup struct {
	Organization string `json:"organization"`
	Name         string `json:"name"`
	Description  string `json:"description"`
}

ScalewayNewSecurityGroup definition POST request /security_groups

type ScalewayNewSecurityGroupRule added in v1.6.0

type ScalewayNewSecurityGroupRule struct {
	Action       string `json:"action"`
	Direction    string `json:"direction"`
	IPRange      string `json:"ip_range"`
	Protocol     string `json:"protocol"`
	DestPortFrom int    `json:"dest_port_from,omitempty"`
}

ScalewayNewSecurityGroupRule definition POST/PUT request /security_group/{groupID}

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 ScalewayOrganizationDefinition

type ScalewayOrganizationDefinition struct {
	ID    string                   `json:"id"`
	Name  string                   `json:"name"`
	Users []ScalewayUserDefinition `json:"users"`
}

ScalewayOrganizationDefinition represents a Scaleway Organization

type ScalewayOrganizationsDefinition

type ScalewayOrganizationsDefinition struct {
	Organizations []ScalewayOrganizationDefinition `json:"organizations"`
}

ScalewayOrganizationsDefinition represents a Scaleway Organizations

type ScalewayPermCategory added in v1.6.0

type ScalewayPermCategory map[string][]string

ScalewayPermCategory represents ScalewayPermissions's fields

type ScalewayPermissionDefinition added in v1.6.0

type ScalewayPermissionDefinition struct {
	Permissions ScalewayPermissions `json:"permissions"`
}

ScalewayPermissionDefinition represents the permissions

type ScalewayPermissions added in v1.6.0

type ScalewayPermissions map[string]ScalewayPermCategory

ScalewayPermissions represents the response of GET /permissions

type ScalewayQuota added in v1.6.0

type ScalewayQuota map[string]int

ScalewayQuota represents a map of quota (name, value)

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
	Arch       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, error)

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

func NewScalewayResolverResult added in v1.7.0

func NewScalewayResolverResult(Identifier, Name, Arch string, Type int) (ScalewayResolverResult, error)

NewScalewayResolverResult returns a new ScalewayResolverResult

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 FilterImagesByArch added in v1.8.0

func FilterImagesByArch(res ScalewayResolverResults, arch string) (ret ScalewayResolverResults)

FilterImagesByArch removes entry that doesn't match with architecture

func ResolveIdentifier

func ResolveIdentifier(api *ScalewayAPI, needle string) (ScalewayResolverResults, error)

ResolveIdentifier resolves needle provided by the user

func (*ScalewayResolverResults) FilterByArch added in v1.7.0

func (s *ScalewayResolverResults) FilterByArch(arch string)

FilterByArch deletes the elements which not match with arch

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 ScalewayRoleDefinition

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

ScalewayRoleDefinition represents a Scaleway Token UserId Role

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 ScalewaySecurityGroupRule added in v1.6.0

type ScalewaySecurityGroupRule struct {
	Direction    string `json:"direction"`
	Protocol     string `json:"protocol"`
	IPRange      string `json:"ip_range"`
	DestPortFrom int    `json:"dest_port_from,omitempty"`
	Action       string `json:"action"`
	Position     int    `json:"position"`
	DestPortTo   string `json:"dest_port_to"`
	Editable     bool   `json:"editable"`
	ID           string `json:"id"`
}

ScalewaySecurityGroupRule definition

type ScalewaySecurityGroups added in v1.6.0

type ScalewaySecurityGroups struct {
	Description           string                  `json:"description"`
	ID                    string                  `json:"id"`
	Organization          string                  `json:"organization"`
	Name                  string                  `json:"name"`
	Servers               []ScalewaySecurityGroup `json:"servers"`
	EnableDefaultSecurity bool                    `json:"enable_default_security"`
	OrganizationDefault   bool                    `json:"organization_default"`
}

ScalewaySecurityGroups definition

type ScalewayServer

type ScalewayServer struct {
	// Arch is the architecture target of the server
	Arch string `json:"arch,omitempty"`

	// 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"`

	// CommercialType is the commercial type of the server (i.e: C1, C2[SML], VC1S)
	CommercialType string `json:"commercial_type,omitempty"`

	// Location of the server
	Location struct {
		Platform   string `json:"platform_id,omitempty"`
		Chassis    string `json:"chassis_id,omitempty"`
		Cluster    string `json:"cluster_id,omitempty"`
		Hypervisor string `json:"hypervisor_id,omitempty"`
		Blade      string `json:"blade_id,omitempty"`
		Node       string `json:"node_id,omitempty"`
	} `json:"location,omitempty"`

	IPV6 *ScalewayIPV6Definition `json:"ipv6,omitempty"`

	EnableIPV6 bool `json:"enable_ipv6,omitempty"`

	// This fields are not returned by the API, we generate it
	DNSPublic  string `json:"dns_public,omitempty"`
	DNSPrivate string `json:"dns_private,omitempty"`
}

ScalewayServer represents a Scaleway server

func WaitForServerReady

func WaitForServerReady(api *ScalewayAPI, serverID, 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 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"`

	// CommercialType is the commercial type of the server (i.e: C1, C2[SML], VC1S)
	CommercialType string `json:"commercial_type"`

	PublicIP string `json:"public_ip,omitempty"`

	EnableIPV6 bool `json:"enable_ipv6,omitempty"`

	SecurityGroup string `json:"security_group,omitempty"`
}

ScalewayServerDefinition represents a Scaleway server with image definition

type ScalewayServerPatchDefinition

type ScalewayServerPatchDefinition struct {
	Arch              *string                    `json:"arch,omitempty"`
	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        *string                    `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"`
	Tags              *[]string                  `json:"tags,omitempty"`
	IPV6              *ScalewayIPV6Definition    `json:"ipv6,omitempty"`
	EnableIPV6        *bool                      `json:"enable_ipv6,omitempty"`
}

ScalewayServerPatchDefinition represents a Scaleway 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 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 ScalewaySortServers added in v1.10.1

type ScalewaySortServers []ScalewayServer

ScalewaySortServers represents a wrapper to sort by CreationDate the servers

func (ScalewaySortServers) Len added in v1.10.1

func (s ScalewaySortServers) Len() int

func (ScalewaySortServers) Less added in v1.10.1

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

func (ScalewaySortServers) Swap added in v1.10.1

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

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              ScalewayRoleDefinition `json:"roles"`
	Expires            string                 `json:"expires"`
	InheritsUsersPerms bool                   `json:"inherits_user_perms"`
	ID                 string                 `json:"id"`
}

ScalewayTokenDefinition represents a Scaleway Token

type ScalewayTokensDefinition

type ScalewayTokensDefinition struct {
	Token ScalewayTokenDefinition `json:"token"`
}

ScalewayTokensDefinition represents a Scaleway Tokens

type ScalewayUpdateSecurityGroup added in v1.10.1

type ScalewayUpdateSecurityGroup struct {
	Organization        string `json:"organization"`
	Name                string `json:"name"`
	Description         string `json:"description"`
	OrganizationDefault bool   `json:"organization_default"`
}

ScalewayUpdateSecurityGroup definition PUT request /security_groups

type ScalewayUserDefinition

type ScalewayUserDefinition struct {
	Email         string                           `json:"email"`
	Firstname     string                           `json:"firstname"`
	Fullname      string                           `json:"fullname"`
	ID            string                           `json:"id"`
	Lastname      string                           `json:"lastname"`
	Organizations []ScalewayOrganizationDefinition `json:"organizations"`
	Roles         []ScalewayRoleDefinition         `json:"roles"`
	SSHPublicKeys []ScalewayKeyDefinition          `json:"ssh_public_keys"`
}

ScalewayUserDefinition represents a Scaleway User

type ScalewayUserPatchSSHKeyDefinition

type ScalewayUserPatchSSHKeyDefinition struct {
	SSHPublicKeys []ScalewayKeyDefinition `json:"ssh_public_keys"`
}

ScalewayUserPatchSSHKeyDefinition represents a User Patch

type ScalewayUserdata added in v1.5.0

type ScalewayUserdata []byte

ScalewayUserdata represents []byte

func (*ScalewayUserdata) String added in v1.5.0

func (s *ScalewayUserdata) String() string

type ScalewayUserdatas added in v1.5.0

type ScalewayUserdatas struct {
	UserData []string `json:"user_data"`
}

ScalewayUserdatas represents the response of a GET /user_data

type ScalewayUsersDefinition

type ScalewayUsersDefinition struct {
	User ScalewayUserDefinition `json:"user"`
}

ScalewayUsersDefinition represents the response of a GET /user

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 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 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