api

package
Version: v0.0.0-...-194264a Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2018 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// PoolsV1 is the content-type string for v1 of our pools resource
	PoolsV1 = "x.ciao.pools.v1"

	// ExternalIPsV1 is the content-type string for v1 of our external-ips resource
	ExternalIPsV1 = "x.ciao.external-ips.v1"

	// WorkloadsV1 is the content-type string for v1 of our workloads resource
	WorkloadsV1 = "x.ciao.workloads.v1"

	// TenantsV1 is the content-type string for v1 of our tenants resource
	TenantsV1 = "x.ciao.tenants.v1"

	// NodeV1 is the content-type string for v1 of our node resource
	NodeV1 = "x.ciao.node.v1"

	// ImagesV1 is the content-type string for v1 of our images resource
	ImagesV1 = "x.ciao.images.v1"

	// VolumesV1 is the content-type string for v1 of our volumes resource
	VolumesV1 = "x.ciao.volumes.v1"

	// InstancesV1 is the content-type string for v1 of our intances resource
	InstancesV1 = "x.ciao.instances.v1"
)
View Source
const Port = 8889

Port is the default port number for the ciao API.

Variables

View Source
var (
	// ErrNoImage is returned when an image is not found.
	ErrNoImage = errors.New("Image not found")

	// ErrImageSaving is returned when an image is being uploaded.
	ErrImageSaving = errors.New("Image being uploaded")

	// ErrBadUUID is returned when an invalid UUID is specified
	ErrBadUUID = errors.New("Bad UUID")

	// ErrAlreadyExists is returned when an attempt is made to add
	// an image with a UUID that already exists.
	ErrAlreadyExists = errors.New("Already Exists")

	// ErrQuota is returned when the tenant exceeds its quota
	ErrQuota = errors.New("Tenant over quota")
)
View Source
var (
	//ErrInstanceNotFound is used if instance not found
	ErrInstanceNotFound = errors.New("Instance not found")

	// ErrVolumeNotAvailable returned if volume not available
	ErrVolumeNotAvailable = errors.New("Volume not available")

	// ErrVolumeOwner returned if permission denied
	ErrVolumeOwner = errors.New("You are not volume owner")

	// ErrVolumeNotAttached returned if volume not attached
	ErrVolumeNotAttached = errors.New("Volume not attached")
)

Functions

func Routes

func Routes(config Config, r *mux.Router) *mux.Router

Routes returns the supported ciao API endpoints. A plain application/json request will return v1 of the resource since we only have one version of this api so far, that means most routes will match both json as well as our custom content type.

Types

type Config

type Config struct {
	URL         string
	CiaoService Service
}

Config is used to setup the Context for the ciao API.

type Context

type Context struct {
	URL string
	Service
}

Context is used to provide the services and current URL to the handlers.

type CreateImageRequest

type CreateImageRequest struct {
	Name       string           `json:"name,omitempty"`
	ID         string           `json:"id,omitempty"`
	Visibility types.Visibility `json:"visibility,omitempty"`
}

CreateImageRequest contains information for a create image request.

type CreateServerRequest

type CreateServerRequest struct {
	Server struct {
		ID           string            `json:"id"`
		Name         string            `json:"name"`
		Image        string            `json:"imageRef"`
		WorkloadID   string            `json:"workload_id"`
		MaxInstances int               `json:"max_count"`
		MinInstances int               `json:"min_count"`
		Metadata     map[string]string `json:"metadata,omitempty"`
	} `json:"server"`
}

CreateServerRequest contains the details needed to start new instance(s)

type ErrorImage

type ErrorImage error

ErrorImage defines all possible image handling errors

type HTTPErrorData

type HTTPErrorData struct {
	Code    int    `json:"code"`
	Name    string `json:"name"`
	Message string `json:"message"`
}

HTTPErrorData represents the HTTP response body for a compute API request error.

type HTTPReturnErrorCode

type HTTPReturnErrorCode struct {
	Error HTTPErrorData `json:"error"`
}

HTTPReturnErrorCode represents the unmarshalled version for Return codes when a API call is made and you need to return explicit data of the call as OpenStack format http://developer.openstack.org/api-guide/compute/faults.html

type Handler

type Handler struct {
	*Context
	Handler    func(*Context, http.ResponseWriter, *http.Request) (Response, error)
	Privileged bool
}

Handler is a custom handler for the compute APIs. This custom handler allows us to more cleanly return an error and response, and pass some package level context into the handler.

func (Handler) ServeHTTP

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

type PrivateAddresses

type PrivateAddresses struct {
	Addr    string `json:"addr"`
	MacAddr string `json:"mac_addr"`
}

PrivateAddresses contains information about a single instance network interface.

type RequestedVolume

type RequestedVolume struct {
	Size        int    `json:"size"`
	SourceVolID string `json:"source_volid,omitempty"`
	Description string `json:"description,omitempty"`
	Name        string `json:"name,omitempty"`
	ImageRef    string `json:"imageRef,omitempty"`
	Internal    bool   `json:"-"`
}

RequestedVolume contains information about a volume to be created.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response contains the http status and any response struct to be marshalled.

type Server

type Server struct {
	Server ServerDetails `json:"server"`
}

Server holds a single server's worth of details.

type ServerDetails

type ServerDetails struct {
	PrivateAddresses []PrivateAddresses `json:"private_addresses"`
	Created          time.Time          `json:"created"`
	WorkloadID       string             `json:"workload_id"`
	NodeID           string             `json:"node_id"`
	ID               string             `json:"id"`
	Name             string             `json:"name"`
	Volumes          []string           `json:"volumes"`
	Status           string             `json:"status"`
	TenantID         string             `json:"tenant_id"`
	SSHIP            string             `json:"ssh_ip"`
	SSHPort          int                `json:"ssh_port"`
}

ServerDetails contains information about a specific instance.

type Servers

type Servers struct {
	TotalServers int             `json:"total_servers"`
	Servers      []ServerDetails `json:"servers"`
}

Servers holds multiple servers including a count

type Service

type Service interface {
	AddPool(name string, subnet *string, ips []string) (types.Pool, error)
	ListPools() ([]types.Pool, error)
	ShowPool(id string) (types.Pool, error)
	DeletePool(id string) error
	AddAddress(poolID string, subnet *string, IPs []string) error
	RemoveAddress(poolID string, subnetID *string, IPID *string) error
	ListMappedAddresses(tenantID *string) []types.MappedIP
	MapAddress(tenantID string, poolName *string, instanceID string) error
	UnMapAddress(ID string) error
	CreateWorkload(req types.Workload) (types.Workload, error)
	DeleteWorkload(tenantID string, workloadID string) error
	ShowWorkload(tenantID string, workloadID string) (types.Workload, error)
	ListWorkloads(tenantID string) ([]types.Workload, error)
	ListQuotas(tenantID string) []types.QuotaDetails
	UpdateQuotas(tenantID string, qds []types.QuotaDetails) error
	EvacuateNode(nodeID string) error
	RestoreNode(nodeID string) error
	ListTenants() ([]types.TenantSummary, error)
	ShowTenant(ID string) (types.TenantConfig, error)
	PatchTenant(ID string, patch []byte) error
	CreateTenant(ID string, config types.TenantConfig) (types.TenantSummary, error)
	DeleteTenant(ID string) error
	CreateImage(string, CreateImageRequest) (types.Image, error)
	UploadImage(string, string, io.Reader) error
	ListImages(string) ([]types.Image, error)
	GetImage(string, string) (types.Image, error)
	DeleteImage(string, string) error
	CreateVolume(tenant string, req RequestedVolume) (types.Volume, error)
	DeleteVolume(tenant string, volume string) error
	AttachVolume(tenant string, volume string, instance string, mountpoint string) error
	DetachVolume(tenant string, volume string, attachment string) error
	ListVolumesDetail(tenant string) ([]types.Volume, error)
	ShowVolumeDetails(tenant string, volume string) (types.Volume, error)
	CreateServer(string, CreateServerRequest) (interface{}, error)
	ListServersDetail(tenant string) ([]ServerDetails, error)
	ShowServerDetails(tenant string, server string) (Server, error)
	DeleteServer(tenant string, server string) error
	StartServer(tenant string, server string) error
	StopServer(tenant string, server string) error
}

Service is an interface which must be implemented by the ciao API context.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL