cloudapi

package
v0.0.0-...-ec8b350 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAllowed is returned when the request's method is not allowed
	ErrNotAllowed = &ErrorResponse{
		http.StatusMethodNotAllowed,
		"Method is not allowed",
		"text/plain; charset=UTF-8",
		"MethodNotAllowedError",
		nil,
		nil,
	}

	// ErrNotFound is returned when the requested resource is not found
	ErrNotFound = &ErrorResponse{
		http.StatusNotFound,
		"Resource Not Found",
		"text/plain; charset=UTF-8",
		"NotFoundError",
		nil,
		nil,
	}

	// ErrBadRequest is returned when the request is malformed or incorrect
	ErrBadRequest = &ErrorResponse{
		http.StatusBadRequest,
		"Malformed request url",
		"text/plain; charset=UTF-8",
		"BadRequestError",
		nil,
		nil,
	}
)

Functions

This section is empty.

Types

type CloudAPI

type CloudAPI struct {
	localservices.ServiceInstance
	// contains filtered or unexported fields
}

CloudAPI is the API test double

func New

func New(serviceURL, userAccount string) *CloudAPI

New makes a new *CloudAPI service with the given information

func (*CloudAPI) AddMachineTags

func (c *CloudAPI) AddMachineTags(machineID string, tags map[string]string) (map[string]string, error)

AddMachineTags adds additional tags to the specified machine. This API lets you append new tags, not overwrite existing tags.

func (*CloudAPI) AddNIC

func (c *CloudAPI) AddNIC(machineID, networkID string) (*cloudapi.NIC, error)

func (*CloudAPI) CountMachines

func (c *CloudAPI) CountMachines() (int, error)

CountMachines returns a count of machines the double knows about

func (*CloudAPI) CreateFabricNetwork

func (c *CloudAPI) CreateFabricNetwork(vlanID int16, opts cloudapi.CreateFabricNetworkOpts) (*cloudapi.FabricNetwork, error)

CreateFabricNetwork creates a new fabric network

func (*CloudAPI) CreateFabricVLAN

func (c *CloudAPI) CreateFabricVLAN(vlan cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error)

CreateFabricVLAN creates a new VLAN with the specified options

func (*CloudAPI) CreateFirewallRule

func (c *CloudAPI) CreateFirewallRule(rule string, enabled bool) (*cloudapi.FirewallRule, error)

CreateFirewallRule creates a new firewall rule and returns it

func (*CloudAPI) CreateKey

func (c *CloudAPI) CreateKey(keyName, key string) (*cloudapi.Key, error)

CreateKey creates a new key in the double

func (*CloudAPI) CreateMachine

func (c *CloudAPI) CreateMachine(name, pkg, image string, networks []string, metadata, tags map[string]string) (*cloudapi.Machine, error)

CreateMachine creates a new machine in the double. It will be running immediately.

func (*CloudAPI) DeleteAllMachineMetadata

func (c *CloudAPI) DeleteAllMachineMetadata(machineID string) error

DeleteAllMachineMetadata deletes all metadata keys from the specified machine.

func (*CloudAPI) DeleteFabricNetwork

func (c *CloudAPI) DeleteFabricNetwork(vlanID int16, networkID string) error

DeleteFabricNetwork deletes an existing fabric network

func (*CloudAPI) DeleteFabricVLAN

func (c *CloudAPI) DeleteFabricVLAN(vlanID int16) error

DeleteFabricVLAN delets a given VLAN as specified by ID

func (*CloudAPI) DeleteFirewallRule

func (c *CloudAPI) DeleteFirewallRule(fwRuleID string) error

DeleteFirewallRule deletes the given firewall rule

func (*CloudAPI) DeleteKey

func (c *CloudAPI) DeleteKey(keyName string) error

DeleteKey deletes an existing key from the double

func (*CloudAPI) DeleteMachine

func (c *CloudAPI) DeleteMachine(machineID string) error

DeleteMachine deletes the given machine from the double

func (*CloudAPI) DeleteMachineMetadata

func (c *CloudAPI) DeleteMachineMetadata(machineID string, key string) error

DeleteMachineMetadata deletes a single metadata key from the specified machine

func (*CloudAPI) DeleteMachineTag

func (c *CloudAPI) DeleteMachineTag(machineID, tagKey string) error

func (*CloudAPI) DeleteMachineTags

func (c *CloudAPI) DeleteMachineTags(machineID string) error

DeleteMachineTags deletes all tags from the specified machine.

func (*CloudAPI) DisableFirewallMachine

func (c *CloudAPI) DisableFirewallMachine(machineID string) error

DisableFirewallMachine disables the firewall for the given machine

func (*CloudAPI) DisableFirewallRule

func (c *CloudAPI) DisableFirewallRule(fwRuleID string) (*cloudapi.FirewallRule, error)

DisableFirewallRule disables the given firewall rule

func (*CloudAPI) EnableFirewallMachine

func (c *CloudAPI) EnableFirewallMachine(machineID string) error

EnableFirewallMachine enables the firewall for the given machine

func (*CloudAPI) EnableFirewallRule

func (c *CloudAPI) EnableFirewallRule(fwRuleID string) (*cloudapi.FirewallRule, error)

EnableFirewallRule enables the given firewall rule

func (*CloudAPI) GetFabricNetwork

func (c *CloudAPI) GetFabricNetwork(vlanID int16, networkID string) (*cloudapi.FabricNetwork, error)

GetFabricNetwork gets a single network by VLAN and Network IDs

func (*CloudAPI) GetFabricVLAN

func (c *CloudAPI) GetFabricVLAN(vlanID int16) (*cloudapi.FabricVLAN, error)

GetFabricVLAN retrieves a single VLAN by ID

func (*CloudAPI) GetFirewallRule

func (c *CloudAPI) GetFirewallRule(fwRuleID string) (*cloudapi.FirewallRule, error)

GetFirewallRule gets a single firewall rule by ID

func (*CloudAPI) GetImage

func (c *CloudAPI) GetImage(imageID string) (*cloudapi.Image, error)

GetImage gets a single image by name from the double

func (*CloudAPI) GetKey

func (c *CloudAPI) GetKey(keyName string) (*cloudapi.Key, error)

GetKey gets a single key from the double by name

func (*CloudAPI) GetMachine

func (c *CloudAPI) GetMachine(machineID string) (*cloudapi.Machine, error)

GetMachine gets a single machine by ID from the double

func (*CloudAPI) GetMachineMetadata

func (c *CloudAPI) GetMachineMetadata(machineID string) (map[string]string, error)

GetMachineMetadata returns the complete set of metadata associated with the specified machine.

func (*CloudAPI) GetMachineTag

func (c *CloudAPI) GetMachineTag(machineID, tagKey string) (string, error)

GetMachineTag returns the value for a single tag on the specified machine.

func (*CloudAPI) GetNIC

func (c *CloudAPI) GetNIC(machineID, MAC string) (*cloudapi.NIC, error)

func (*CloudAPI) GetNetwork

func (c *CloudAPI) GetNetwork(networkID string) (*cloudapi.Network, error)

GetNetwork gets a network by ID

func (*CloudAPI) GetPackage

func (c *CloudAPI) GetPackage(packageName string) (*cloudapi.Package, error)

GetPackage gets a single package in the double

func (*CloudAPI) ListFabricNetworks

func (c *CloudAPI) ListFabricNetworks(vlanID int16) ([]cloudapi.FabricNetwork, error)

ListFabricNetworks lists the networks inside the given VLAN

func (*CloudAPI) ListFabricVLANs

func (c *CloudAPI) ListFabricVLANs() ([]cloudapi.FabricVLAN, error)

ListFabricVLANs lists VLANs

func (*CloudAPI) ListFirewallRuleMachines

func (c *CloudAPI) ListFirewallRuleMachines(fwRuleID string) ([]*cloudapi.Machine, error)

ListFirewallRuleMachines should list the machines that are affected by a given firewall rule. In this double, it just returns all the machines.

func (*CloudAPI) ListFirewallRules

func (c *CloudAPI) ListFirewallRules() ([]*cloudapi.FirewallRule, error)

ListFirewallRules gets a list of firewall rules from the double

func (*CloudAPI) ListImages

func (c *CloudAPI) ListImages(filters map[string]string) ([]cloudapi.Image, error)

ListImages returns a list of images in the double

func (*CloudAPI) ListKeys

func (c *CloudAPI) ListKeys() ([]cloudapi.Key, error)

ListKeys lists keys in the double

func (*CloudAPI) ListMachineFirewallRules

func (c *CloudAPI) ListMachineFirewallRules(machineID string) ([]*cloudapi.FirewallRule, error)

ListMachineFirewallRules returns a list of firewall rules that apply to the given machine

func (*CloudAPI) ListMachineTags

func (c *CloudAPI) ListMachineTags(machineID string) (map[string]string, error)

ListMachineTags returns the complete set of tags associated with the specified machine.

func (*CloudAPI) ListMachines

func (c *CloudAPI) ListMachines(filters map[string]string) ([]*cloudapi.Machine, error)

ListMachines returns a list of machines in the double

func (*CloudAPI) ListNICs

func (c *CloudAPI) ListNICs(machineID string) ([]cloudapi.NIC, error)

func (*CloudAPI) ListNetworks

func (c *CloudAPI) ListNetworks() ([]cloudapi.Network, error)

ListNetworks returns a list of networks that the double knows about

func (*CloudAPI) ListPackages

func (c *CloudAPI) ListPackages(filters map[string]string) ([]cloudapi.Package, error)

ListPackages lists packages in the double

func (*CloudAPI) RebootMachine

func (c *CloudAPI) RebootMachine(machineID string) error

RebootMachine changes a machine's state to "running" and updates Updated

func (*CloudAPI) RemoveNIC

func (c *CloudAPI) RemoveNIC(machineID, MAC string) error

func (*CloudAPI) RenameMachine

func (c *CloudAPI) RenameMachine(machineID, newName string) error

RenameMachine changes a machine's name

func (*CloudAPI) ReplaceMachineTags

func (c *CloudAPI) ReplaceMachineTags(machineID string, tags map[string]string) (map[string]string, error)

ReplaceMachineTags replaces existing tags for the specified machine. This API lets you overwrite existing tags, not append to existing tags.

func (*CloudAPI) ResizeMachine

func (c *CloudAPI) ResizeMachine(machineID, packageName string) error

ResizeMachine changes a machine's package to a new size. Unlike the real API, this method lets you downsize machines.

func (*CloudAPI) SetupHTTP

func (c *CloudAPI) SetupHTTP(mux *httprouter.Router)

SetupHTTP attaches all the needed handlers to provide the HTTP API.

func (*CloudAPI) StartMachine

func (c *CloudAPI) StartMachine(machineID string) error

StartMachine changes a machine's state to "running"

func (*CloudAPI) StopMachine

func (c *CloudAPI) StopMachine(machineID string) error

StopMachine changes a machine's status to "stopped"

func (*CloudAPI) UpdateFabricVLAN

func (c *CloudAPI) UpdateFabricVLAN(new cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error)

UpdateFabricVLAN updates a given VLAN with new fields

func (*CloudAPI) UpdateFirewallRule

func (c *CloudAPI) UpdateFirewallRule(fwRuleID, rule string, enabled bool) (*cloudapi.FirewallRule, error)

UpdateFirewallRule makes changes to a given firewall rule

func (*CloudAPI) UpdateMachineMetadata

func (c *CloudAPI) UpdateMachineMetadata(machineID string, metadata map[string]string) (map[string]string, error)

UpdateMachineMetadata updates the metadata for a given machine. Any metadata keys passed in here are created if they do not exist, and overwritten if they do.

type ErrorResponse

type ErrorResponse struct {
	Code int
	Body string
	// contains filtered or unexported fields
}

ErrorResponse defines a single HTTP error response.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

func (*ErrorResponse) ServeHTTP

func (e *ErrorResponse) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MethodNotAllowed

type MethodNotAllowed struct{}

func (MethodNotAllowed) ServeHTTP

func (MethodNotAllowed) ServeHTTP(w http.ResponseWriter, r *http.Request)

type NotFound

type NotFound struct{}

func (NotFound) ServeHTTP

func (NotFound) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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