image

package
Version: v0.0.0-...-53c686c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const APIPort = 9292

APIPort is the standard OpenStack Image port

Variables

This section is empty.

Functions

func Routes

func Routes(config APIConfig) *mux.Router

Routes provides gorilla mux routes for the supported endpoints.

Types

type APIConfig

type APIConfig struct {
	Port         int     // the https port of the block api service
	ImageService Service // the service interface
}

APIConfig contains information needed to start the block api service.

type APIHandler

type APIHandler struct {
	*Context
	Handler func(*Context, http.ResponseWriter, *http.Request) (APIResponse, error)
}

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

func (APIHandler) ServeHTTP

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

ServeHTTP satisfies the http Handler interface. It wraps our api response in json as well.

type APIResponse

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

APIResponse is returned from the API handlers.

type ContainerFormat

type ContainerFormat string

ContainerFormat defines the acceptable container format strings.

const (
	// Bare is the only format we support right now.
	Bare ContainerFormat = "bare"
)

type Context

type Context struct {
	Service
	// contains filtered or unexported fields
}

Context contains data and interfaces that the image api will need. TBD: do we really need this, or is just a service interface sufficient?

type CreateImageRequest

type CreateImageRequest struct {
	Name            string          `json:"name,omitempty"`
	ID              string          `json:"id,omitempty"`
	Visibility      Visibility      `json:"visibility,omitempty"`
	Tags            []string        `json:"tags,omitempty"`
	ContainerFormat ContainerFormat `json:"container_format,omitempty"`
	DiskFormat      DiskFormat      `json:"disk_format,omitempty"`
	MinDisk         int             `json:"min_disk,omitempty"`
	MinRAM          int             `json:"min_ram,omitempty"`
	Protected       bool            `json:"protected,omitempty"`
	Properties      interface{}     `json:"properties,omitempty"`
}

CreateImageRequest contains information for a create image request. http://developer.openstack.org/api-ref-image-v2.html#createImage-v2

type DefaultResponse

type DefaultResponse struct {
	Status          Status           `json:"status"`
	ContainerFormat *ContainerFormat `json:"container_format"`
	MinRAM          *int             `json:"min_ram"`
	UpdatedAt       *time.Time       `json:"updated_at"`
	Owner           *string          `json:"owner"`
	MinDisk         *int             `json:"min_disk"`
	Tags            []string         `json:"tags"`
	Locations       []string         `json:"locations"`
	Visibility      Visibility       `json:"visibility"`
	ID              string           `json:"id"`
	Size            *int             `json:"size"`
	VirtualSize     *int             `json:"virtual_size"`
	Name            *string          `json:"name"`
	CheckSum        *string          `json:"checksum"`
	CreatedAt       time.Time        `json:"created_at"`
	DiskFormat      DiskFormat       `json:"disk_format"`
	Properties      interface{}      `json:"properties"`
	Protected       bool             `json:"protected"`
	Self            string           `json:"self"`
	File            string           `json:"file"`
	Schema          string           `json:"schema"`
}

DefaultResponse contains information about an image http://developer.openstack.org/api-ref-image-v2.html#createImage-v2

type DiskFormat

type DiskFormat string

DiskFormat defines the valid values for the disk_format string

const (
	// Raw
	Raw DiskFormat = "raw"

	// QCow
	QCow DiskFormat = "qcow2"

	// ISO
	ISO DiskFormat = "iso"
)

we support the following disk formats

type Link struct {
	Href string `json:"href"`
	Type string `json:"type,omitempty"`
	Rel  string `json:"rel,omitempty"`
}

Link is used by the API to create the link json strings.

type ListImagesResponse

type ListImagesResponse struct {
	Images []DefaultResponse `json:"images"`
	Schema string            `json:"schema"`
	First  string            `json:"first"`
}

ListImagesResponse contains the list of all images that have been created. http://developer.openstack.org/api-ref-image-v2.html#listImages-v2

type Service

type Service interface {
	CreateImage(CreateImageRequest) (DefaultResponse, error)
	UploadImage(string, io.Reader) (UploadImageResponse, error)
	ListImages() ([]DefaultResponse, error)
	GetImage(string) (DefaultResponse, error)
}

Service is the interface that the api requires in order to get information needed to implement the image endpoints.

type Status

type Status string

Status defines the possible states for an image

const (
	// Queued means that the image service reserved an image ID
	// for the image but did not yet upload any image data.
	Queued Status = "queued"

	// Saving means that the image service is currently uploading
	// the raw data for the image.
	Saving Status = "saving"

	// Active means that the image is active and fully available
	// in the image service.
	Active Status = "active"

	// Killed means that an image data upload error occurred.
	Killed Status = "killed"

	// Deleted means that the image service retains information
	// about the image but the image is no longer available for use.
	Deleted Status = "deleted"

	// PendingDelete is similar to the deleted status.
	// An image in this state is not recoverable.
	PendingDelete Status = "pending_delete"
)

type UploadImageResponse

type UploadImageResponse struct {
	ImageID string `json:"image_id"`
}

UploadImageResponse contains the UUID of the image which content got uploaded http://developer.openstack.org/api-ref-image-v2.html#storeImageFile-v2

type Version

type Version struct {
	Status VersionStatus `json:"status"`
	ID     string        `json:"id"`
	Links  []Link        `json:"links"`
}

Version is used by the API to create the version json strings

type VersionStatus

type VersionStatus string

VersionStatus defines whether a reported version is supported or not.

const (
	// Deprecated indicates the api deprecates the spec version.
	Deprecated VersionStatus = "DEPRECATED"

	// Supported indicates a spec version is supported by the api
	Supported VersionStatus = "SUPPORTED"

	// Current indicates the current spec version of the api
	// TBD: can this be eliminated? do we need both supported & current?
	Current VersionStatus = "CURRENT"
)

type Versions

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

Versions creates multiple version json strings

type Visibility

type Visibility string

Visibility defines whether an image is per tenant or public.

const (
	// Public indicates that the image can be used by anyone.
	Public Visibility = "public"

	// Private indicates that the image is only available to a tenant.
	Private Visibility = "private"
)

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