images

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(client *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r tasks.Result)

Create an image.

func Delete

func Delete(client *gcorecloud.ServiceClient, imageID string) (r tasks.Result)

Delete an image.

func ExtractImageIDFromTask

func ExtractImageIDFromTask(task *tasks.Task) (string, error)

func ExtractImagesInto

func ExtractImagesInto(r pagination.Page, v interface{}) error

func Upload added in v0.4.29

func Upload(client *gcorecloud.ServiceClient, opts UploadOptsBuilder) (r tasks.Result)

Upload accepts a UploadOpts struct and upload an image using the values provided.

Types

type CreateOpts

type CreateOpts struct {
	Name           string                `json:"name" required:"true" validate:"required"`
	HwMachineType  types.HwMachineType   `json:"hw_machine_type" validate:"required,enum"`
	SshKey         types.SshKeyType      `json:"ssh_key" validate:"required,enum"`
	OSType         types.OSType          `json:"os_type" validate:"required,enum"`
	IsBaremetal    *bool                 `json:"is_baremetal,omitempty"`
	HwFirmwareType types.HwFirmwareType  `json:"hw_firmware_type" validate:"required,enum"`
	Source         types.ImageSourceType `json:"source" validate:"required,enum"`
	VolumeID       string                `json:"volume_id" required:"true" validate:"required"`
}

CreateOpts represents options used to create an image.

func (CreateOpts) ToImageCreateMap

func (opts CreateOpts) ToImageCreateMap() (map[string]interface{}, error)

ToImageCreateMap builds a request body from CreateOpts.

func (CreateOpts) Validate

func (opts CreateOpts) Validate() error
    "cow_format": False,
    "hw_firmware_type": "bios",
    "hw_machine_type": "q35",
    "is_baremetal": False,
    "name": "image_name",
    "os_type": "linux",
    "ssh_key": "allow",
    "url": "http://mirror.noris.net/cirros/0.4.0/cirros-0.4.0-x86_64-disk.img",
    "metadata": {"key": "value"},
}

Validate

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToImageCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type GetResult

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

GetResult represents the result of a get operation. Call its Extract method to interpret it as a Image.

func Get

func Get(client *gcorecloud.ServiceClient, id string) (r GetResult)

Get retrieves a specific image based on its unique ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Image, error)

Extract is a function that accepts a result and extracts a image resource.

func (GetResult) ExtractInto

func (r GetResult) ExtractInto(v interface{}) error

type Image

type Image struct {
	ID            string                   `json:"id"`
	Name          string                   `json:"name"`
	Description   string                   `json:"description"`
	Status        string                   `json:"status"`
	Tags          []string                 `json:"tags"`
	Visibility    string                   `json:"visibility"`
	MinDisk       int                      `json:"min_disk"`
	MinRAM        int                      `json:"min_ram"`
	OsDistro      string                   `json:"os_distro"`
	OsVersion     string                   `json:"os_version"`
	DisplayOrder  int                      `json:"display_order"`
	CreatedAt     gcorecloud.JSONRFC3339Z  `json:"created_at"`
	UpdatedAt     *gcorecloud.JSONRFC3339Z `json:"updated_at"`
	Size          int                      `json:"size"`
	CreatorTaskID *string                  `json:"creator_task_id"`
	TaskID        *string                  `json:"task_id"`
	Region        string                   `json:"region"`
	DiskFormat    string                   `json:"disk_format"`
	Metadata      []metadata.Metadata      `json:"metadata_detailed"`
}

func ExtractImages

func ExtractImages(r pagination.Page) ([]Image, error)

ExtractImages accepts a Page struct, specifically a ImagePage struct, and extracts the elements into a slice of image structs. In other words, a generic collection is mapped into a relevant slice.

func ListAll

func ListAll(client *gcorecloud.ServiceClient, opts ListOptsBuilder) ([]Image, error)

type ImagePage

type ImagePage struct {
	pagination.LinkedPageBase
}

ImagePage is the page returned by a pager when traversing over a collection of images.

func (ImagePage) IsEmpty

func (r ImagePage) IsEmpty() (bool, error)

IsEmpty checks whether a ImagePage struct is empty.

func (ImagePage) NextPageURL

func (r ImagePage) NextPageURL() (string, error)

NextPageURL is invoked when a paginated collection of images has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.

type ImageTaskResult

type ImageTaskResult struct {
	Images []string `json:"images"`
}

type ListOpts

type ListOpts struct {
	Private    bool              `q:"private" validate:"omitempty"`
	Visibility types.Visibility  `q:"visibility" validate:"omitempty"`
	MetadataK  string            `q:"metadata_k" validate:"omitempty"`
	MetadataKV map[string]string `q:"metadata_kv" validate:"omitempty"`
}

ListOpts allows the filtering and sorting of paginated collections through the API.

func (ListOpts) ToImageListQuery

func (opts ListOpts) ToImageListQuery() (string, error)

ToImageListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToImageListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type UpdateOpts added in v0.4.29

type UpdateOpts struct {
	HwMachineType  types.HwMachineType  `json:"hw_machine_type" validate:"required,enum"`
	SshKey         types.SshKeyType     `json:"ssh_key" validate:"required,enum"`
	Name           string               `json:"name" required:"true"`
	OSType         types.OSType         `json:"os_type" validate:"required,enum"`
	IsBaremetal    *bool                `json:"is_baremetal,omitempty"`
	HwFirmwareType types.HwFirmwareType `json:"hw_firmware_type" validate:"required,enum"`
}

UpdateOpts represents options used to create an image.

func (UpdateOpts) ToImageUpdateMap added in v0.4.29

func (opts UpdateOpts) ToImageUpdateMap() (map[string]interface{}, error)

ToImageUpdateMap builds a request body from UpdateOpts.

func (UpdateOpts) Validate added in v0.4.29

func (opts UpdateOpts) Validate() error

Validate

type UpdateOptsBuilder added in v0.4.29

type UpdateOptsBuilder interface {
	ToImageUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult added in v0.4.29

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

UpdatyResult represents the result of a update operation. Call its Extract method to interpret it as a Image.

func Update added in v0.4.29

func Update(client *gcorecloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update accepts a UpdateOpts struct and updates an existing image using the values provided.

func (UpdateResult) Extract added in v0.4.29

func (r UpdateResult) Extract() (*Image, error)

Extract is a function that accepts a result and extracts a image resource.

func (UpdateResult) ExtractInto added in v0.4.29

func (r UpdateResult) ExtractInto(v interface{}) error

type UploadOpts added in v0.4.29

type UploadOpts struct {
	OsVersion      string               `json:"os_version,omitempty"`
	HwMachineType  types.HwMachineType  `json:"hw_machine_type" validate:"required,enum"`
	SshKey         types.SshKeyType     `json:"ssh_key" validate:"required,enum"`
	Name           string               `json:"name" required:"true" validate:"required"`
	OsDistro       string               `json:"os_distro,omitempty"`
	OSType         types.OSType         `json:"os_type" validate:"required,enum"`
	URL            string               `json:"url" required:"true" validate:"required,url"`
	IsBaremetal    *bool                `json:"is_baremetal,omitempty"`
	HwFirmwareType types.HwFirmwareType `json:"hw_firmware_type" validate:"required,enum"`
	CowFormat      bool                 `json:"cow_format"`
	Metadata       map[string]string    `json:"metadata,omitempty"`
}

UploadOpts represents options used to upload an image.

func (UploadOpts) ToImageUploadMap added in v0.4.29

func (opts UploadOpts) ToImageUploadMap() (map[string]interface{}, error)

ToImageUploadMap builds a request body from UploadOpts.

func (UploadOpts) Validate added in v0.4.29

func (opts UploadOpts) Validate() error

Validate

type UploadOptsBuilder added in v0.4.29

type UploadOptsBuilder interface {
	ToImageUploadMap() (map[string]interface{}, error)
}

UploadOptsBuilder allows extensions to add additional parameters to the Upload request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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