packngo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2017 License: BSD-3-Clause, MIT Imports: 11 Imported by: 288

README

packngo

Packet Go Api Client

Committing

Before committing, it's a good idea to run gofmt -w *.go. (gofmt)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool allocates a new bool value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int allocates a new int32 value to store v and returns a pointer to it, but unlike Int32 its argument value is an int.

func StreamToString

func StreamToString(stream io.Reader) string

StreamToString converts a reader to a string

func String

func String(v string) *string

String allocates a new string value to store v and returns a pointer to it

func Stringify

func Stringify(message interface{}) string

Stringify creates a string representation of the provided message

Types

type Address

type Address struct {
	ID string `json:"id,omitempty"`
}

Address - the physical address of the facility

func (Address) String

func (a Address) String() string

type Attachment

type Attachment struct {
	ID   string `json:"id"`
	Href string `json:"href"`
}

Attachment used to execute actions on volume

type Client

type Client struct {
	BaseURL *url.URL

	UserAgent     string
	ConsumerToken string
	APIKey        string

	RateLimit Rate

	// Packet Api Objects
	Plans            PlanService
	Users            UserService
	Emails           EmailService
	SSHKeys          SSHKeyService
	Devices          DeviceService
	Projects         ProjectService
	Facilities       FacilityService
	OperatingSystems OSService
	Ips              IPService
	IpReservations   IPReservationService
	Volumes          VolumeService
	// contains filtered or unexported fields
}

Client is the base API Client

func NewClient

func NewClient(consumerToken string, apiKey string, httpClient *http.Client) *Client

NewClient initializes and returns a Client, use this to get an API Client to operate on N.B.: Packet's API certificate requires Go 1.5+ to successfully parse. If you are using an older version of Go, pass in a custom http.Client with a custom TLS configuration that sets "InsecureSkipVerify" to "true"

func NewClientWithBaseURL

func NewClientWithBaseURL(consumerToken string, apiKey string, httpClient *http.Client, apiBaseURL string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do executes the http request

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest inits a new http request with the proper headers

type Cpus

type Cpus struct {
	Count int    `json:"count,omitempty"`
	Type  string `json:"type,omitempty"`
}

Cpus - the CPU config details for specs on a plan

func (Cpus) String

func (c Cpus) String() string

type Device

type Device struct {
	ID            string       `json:"id"`
	Href          string       `json:"href,omitempty"`
	Hostname      string       `json:"hostname,omitempty"`
	State         string       `json:"state,omitempty"`
	Created       string       `json:"created_at,omitempty"`
	Updated       string       `json:"updated_at,omitempty"`
	Locked        bool         `json:"locked,omitempty"`
	BillingCycle  string       `json:"billing_cycle,omitempty"`
	Tags          []string     `json:"tags,omitempty"`
	Network       []*IPAddress `json:"ip_addresses"`
	OS            *OS          `json:"operating_system,omitempty"`
	Plan          *Plan        `json:"plan,omitempty"`
	Facility      *Facility    `json:"facility,omitempty"`
	Project       *Project     `json:"project,omitempty"`
	ProvisionPer  float32      `json:"provisioning_percentage,omitempty"`
	UserData      string       `json:"userdata",omitempty`
	IPXEScriptUrl string       `json:"ipxe_script_url,omitempty"`
	AlwaysPXE     bool         `json:"always_pxe,omitempty"`
}

Device represents a Packet device

func (Device) String

func (d Device) String() string

type DeviceActionRequest

type DeviceActionRequest struct {
	Type string `json:"type"`
}

DeviceActionRequest type used to execute actions on devices

func (DeviceActionRequest) String

func (d DeviceActionRequest) String() string

type DeviceCreateRequest

type DeviceCreateRequest struct {
	HostName             string   `json:"hostname"`
	Plan                 string   `json:"plan"`
	Facility             string   `json:"facility"`
	OS                   string   `json:"operating_system"`
	BillingCycle         string   `json:"billing_cycle"`
	ProjectID            string   `json:"project_id"`
	UserData             string   `json:"userdata"`
	Tags                 []string `json:"tags"`
	IPXEScriptUrl        string   `json:"ipxe_script_url,omitempty"`
	PublicIPv4SubnetSize int      `json:"public_ipv4_subnet_size,omitempty"`
	AlwaysPXE            bool     `json:"always_pxe,omitempty"`
}

DeviceCreateRequest type used to create a Packet device

func (DeviceCreateRequest) String

func (d DeviceCreateRequest) String() string

type DeviceService

type DeviceService interface {
	List(ProjectID string) ([]Device, *Response, error)
	Get(string) (*Device, *Response, error)
	Create(*DeviceCreateRequest) (*Device, *Response, error)
	Update(string, *DeviceUpdateRequest) (*Device, *Response, error)
	Delete(string) (*Response, error)
	Reboot(string) (*Response, error)
	PowerOff(string) (*Response, error)
	PowerOn(string) (*Response, error)
	Lock(string) (*Response, error)
	Unlock(string) (*Response, error)
}

DeviceService interface defines available device methods

type DeviceServiceOp

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

DeviceServiceOp implements DeviceService

func (*DeviceServiceOp) Create

func (s *DeviceServiceOp) Create(createRequest *DeviceCreateRequest) (*Device, *Response, error)

Create creates a new device

func (*DeviceServiceOp) Delete

func (s *DeviceServiceOp) Delete(deviceID string) (*Response, error)

Delete deletes a device

func (*DeviceServiceOp) Get

func (s *DeviceServiceOp) Get(deviceID string) (*Device, *Response, error)

Get returns a device by id

func (*DeviceServiceOp) List

func (s *DeviceServiceOp) List(projectID string) ([]Device, *Response, error)

List returns devices on a project

func (*DeviceServiceOp) Lock

func (s *DeviceServiceOp) Lock(deviceID string) (*Response, error)

Lock sets a device to "locked"

func (*DeviceServiceOp) PowerOff

func (s *DeviceServiceOp) PowerOff(deviceID string) (*Response, error)

PowerOff powers on a device

func (*DeviceServiceOp) PowerOn

func (s *DeviceServiceOp) PowerOn(deviceID string) (*Response, error)

PowerOn powers on a device

func (*DeviceServiceOp) Reboot

func (s *DeviceServiceOp) Reboot(deviceID string) (*Response, error)

Reboot reboots on a device

func (*DeviceServiceOp) Unlock

func (s *DeviceServiceOp) Unlock(deviceID string) (*Response, error)

Unlock sets a device to "locked"

func (*DeviceServiceOp) Update

func (s *DeviceServiceOp) Update(deviceID string, updateRequest *DeviceUpdateRequest) (*Device, *Response, error)

Update updates an existing device

type DeviceUpdateRequest

type DeviceUpdateRequest struct {
	HostName      string   `json:"hostname"`
	Description   string   `json:"description"`
	UserData      string   `json:"userdata"`
	Locked        bool     `json:"locked"`
	Tags          []string `json:"tags"`
	AlwaysPXE     bool     `json:"always_pxe,omitempty"`
	IPXEScriptUrl string   `json:"ipxe_script_url,omitempty"`
}

DeviceUpdateRequest type used to update a Packet device

type Drives

type Drives struct {
	Count int    `json:"count,omitempty"`
	Size  string `json:"size,omitempty"`
	Type  string `json:"type,omitempty"`
}

Drives - the storage config details for specs on a plan

func (Drives) String

func (d Drives) String() string

type Email

type Email struct {
	ID      string `json:"id"`
	Address string `json:"address"`
	Default bool   `json:"default,omitempty"`
	URL     string `json:"href,omitempty"`
}

Email represents a user's email address

func (Email) String

func (e Email) String() string

type EmailService

type EmailService interface {
	Get(string) (*Email, *Response, error)
}

EmailService interface defines available email methods

type EmailServiceOp

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

EmailServiceOp implements EmailService

func (*EmailServiceOp) Get

func (s *EmailServiceOp) Get(emailID string) (*Email, *Response, error)

Get retrieves an email by id

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Errors   []string `json:"errors"`
}

ErrorResponse is the http response used on errrors

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Facility

type Facility struct {
	ID       string   `json:"id"`
	Name     string   `json:"name,omitempty"`
	Code     string   `json:"code,omitempty"`
	Features []string `json:"features,omitempty"`
	Address  *Address `json:"address,omitempty"`
	URL      string   `json:"href,omitempty"`
}

Facility represents a Packet facility

func (Facility) String

func (f Facility) String() string

type FacilityService

type FacilityService interface {
	List() ([]Facility, *Response, error)
}

FacilityService interface defines available facility methods

type FacilityServiceOp

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

FacilityServiceOp implements FacilityService

func (*FacilityServiceOp) List

func (s *FacilityServiceOp) List() ([]Facility, *Response, error)

List returns all available Packet facilities

type Features

type Features struct {
	Raid bool `json:"raid,omitempty"`
	Txt  bool `json:"txt,omitempty"`
}

Features - other features in the specs for a plan

func (Features) String

func (f Features) String() string

type IPAddress

type IPAddress struct {
	ID            string            `json:"id"`
	Address       string            `json:"address"`
	Gateway       string            `json:"gateway"`
	Network       string            `json:"network"`
	AddressFamily int               `json:"address_family"`
	Netmask       string            `json:"netmask"`
	Public        bool              `json:"public"`
	Cidr          int               `json:"cidr"`
	AssignedTo    map[string]string `json:"assigned_to"`
	Created       string            `json:"created_at,omitempty"`
	Updated       string            `json:"updated_at,omitempty"`
	Href          string            `json:"href"`
	Facility      Facility          `json:"facility,omitempty"`
}

IPAddress represents a ip address

func (IPAddress) String

func (i IPAddress) String() string

type IPAddressAssignRequest

type IPAddressAssignRequest struct {
	Address string `json:"address"`
}

IPAddressAssignRequest represents the body if a ip assign request

type IPReservation

type IPReservation struct {
	ID            string              `json:"id"`
	Network       string              `json:"network"`
	Address       string              `json:"address"`
	AddressFamily int                 `json:"address_family"`
	Netmask       string              `json:"netmask"`
	Public        bool                `json:"public"`
	Cidr          int                 `json:"cidr"`
	Management    bool                `json:"management"`
	Manageable    bool                `json:"manageable"`
	Addon         bool                `json:"addon"`
	Bill          bool                `json:"bill"`
	Assignments   []map[string]string `json:"assignments"`
	Created       string              `json:"created_at,omitempty"`
	Updated       string              `json:"updated_at,omitempty"`
	Href          string              `json:"href"`
	Facility      Facility            `json:"facility,omitempty"`
}

IPReservation represent an IP reservation for a single project

type IPReservationRequest

type IPReservationRequest struct {
	Type     string `json:"type"`
	Quantity int    `json:"quantity"`
	Comments string `json:"comments"`
	Facility string `json:"facility"`
}

IPReservationRequest represents the body of a reservation request

type IPReservationService

type IPReservationService interface {
	List(projectID string) ([]IPReservation, *Response, error)
	RequestMore(projectID string, ipReservationReq *IPReservationRequest) (*IPReservation, *Response, error)
	Get(ipReservationID string) (*IPReservation, *Response, error)
	Remove(ipReservationID string) (*Response, error)
}

IPReservationService interface defines available IPReservation methods

type IPReservationServiceOp

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

IPReservationServiceOp implements the IPReservationService interface

func (*IPReservationServiceOp) Get

func (i *IPReservationServiceOp) Get(ipReservationID string) (*IPReservation, *Response, error)

Get returns a single IP reservation object

func (*IPReservationServiceOp) List

func (i *IPReservationServiceOp) List(projectID string) ([]IPReservation, *Response, error)

List provides a list of IP resevations for a single project.

func (*IPReservationServiceOp) Remove

func (i *IPReservationServiceOp) Remove(ipReservationID string) (*Response, error)

Remove removes an IP reservation from the project.

func (*IPReservationServiceOp) RequestMore

func (i *IPReservationServiceOp) RequestMore(projectID string, ipReservationReq *IPReservationRequest) (*IPReservation, *Response, error)

RequestMore requests more IP space for a project in order to have additional IP addresses to assign to devices

type IPService

type IPService interface {
	Assign(deviceID string, assignRequest *IPAddressAssignRequest) (*IPAddress, *Response, error)
	Unassign(ipAddressID string) (*Response, error)
	Get(ipAddressID string) (*IPAddress, *Response, error)
}

IPService interface defines available IP methods

type IPServiceOp

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

IPServiceOp implements IPService

func (*IPServiceOp) Assign

func (i *IPServiceOp) Assign(deviceID string, assignRequest *IPAddressAssignRequest) (*IPAddress, *Response, error)

Assign assigns an IP address to a device. The IP address must be in one of the IP ranges assigned to the device’s project.

func (*IPServiceOp) Get

func (i *IPServiceOp) Get(ipAddressID string) (*IPAddress, *Response, error)

Get returns IpAddress by ID

func (*IPServiceOp) Unassign

func (i *IPServiceOp) Unassign(ipAddressID string) (*Response, error)

Unassign unassigns an IP address record. This will remove the relationship between an IP and the device and will make the IP address available to be assigned to another device.

type ListOptions

type ListOptions struct {
	// for paginated result sets, page of results to retrieve
	Page int `url:"page,omitempty"`

	// for paginated result sets, the number of results to return per page
	PerPage int `url:"per_page,omitempty"`

	// specify which resources you want to return as collections instead of references
	Includes string
}

ListOptions specifies optional global API parameters

type Memory

type Memory struct {
	Total string `json:"total,omitempty"`
}

Memory - the RAM config details for specs on a plan

func (Memory) String

func (m Memory) String() string

type Nics

type Nics struct {
	Count int    `json:"count,omitempty"`
	Type  string `json:"type,omitempty"`
}

Nics - the network hardware details for specs on a plan

func (Nics) String

func (n Nics) String() string

type OS

type OS struct {
	Name    string `json:"name"`
	Slug    string `json:"slug"`
	Distro  string `json:"distro"`
	Version string `json:"version"`
}

OS represents a Packet operating system

func (OS) String

func (o OS) String() string

type OSService

type OSService interface {
	List() ([]OS, *Response, error)
}

OSService interface defines available operating_systems methods

type OSServiceOp

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

OSServiceOp implements OSService

func (*OSServiceOp) List

func (s *OSServiceOp) List() ([]OS, *Response, error)

List returns all available operating systems

type Plan

type Plan struct {
	ID          string   `json:"id"`
	Slug        string   `json:"slug,omitempty"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	Line        string   `json:"line,omitempty"`
	Specs       *Specs   `json:"specs,omitempty"`
	Pricing     *Pricing `json:"pricing,omitempty"`
}

Plan represents a Packet service plan

func (Plan) String

func (p Plan) String() string

type PlanService

type PlanService interface {
	List() ([]Plan, *Response, error)
}

PlanService interface defines available plan methods

type PlanServiceOp

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

PlanServiceOp implements PlanService

func (*PlanServiceOp) List

func (s *PlanServiceOp) List() ([]Plan, *Response, error)

List method returns all available plans

type Pricing

type Pricing struct {
	Hourly  float32 `json:"hourly,omitempty"`
	Monthly float32 `json:"monthly,omitempty"`
}

Pricing - the pricing options on a plan

func (Pricing) String

func (p Pricing) String() string

type Project

type Project struct {
	ID      string   `json:"id"`
	Name    string   `json:"name,omitempty"`
	Created string   `json:"created_at,omitempty"`
	Updated string   `json:"updated_at,omitempty"`
	Users   []User   `json:"members,omitempty"`
	Devices []Device `json:"devices,omitempty"`
	SSHKeys []SSHKey `json:"ssh_keys,omitempty"`
	URL     string   `json:"href,omitempty"`
}

Project represents a Packet project

func (Project) String

func (p Project) String() string

type ProjectCreateRequest

type ProjectCreateRequest struct {
	Name          string `json:"name"`
	PaymentMethod string `json:"payment_method,omitempty"`
}

ProjectCreateRequest type used to create a Packet project

func (ProjectCreateRequest) String

func (p ProjectCreateRequest) String() string

type ProjectService

type ProjectService interface {
	List() ([]Project, *Response, error)
	Get(string) (*Project, *Response, error)
	Create(*ProjectCreateRequest) (*Project, *Response, error)
	Update(*ProjectUpdateRequest) (*Project, *Response, error)
	Delete(string) (*Response, error)
	ListIPAddresses(string) ([]IPAddress, *Response, error)
	ListVolumes(string) ([]Volume, *Response, error)
}

ProjectService interface defines available project methods

type ProjectServiceOp

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

ProjectServiceOp implements ProjectService

func (*ProjectServiceOp) Create

func (s *ProjectServiceOp) Create(createRequest *ProjectCreateRequest) (*Project, *Response, error)

Create creates a new project

func (*ProjectServiceOp) Delete

func (s *ProjectServiceOp) Delete(projectID string) (*Response, error)

Delete deletes a project

func (*ProjectServiceOp) Get

func (s *ProjectServiceOp) Get(projectID string) (*Project, *Response, error)

Get returns a project by id

func (*ProjectServiceOp) List

func (s *ProjectServiceOp) List() ([]Project, *Response, error)

List returns the user's projects

func (*ProjectServiceOp) ListIPAddresses

func (s *ProjectServiceOp) ListIPAddresses(projectID string) ([]IPAddress, *Response, error)

func (*ProjectServiceOp) ListVolumes

func (s *ProjectServiceOp) ListVolumes(projectID string) ([]Volume, *Response, error)

List returns Volumes for a project

func (*ProjectServiceOp) Update

func (s *ProjectServiceOp) Update(updateRequest *ProjectUpdateRequest) (*Project, *Response, error)

Update updates a project

type ProjectUpdateRequest

type ProjectUpdateRequest struct {
	ID            string `json:"id"`
	Name          string `json:"name,omitempty"`
	PaymentMethod string `json:"payment_method,omitempty"`
}

ProjectUpdateRequest type used to update a Packet project

func (ProjectUpdateRequest) String

func (p ProjectUpdateRequest) String() string

type Rate

type Rate struct {
	RequestLimit      int       `json:"request_limit"`
	RequestsRemaining int       `json:"requests_remaining"`
	Reset             Timestamp `json:"rate_reset"`
}

Rate provides the API request rate limit details

func (Rate) String

func (r Rate) String() string

type Response

type Response struct {
	*http.Response
	Rate
}

Response is the http response from api calls

type SSHKey

type SSHKey struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Key         string `json:"key"`
	FingerPrint string `json:"fingerprint"`
	Created     string `json:"created_at"`
	Updated     string `json:"updated_at"`
	User        User   `json:"user,omitempty"`
	URL         string `json:"href,omitempty"`
}

SSHKey represents a user's ssh key

func (SSHKey) String

func (s SSHKey) String() string

type SSHKeyCreateRequest

type SSHKeyCreateRequest struct {
	Label     string `json:"label"`
	Key       string `json:"key"`
	ProjectID string `json:"-"`
}

SSHKeyCreateRequest type used to create an ssh key

func (SSHKeyCreateRequest) String

func (s SSHKeyCreateRequest) String() string

type SSHKeyService

type SSHKeyService interface {
	List() ([]SSHKey, *Response, error)
	Get(string) (*SSHKey, *Response, error)
	Create(*SSHKeyCreateRequest) (*SSHKey, *Response, error)
	Update(*SSHKeyUpdateRequest) (*SSHKey, *Response, error)
	Delete(string) (*Response, error)
}

SSHKeyService interface defines available device methods

type SSHKeyServiceOp

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

SSHKeyServiceOp implements SSHKeyService

func (*SSHKeyServiceOp) Create

func (s *SSHKeyServiceOp) Create(createRequest *SSHKeyCreateRequest) (*SSHKey, *Response, error)

Create creates a new ssh key

func (*SSHKeyServiceOp) Delete

func (s *SSHKeyServiceOp) Delete(sshKeyID string) (*Response, error)

Delete deletes an ssh key

func (*SSHKeyServiceOp) Get

func (s *SSHKeyServiceOp) Get(sshKeyID string) (*SSHKey, *Response, error)

Get returns an ssh key by id

func (*SSHKeyServiceOp) List

func (s *SSHKeyServiceOp) List() ([]SSHKey, *Response, error)

List returns a user's ssh keys

func (*SSHKeyServiceOp) Update

func (s *SSHKeyServiceOp) Update(updateRequest *SSHKeyUpdateRequest) (*SSHKey, *Response, error)

Update updates an ssh key

type SSHKeyUpdateRequest

type SSHKeyUpdateRequest struct {
	ID    string `json:"id"`
	Label string `json:"label"`
	Key   string `json:"key"`
}

SSHKeyUpdateRequest type used to update an ssh key

func (SSHKeyUpdateRequest) String

func (s SSHKeyUpdateRequest) String() string

type SnapshotPolicy

type SnapshotPolicy struct {
	ID                string `json:"id"`
	Href              string `json:"href"`
	SnapshotFrequency string `json:"snapshot_frequency,omitempty"`
	SnapshotCount     int    `json:"snapshot_count,omitempty"`
}

SnapshotPolicy used to execute actions on volume

type Specs

type Specs struct {
	Cpus     []*Cpus   `json:"cpus,omitempty"`
	Memory   *Memory   `json:"memory,omitempty"`
	Drives   []*Drives `json:"drives,omitempty"`
	Nics     []*Nics   `json:"nics,omitempty"`
	Features *Features `json:"features,omitempty"`
}

Specs - the server specs for a plan

func (Specs) String

func (s Specs) String() string

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. All exported methods of time.Time can be called on Timestamp.

func (Timestamp) Equal

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

type User

type User struct {
	ID          string  `json:"id"`
	FirstName   string  `json:"first_name,omitempty"`
	LastName    string  `json:"last_name,omitempty"`
	FullName    string  `json:"full_name,omitempty"`
	Email       string  `json:"email,omitempty"`
	TwoFactor   string  `json:"two_factor_auth,omitempty"`
	AvatarURL   string  `json:"avatar_url,omitempty"`
	Facebook    string  `json:"twitter,omitempty"`
	Twitter     string  `json:"facebook,omitempty"`
	LinkedIn    string  `json:"linkedin,omitempty"`
	Created     string  `json:"created_at,omitempty"`
	Updated     string  `json:"updated_at,omitempty"`
	TimeZone    string  `json:"timezone,omitempty"`
	Emails      []Email `json:"email,omitempty"`
	PhoneNumber string  `json:"phone_number,omitempty"`
	URL         string  `json:"href,omitempty"`
}

User represents a Packet user

func (User) String

func (u User) String() string

type UserService

type UserService interface {
	Get(string) (*User, *Response, error)
}

UserService interface defines available user methods

type UserServiceOp

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

UserServiceOp implements UserService

func (*UserServiceOp) Get

func (s *UserServiceOp) Get(userID string) (*User, *Response, error)

Get method gets a user by userID

type Volume

type Volume struct {
	ID               string            `json:"id"`
	Name             string            `json:"name,omitempty"`
	Description      string            `json:"description,omitempty"`
	Size             int               `json:"size,omitempty"`
	State            string            `json:"state,omitempty"`
	Locked           bool              `json:"locked,omitempty"`
	BillingCycle     string            `json:"billing_cycle,omitempty"`
	Created          string            `json:"created_at,omitempty"`
	Updated          string            `json:"updated_at,omitempty"`
	Href             string            `json:"href,omitempty"`
	SnapshotPolicies []*SnapshotPolicy `json:"snapshot_policies,omitempty"`
	Attachments      []*Attachment     `json:"attachments,omitempty"`
	Plan             *Plan             `json:"plan,omitempty"`
	Facility         *Facility         `json:"facility,omitempty"`
	Project          *Project          `json:"project,omitempty"`
}

Volume represents a volume

func (Volume) String

func (v Volume) String() string

type VolumeCreateRequest

type VolumeCreateRequest struct {
	Size             int               `json:"size"`
	BillingCycle     string            `json:"billing_cycle"`
	ProjectID        string            `json:"project_id"`
	PlanID           string            `json:"plan_id"`
	FacilityID       string            `json:"facility_id"`
	Description      string            `json:"description,omitempty"`
	SnapshotPolicies []*SnapshotPolicy `json:"snapshot_policies,omitempty"`
}

VolumeCreateRequest type used to create a Packet volume

func (VolumeCreateRequest) String

func (v VolumeCreateRequest) String() string

type VolumeService

type VolumeService interface {
	Get(string) (*Volume, *Response, error)
	Update(*VolumeUpdateRequest) (*Volume, *Response, error)
	Delete(string) (*Response, error)
	Create(*VolumeCreateRequest) (*Volume, *Response, error)
}

VolumeService interface defines available Volume methods

type VolumeServiceOp

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

VolumeServiceOp implements VolumeService

func (*VolumeServiceOp) Create

func (v *VolumeServiceOp) Create(createRequest *VolumeCreateRequest) (*Volume, *Response, error)

Create creates a new volume for a project

func (*VolumeServiceOp) Delete

func (v *VolumeServiceOp) Delete(volumeID string) (*Response, error)

Delete deletes a volume

func (*VolumeServiceOp) Get

func (v *VolumeServiceOp) Get(volumeID string) (*Volume, *Response, error)

Get returns a volume by id

func (*VolumeServiceOp) Update

func (v *VolumeServiceOp) Update(updateRequest *VolumeUpdateRequest) (*Volume, *Response, error)

Update updates a volume

type VolumeUpdateRequest

type VolumeUpdateRequest struct {
	ID          string `json:"id"`
	Description string `json:"description,omitempty"`
	Plan        string `json:"plan,omitempty"`
}

VolumeUpdateRequest type used to update a Packet volume

func (VolumeUpdateRequest) String

func (v VolumeUpdateRequest) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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