api

package
Version: v0.0.0-...-6e53cf2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	StatusCode int
	Header     http.Header
	Message    string
	URL        *url.URL
}

Error represents an HTTP error

func (Error) Error

func (e Error) Error() string

Error supports the error interface

type IPAddress

type IPAddress struct {
	ID           string `json:"id,omitempty"`
	Address      string `json:"address,omitempty"`
	Organization string `json:"organization,omitempty"`
	Server       string `json:"server,omitempty"`
}

IPAddress represents an IP entity

func (IPAddress) Display

func (ip IPAddress) Display()

Display log the IPAddress caracteristics

type IPAddressResponse

type IPAddressResponse struct {
	IPAddress `json:"ip,omitempty"`
}

IPAddressResponse represents JSON response of IP address

func GetIPAddressFromJSON

func GetIPAddressFromJSON(b []byte) (*IPAddressResponse, error)

GetIPAddressFromJSON load bytes and return a IPAddressResponse

type IPAddressesResponse

type IPAddressesResponse struct {
	IPAddresses []IPAddress
}

IPAddressesResponse represents JSON response of list of IP address

func GetIPAddressesFromJSON

func GetIPAddressesFromJSON(b []byte) (*IPAddressesResponse, error)

GetIPAddressesFromJSON load bytes and return a IPAddressesResponse

type Image

type Image struct {
	ID           string `json:"id,omitempty"`
	Arch         string `json:"arch,omitempty"`
	Name         string `json:"name,omitempty"`
	Creation     string `json:"creation_date,omitempty"`
	Modification string `json:"modification_date,omitempty"`
	Organization string `json:"organization,omitempty"`
	Public       bool   `json:"public,omitempty"`
}

Image represents the image entity

func (Image) Display

func (i Image) Display()

Display log the Image caracteristics

type ImageResponse

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

ImageResponse represents JSON response of an image

type ImagesResponse

type ImagesResponse struct {
	Images []Image
}

ImagesResponse represents a list of volumes in JSON

type Organization

type Organization struct {
	ID            string `json:"id,omitempty"`
	Name          string `json:"name,omitempty"`
	Currency      string `json:"currency,omitempty"`
	Locale        string `json:"locale,omitempty"`
	CustomerClass string `json:"customer_class,omitempty"`
}

Organization represents a Scaleway entity

func (Organization) Display

func (o Organization) Display()

Display log the Organization caracteristics

type OrganizationsResponse

type OrganizationsResponse struct {
	Organizations []Organization
}

OrganizationsResponse represents JSON response of server

type PublicIP

type PublicIP struct {
	ID      string `json:"id,omitempty"`
	Dynamic bool   `json:"dynamic,omitempty"`
	Address string `json:"address,omitempty"`
}

PublicIP represents IP address of a server

type Role

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

Role represents role of an user into an organization

type ScalewayClient

type ScalewayClient struct {
	Token        string
	UserID       string
	Organization string
	Client       *http.Client
	ComputeURL   string
	AccountURL   string
}

ScalewayClient is a client for the Scaleway API. Token is to authenticate to the API UserID represents your user identifiant Organization is the ID of the user's organization

func NewClient

func NewClient(token string, userid string, organization string) *ScalewayClient

NewClient creates a new Scaleway API client using API token. userid can be an empty string - defaults to the token's user id organization can be an empty string - defaults to the user's primary organization

func (ScalewayClient) CreateIP

func (c ScalewayClient) CreateIP() (IPAddressResponse, error)

CreateIP creates a new reserved IP address

func (ScalewayClient) CreateServer

func (c ScalewayClient) CreateServer(name string, image string) (ServerResponse, error)

CreateServer creates a new server name is the server name image is the image unique identifier

func (ScalewayClient) CreateToken

func (c ScalewayClient) CreateToken(email string, password string, expires bool) (TokenResponse, error)

CreateToken authenticates a user against their email, password, and then returns a new Token, which can be used until it expires. email is the user email password is the user password expires is if you want a token wich expires or not

func (ScalewayClient) CreateVolume

func (c ScalewayClient) CreateVolume(name string, volumeType string, size int) (VolumeResponse, error)

CreateVolume creates a new volume name is the volume name volumeType is the volume type size is the volume size

func (ScalewayClient) DeleteIP

func (c ScalewayClient) DeleteIP(ipID string) error

DeleteIP delete a specific IP address ipID is the IP unique identifier

func (ScalewayClient) DeleteImage

func (c ScalewayClient) DeleteImage(imageID string) error

DeleteImage delete a specific volume volumeID is the volume unique identifier

func (ScalewayClient) DeleteServer

func (c ScalewayClient) DeleteServer(serverID string) error

DeleteServer delete a specific server serverID is the server unique identifier

func (ScalewayClient) DeleteToken

func (c ScalewayClient) DeleteToken(tokenID string) error

DeleteToken delete a specific token tokenID is the token unique identifier

func (ScalewayClient) DeleteVolume

func (c ScalewayClient) DeleteVolume(volumeID string) error

DeleteVolume delete a specific volume volumeID is the volume unique identifier

func (ScalewayClient) GetIP

func (c ScalewayClient) GetIP(ipID string) (IPAddressResponse, error)

GetIP list an individual IP address ipID is the IP unique identifier

func (ScalewayClient) GetIPs

GetIPs list all IPs associate with your account

func (ScalewayClient) GetImage

func (c ScalewayClient) GetImage(volumeID string) (ImageResponse, error)

GetImage list an individual image volumeID is the image unique identifier

func (ScalewayClient) GetImages

func (c ScalewayClient) GetImages() (ImagesResponse, error)

GetImages list all images associate with your account

func (ScalewayClient) GetServer

func (c ScalewayClient) GetServer(serverID string) (ServerResponse, error)

GetServer list an individual server serverID is the server unique identifier

func (ScalewayClient) GetServers

func (c ScalewayClient) GetServers() (ServersResponse, error)

GetServers list all servers associate with your account

func (ScalewayClient) GetUserInformations

func (c ScalewayClient) GetUserInformations() (UserResponse, error)

GetUserInformations list informations about your user account

func (ScalewayClient) GetUserOrganizations

func (c ScalewayClient) GetUserOrganizations() (OrganizationsResponse, error)

GetUserOrganizations list all organizations associate with your account

func (ScalewayClient) GetUserToken

func (c ScalewayClient) GetUserToken(tokenID string) (TokenResponse, error)

GetUserToken lList an individual Token

func (ScalewayClient) GetUserTokens

func (c ScalewayClient) GetUserTokens() (TokensResponse, error)

GetUserTokens list all tokens associate with your account

func (ScalewayClient) GetVolume

func (c ScalewayClient) GetVolume(volumeID string) (VolumeResponse, error)

GetVolume list an individual volume volumeID is the volume unique identifier

func (ScalewayClient) GetVolumes

func (c ScalewayClient) GetVolumes() (VolumesResponse, error)

GetVolumes list all volumes associate with your account

func (ScalewayClient) ListServerActions

func (c ScalewayClient) ListServerActions(serverID string) (ServerActionsResponse, error)

ListServerActions list actions to be applied on a server serverID is the server unique identifier

func (ScalewayClient) PerformServerAction

func (c ScalewayClient) PerformServerAction(serverID string, action string) (TaskResponse, error)

PerformServerAction execute an action on a server serverID is the server unique identifier action is the action to execute

func (ScalewayClient) SetOrganizationFromToken

func (c ScalewayClient) SetOrganizationFromToken() error

SetOrganizationFromToken set Organization from Token if left empty

func (ScalewayClient) SetUserFromToken

func (c ScalewayClient) SetUserFromToken() error

SetUserFromToken set UserID from Token if left empty

func (ScalewayClient) String

func (c ScalewayClient) String() string

func (ScalewayClient) UpdateToken

func (c ScalewayClient) UpdateToken(tokenID string) (TokenResponse, error)

UpdateToken increase Token expiration time of 30 minutes tokenID is the token unique identifier

func (ScalewayClient) UploadPublicKey

func (c ScalewayClient) UploadPublicKey(keyPath string) (UserResponse, error)

UploadPublicKey update user SSH keys keyPath is the complete path of the SSH key

type Server

type Server struct {
	ID               string   `json:"id,omitempty"`
	Name             string   `json:"name,omitempty"`
	Organization     string   `json:"organization,omitempty"`
	CreationDate     string   `json:"creation_date,omitempty"`
	ModificationDate string   `json:"modification_date,omitempty"`
	Image            Image    `json:"image,omitempty"`
	PublicIP         PublicIP `json:"public_ip,omitempty"`
	State            string   `json:"state,omitempty"`
	Tags             []string `json:"tags,omitempty"`
}

Server represents a cloud server

func (Server) Display

func (s Server) Display()

Display log the server caracteristics

type ServerActionsResponse

type ServerActionsResponse struct {
	Actions []string
}

ServerActionsResponse represents JSON response of available actions for a server

type ServerResponse

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

ServerResponse represents JSON response of server

type ServersResponse

type ServersResponse struct {
	Servers []Server
}

ServersResponse represents JSON response of list of server

type Task

type Task struct {
	ID          string `json:"id,omitempty"`
	Description string `json:"description,omitempty"`
	HrefFrom    string `json:"href_from,omitempty"`
	Progress    int    `json:"progress,omitempty"`
	Status      string `json:"status,omitempty"`
}

Task represents an asynchronous task

type TaskResponse

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

TaskResponse represents a JSON response of task

type Token

type Token struct {
	ID       string `json:"id,omitempty"`
	UserID   string `json:"user_id,omitempty"`
	Creation string `json:"creation_date,omitempty"`
	Expires  string `json:"expires,omitempty"`
}

Token represents an identifier associated with your account. It is used to authenticate commands in the APIs

func (Token) Display

func (t Token) Display()

Display log the Token caracteristics

type TokenResponse

type TokenResponse struct {
	Token Token `json:"token,omitempty"`
}

TokenResponse represents JSON response of server for a token

type TokensResponse

type TokensResponse struct {
	Tokens []Token
}

TokensResponse represents JSON response of server for tokens

type User

type User struct {
	ID            string         `json:"id,omitempty"`
	Fullname      string         `json:"fullname,omitempty"`
	Firstname     string         `json:"firstname,omitempty"`
	Lastname      string         `json:"lastname,omitempty"`
	Email         string         `json:"email,omitempty"`
	PhoneNumber   string         `json:"phone_number,omitempty"`
	Organizations []Organization `json:"organizations,omitempty"`
	Roles         []Role         `json:"roles,omitempty"`
}

User represents a user account of the Scaleway cloud

func (User) Display

func (u User) Display()

Display log the User caracteristics

type UserResponse

type UserResponse struct {
	User User `json:"user,omitempty"`
}

UserResponse represents JSON response of server

type Volume

type Volume struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	Organization string `json:"organization,omitempty"`
	Type         string `json:"volume_type,omitempty"`
	Size         int64  `json:"size,omitempty"`
	Server       Server `json:"server,omitempty"`
}

Volume represents a disk

func (Volume) Display

func (v Volume) Display()

Display log the Volume caracteristics

type VolumeResponse

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

VolumeResponse represents JSON response of volume

type VolumesResponse

type VolumesResponse struct {
	Volumes []Volume
}

VolumesResponse represents a list of volumes in JSON

Jump to

Keyboard shortcuts

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