api

package module
v0.0.0-...-0d651c5 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 21 Imported by: 1

Documentation

Overview

Package api contains client and functions to interact with Scaleway API

Index

Constants

This section is empty.

Variables

View Source
var (
	AccountAPI     = "https://account.scaleway.com/"
	MetadataAPI    = "http://169.254.42.42/"
	MarketplaceAPI = "https://api-marketplace.scaleway.com"
	ComputeAPIPar1 = "https://cp-par1.scaleway.com/"
	ComputeAPIAms1 = "https://cp-ams1.scaleway.com"

	URLPublicDNS  = ".pub.cloud.scaleway.com"
	URLPrivateDNS = ".priv.cloud.scaleway.com"
)

Default values

Functions

func FilterImagesByArch

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

FilterImagesByArch removes entry that doesn't match with architecture

func FilterImagesByRegion

func FilterImagesByRegion(res types.ScalewayResolverResults, region string) (ret types.ScalewayResolverResults)

FilterImagesByRegion removes entry that doesn't match with region

Types

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 *cache.ScalewayCache

	Region string
	//
	logger.Logger
	// contains filtered or unexported fields
}

types.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)

Newtypes.ScalewayAPI creates a ready-to-use ScalewayAPI client

func (*ScalewayAPI) AttachIP

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

func (s *ScalewayAPI) ClearCache()

ClearCache clears the cache

func (*ScalewayAPI) DeleteIP

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

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

DeleteMarketPlaceImage deletes image

func (*ScalewayAPI) DeleteMarketPlaceImageVersion

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

DeleteMarketPlaceImageVersion delete image version

func (*ScalewayAPI) DeleteMarketPlaceLocalImage

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

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

DeleteSecurityGroup deletes a SecurityGroup

func (*ScalewayAPI) DeleteSecurityGroupRule

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

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

DeleteSnapshot deletes a snapshot

func (*ScalewayAPI) DeleteUserdata

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

DeleteUserdata deletes a server user_data

func (*ScalewayAPI) DeleteVolume

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

DeleteVolume deletes a volume

func (*ScalewayAPI) DetachIP

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

DetachIP detaches an IP from a server

func (*ScalewayAPI) GetASecurityGroup

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

GetASecurityGroup returns a ScalewaySecurityGroup

func (*ScalewayAPI) GetASecurityGroupRule

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

GetASecurityGroupRule returns a ScalewaySecurityGroupRule

func (*ScalewayAPI) GetBootscript

func (s *ScalewayAPI) GetBootscript(bootscriptID string) (*types.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() (*[]types.ScalewayBootscript, error)

GetBootscripts gets the list of bootscripts from the ScalewayAPI

func (*ScalewayAPI) GetContainerDatas

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

GetContainerDatas returns a types.ScalewayGetContainerDatas

func (*ScalewayAPI) GetContainers

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

GetContainers returns a types.ScalewayGetContainers

func (*ScalewayAPI) GetDashboard

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

GetDashboard returns the dashboard

func (*ScalewayAPI) GetIP

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

GetIP returns a types.ScalewayGetIP

func (*ScalewayAPI) GetIPS

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

GetIPS returns a types.ScalewayGetIPS

func (*ScalewayAPI) GetImage

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

GetImage gets an image from the ScalewayAPI

func (*ScalewayAPI) GetImageID

func (s *ScalewayAPI) GetImageID(needle, arch string) (*types.ScalewayImageIdentifier, error)

GetImageID returns exactly one image matching

func (*ScalewayAPI) GetImages

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

GetImages gets the list of images from the ScalewayAPI

func (*ScalewayAPI) GetMarketPlaceImageCurrentVersion

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

GetMarketPlaceImageCurrentVersion return the image current version

func (*ScalewayAPI) GetMarketPlaceImageVersions

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

GetMarketPlaceImageVersions returns image version

func (*ScalewayAPI) GetMarketPlaceImages

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

GetMarketPlaceImages returns images from marketplace

func (*ScalewayAPI) GetMarketPlaceLocalImages

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

GetMarketPlaceLocalImages returns images from local region

func (*ScalewayAPI) GetOrganization

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

GetOrganization returns Organization

func (*ScalewayAPI) GetPermissions

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

GetPermissions returns the permissions

func (*ScalewayAPI) GetProductsServers

func (s *ScalewayAPI) GetProductsServers() (*types.ScalewayProductsServers, error)

GetProductServers Fetches all the server type and their constraints from the Products API

func (*ScalewayAPI) GetQuotas

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

GetQuotas returns a types.ScalewayGetQuotas

func (*ScalewayAPI) GetResponsePaginate

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

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

GetSecurityGroupRules returns a ScalewaySecurityGroupRules

func (*ScalewayAPI) GetSecurityGroups

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

GetSecurityGroups returns a ScalewaySecurityGroups

func (*ScalewayAPI) GetServer

func (s *ScalewayAPI) GetServer(serverID string) (*types.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) (*[]types.ScalewayServer, error)

GetServers gets the list of servers from the ScalewayAPI

func (*ScalewayAPI) GetSnapshot

func (s *ScalewayAPI) GetSnapshot(snapshotID string) (*types.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() (*[]types.ScalewaySnapshot, error)

GetSnapshots gets the list of snapshots from the ScalewayAPI

func (*ScalewayAPI) GetTasks

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

GetTasks get the list of tasks from the ScalewayAPI

func (*ScalewayAPI) GetUser

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

GetUser returns the user

func (*ScalewayAPI) GetUserID

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

GetUserID returns the userID

func (*ScalewayAPI) GetUserdata

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

GetUserdata gets a specific userdata for a server

func (*ScalewayAPI) GetUserdatas

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

GetUserdatas gets list of userdata for a server

func (*ScalewayAPI) GetVolume

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

GetVolume gets a volume from the ScalewayAPI

func (*ScalewayAPI) GetVolumeID

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

GetVolumeID returns exactly one volume matching

func (*ScalewayAPI) GetVolumes

func (s *ScalewayAPI) GetVolumes() (*[]types.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

func (s *ScalewayAPI) NewIP() (*types.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 types.ScalewayServerPatchDefinition) error

PatchServer updates a server

func (*ScalewayAPI) PatchUserSSHKey

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

PatchUserSSHKey updates a user

func (*ScalewayAPI) PatchUserdata

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

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

PostMarketPlaceImage adds new image

func (*ScalewayAPI) PostMarketPlaceImageVersion

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

PostMarketPlaceImageVersion adds new image version

func (*ScalewayAPI) PostMarketPlaceLocalImage

func (s *ScalewayAPI) PostMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local types.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

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

PostSecurityGroup posts a group on a server

func (*ScalewayAPI) PostSecurityGroupRule

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

PostSecurityGroupRule posts a rule on a server

func (*ScalewayAPI) PostServer

func (s *ScalewayAPI) PostServer(definition types.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 types.ScalewayVolumeDefinition) (string, error)

PostVolume creates a new volume

func (*ScalewayAPI) PutMarketPlaceImage

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

PutMarketPlaceImage updates image

func (*ScalewayAPI) PutMarketPlaceImageVersion

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

PutMarketPlaceImageVersion updates image version

func (*ScalewayAPI) PutMarketPlaceLocalImage

func (s *ScalewayAPI) PutMarketPlaceLocalImage(uuidImage, uuidVersion, uuidLocalImage string, local types.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

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

PutSecurityGroup updates a SecurityGroup

func (*ScalewayAPI) PutSecurityGroupRule

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

PutSecurityGroupRule updates a SecurityGroupRule

func (*ScalewayAPI) PutVolume

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

PutVolume updates a volume

func (*ScalewayAPI) ResolveBootscript

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

ResolveBootscript attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveImage

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

ResolveImage attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveServer

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

ResolveServer attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveSnapshot

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

ResolveSnapshot attempts to find a matching Identifier for the input string

func (*ScalewayAPI) ResolveTTYUrl

func (s *ScalewayAPI) ResolveTTYUrl() string

ResolveTTYUrl return an URL to get a tty

func (*ScalewayAPI) ResolveVolume

func (s *ScalewayAPI) ResolveVolume(needle string) (types.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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